geometry help

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

geometry help

DanS
I'm working on some code to build arches of various types.

I have some code working that builds arches using two circles (trivial).

I am now working on a general "four cirlce" arch (sometimes called "loin of the donkey", or "ogee" arch).  My solution looks like it works when the radii are equal but the angles of intersection (among other things) are clearly off.  If the radii are not equal this becomes quickly evident (even if they are equal and you zoom in a lot you can see there is some incorrect overlap).

Anyone good with geometry who can point out my problem?

I also copied two routines from this list to aid me "pie_slice()" and "point()"

module archSlice(x,y,r,fnNum,angleStarta=0, angleEnda=0, angleStartb=0, angleEndb=0) {
    translate([x,y,0]) {
        pie_slice(r,angleStartb,angleEndb,fnNum);
    }
    translate([-x,y,0]) {
        pie_slice(r,angleStarta,angleEnda,fnNum);
    }
}

module archDbl(x,y,r,fnNum) {
  intersection() {
    translate([x,y,0]) {
      circle(r, $fn=fnNum);
    }
    translate([-x,y,0]) {
      circle(r, $fn=fnNum);
    }
  }
}

module arch(x,y,r,fnNum,angleStarta=0, angleEnda=0, angleStartb=0, angleEndb) {
  if (angleStarta == 0 && angleEnda == 0 && angleStartb == 0 && angleEndb ==0) {
    difference() {
      archDbl(x,y,r,fnNum);
      translate([0,-r/2,0]) {
        square([r,r],center=true);
      }
    }
  }
  else {
     archSlice(x,y,r,fnNum,angleStarta, angleEnda, angleStartb, angleEndb);
  }
}

module ogee(x,y,r1,r2,fnNum,width) {
    angle = asin((r2+x)/(r1+r2)); //my problem is probably from how I use this angle
    x2 = x - (r1+r2)*(sin(angle));
    y2 = y + (r1+r2)*(cos(angle));
    
    difference() {
      arch(x,y,r1,fnNum,0,angle,(180-angle),180); //for instance maybe it shouldn't be 180-angle
      arch(x,y,(r1-width),fnNum,0,angle,(180-angle),180);
    }
    
    translate([(x2),(y2),0]) {
        difference() {
          pie_slice((r2+width),(0-angle),0,fnNum);//or maybe it shouldn't be 0-angle
          pie_slice(r2,(0-angle),0,fnNum);
          translate([(-2*x2),0,0]) {            
            pie_slice(r2,180,(180+angle),fnNum);
          } 
        }
    }
    translate([(-x2),(y2),0]) {
        difference() {
          pie_slice((r2+width),180,(180+angle),fnNum);//or maybe it shouldn't be 180+angle
          pie_slice(r2,180,(180+angle),fnNum);
          translate([(2*x2),0,0]) {  
            pie_slice(r2,(0-angle),0,fnNum);
          }
        }
    }
}

//if you change the fourth parameter to not be equal to the third (or zoom in) you can see
//there is incorrect overlap etc...
ogee(10,0,20,20,100,2);


module point(x,y) translate([x,y]) circle(0.01);

module pie_slice(r, a0, a1, fnNum) {
    //$fa = 5;
    R = r * sqrt(2) + 1;
    intersection() {
        circle(r, $fn=fnNum);
        hull() {
            point(0,0);
            for(i = [0:4])
                //a = (((4 - i) * a0 + i * a1) / 4);
                     point(R * cos((((4 - i) * a0 + i * a1) / 4)), R * sin((((4 - i) * a0 + i * a1) / 4)));
       }
    }
}


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

runsun
This code:
r1=20;
r2=40;
rotate( [0,0,-45] ){
  translate([-r1,0,0]) pie_slice(r1,0,45, 50);
  translate([r2,0,0]) mirror( [0,1,0]) mirror( [1,0,0]) pie_slice(r2,0,45, 50);
}
gives a shape:



You can go from there.
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

DanS
That code is infinitely more elegant than what I wrote.

I might need more help later on since I'm not sure how to make it do some of the things I am thinking about, but I'll play around with it for now and ask if I need more help.

On Fri, Sep 16, 2016 at 5:19 PM, runsun <[hidden email]> wrote:
This code:

> r1=20;
> r2=40;
> rotate( [0,0,-45] ){
>   translate([-r1,0,0]) pie_slice(r1,0,45, 50);
>   translate([r2,0,0]) mirror( [0,1,0]) mirror( [1,0,0]) pie_slice(r2,0,45,
> 50);
> }

gives a shape:

<http://forum.openscad.org/file/n18394/160916-Ogee_math.png>

You can go from there.



-----

$  Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); &nbsp; $ tips: hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2, 3 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf )
--
View this message in context: http://forum.openscad.org/geometry-help-tp18393p18394.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

Ronaldo
In reply to this post by DanS
The math of your arcs:

Let O be the arc internal opening, t the arc thickness, r1 and r2 the external radius of the lower and the internal radius of the upper circles, then:

the center of the lower circle  C1 = [ O / 2 + t - r1, 0]
the center of the upper circle C2 = [ r2, r2*sin(a)+r1*sin(a) ]
the concordance point  CP = [C1[0] + r1*cos(a), C2[1] - r2*sin(a)]

where a = acos((r2 - O/2 - t - r1)/( r1 + r2 )).

This will give you the outer border of the arc. For the inner border, the angle a is the same.

Ogee_arc.PNG
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

DanS
When you say C1[0] and C2[1] do you just mean C1 and C2 or something else?

On Fri, Sep 16, 2016 at 7:03 PM, Ronaldo <[hidden email]> wrote:
The math of your arcs:

Let O be the arc internal opening, t the arc thickness, r1 and r2 the
external radius of the lower and the internal radius of the upper circles,
then:

the center of the lower circle  C1 = [ O / 2 + t - r1, 0]
the center of the upper circle C2 = [ r2, r2*sin(a)+r1*sin(a) ]
the concordance point  CP = [C1[0] + r1*cos(a), C2[1] - r2*sin(a)]

where a = acos((r2 - O/2 - t - r1)/( r1 + r2 )).

This will give you the outer border of the arc. For the inner border, the
angle a is the same.

Ogee_arc.PNG <http://forum.openscad.org/file/n18397/Ogee_arc.PNG>



--
View this message in context: http://forum.openscad.org/geometry-help-tp18393p18397.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

Ronaldo
C1[0] is the first component fo C1, C2[1] the second of C2. Then:

CP = [ O / 2 + t - r1 + r1*cos(a),  r1*sin(a)]

2016-09-16 20:14 GMT-03:00 Dan Shriver <[hidden email]>:
When you say C1[0] and C2[1] do you just mean C1 and C2 or something else?

On Fri, Sep 16, 2016 at 7:03 PM, Ronaldo <[hidden email]> wrote:
The math of your arcs:

Let O be the arc internal opening, t the arc thickness, r1 and r2 the
external radius of the lower and the internal radius of the upper circles,
then:

the center of the lower circle  C1 = [ O / 2 + t - r1, 0]
the center of the upper circle C2 = [ r2, r2*sin(a)+r1*sin(a) ]
the concordance point  CP = [C1[0] + r1*cos(a), C2[1] - r2*sin(a)]

where a = acos((r2 - O/2 - t - r1)/( r1 + r2 )).

This will give you the outer border of the arc. For the inner border, the
angle a is the same.

Ogee_arc.PNG <http://forum.openscad.org/file/n18397/Ogee_arc.PNG>



--
View this message in context: http://forum.openscad.org/geometry-help-tp18393p18397.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

DanS
I'm going to play around with both solutions because runsun's is extremely elegant but might be a huge challange to my brain to get it to do a generalized ogee.

runsun:  I'm trying to move what you did so the bottom is lying on the x axis and the top is on the y axis.  I can get the bottom on the x axis via a translate with y value: (r2*(cos(45)))  but when I try to do something similar to get the top in line I can't get it right.

Ronaldo: I'm not sure what "first component for C1" is

On Sat, Sep 17, 2016 at 3:31 PM, Ronaldo Persiano <[hidden email]> wrote:
C1[0] is the first component fo C1, C2[1] the second of C2. Then:

CP = [ O / 2 + t - r1 + r1*cos(a),  r1*sin(a)]

2016-09-16 20:14 GMT-03:00 Dan Shriver <[hidden email]>:
When you say C1[0] and C2[1] do you just mean C1 and C2 or something else?

On Fri, Sep 16, 2016 at 7:03 PM, Ronaldo <[hidden email]> wrote:
The math of your arcs:

Let O be the arc internal opening, t the arc thickness, r1 and r2 the
external radius of the lower and the internal radius of the upper circles,
then:

the center of the lower circle  C1 = [ O / 2 + t - r1, 0]
the center of the upper circle C2 = [ r2, r2*sin(a)+r1*sin(a) ]
the concordance point  CP = [C1[0] + r1*cos(a), C2[1] - r2*sin(a)]

where a = acos((r2 - O/2 - t - r1)/( r1 + r2 )).

This will give you the outer border of the arc. For the inner border, the
angle a is the same.

Ogee_arc.PNG <http://forum.openscad.org/file/n18397/Ogee_arc.PNG>



--
View this message in context: http://forum.openscad.org/geometry-help-tp18393p18397.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

Ronaldo
C1 is a 2D point; it has two components or coordinates; C1[0] is the first; C1[1] is the second.

2016-09-17 22:37 GMT-03:00 Dan Shriver <[hidden email]>:
I'm going to play around with both solutions because runsun's is extremely elegant but might be a huge challange to my brain to get it to do a generalized ogee.

runsun:  I'm trying to move what you did so the bottom is lying on the x axis and the top is on the y axis.  I can get the bottom on the x axis via a translate with y value: (r2*(cos(45)))  but when I try to do something similar to get the top in line I can't get it right.

Ronaldo: I'm not sure what "first component for C1" is

On Sat, Sep 17, 2016 at 3:31 PM, Ronaldo Persiano <[hidden email]> wrote:
C1[0] is the first component fo C1, C2[1] the second of C2. Then:

CP = [ O / 2 + t - r1 + r1*cos(a),  r1*sin(a)]

2016-09-16 20:14 GMT-03:00 Dan Shriver <[hidden email]>:
When you say C1[0] and C2[1] do you just mean C1 and C2 or something else?

On Fri, Sep 16, 2016 at 7:03 PM, Ronaldo <[hidden email]> wrote:
The math of your arcs:

Let O be the arc internal opening, t the arc thickness, r1 and r2 the
external radius of the lower and the internal radius of the upper circles,
then:

the center of the lower circle  C1 = [ O / 2 + t - r1, 0]
the center of the upper circle C2 = [ r2, r2*sin(a)+r1*sin(a) ]
the concordance point  CP = [C1[0] + r1*cos(a), C2[1] - r2*sin(a)]

where a = acos((r2 - O/2 - t - r1)/( r1 + r2 )).

This will give you the outer border of the arc. For the inner border, the
angle a is the same.

Ogee_arc.PNG <http://forum.openscad.org/file/n18397/Ogee_arc.PNG>



--
View this message in context: http://forum.openscad.org/geometry-help-tp18393p18397.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

MichaelAtOz
Administrator
In reply to this post by DanS
DanS wrote
Ronaldo: I'm not sure what "first component for C1" is
See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Vectors
Admin - email* me if you need anything,
or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

runsun
This post was updated on .
In reply to this post by DanS
DanS wrote
I'm trying to move what you did so the bottom is lying on the x
axis and the top is on the y axis.  I can get the bottom on the x axis via
a translate with y value: (r2*(cos(45)))  but when I try to do something
similar to get the top in line I can't get it right.
Just translate the whole thing with the *correct* formula:

r1=20;
r2=40;
a =60;

translate( [0, r2*sin(a), 0] ){    
    rotate( [0,0,-a] ){
    translate([-r1,0,0]) pie_slice(r1,0,a, 50);
    translate([r2,0,0]) mirror( [0,1,0]) mirror( [1,0,0]) pie_slice(r2,0,a, 50);
    }
}
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

DanS
runsun I think I finally got it correct when I translated by twice the width of the curve (at least it worked on the one case I tested).  Earlier I was trying trigonometric translations which all failed

On Sun, Sep 18, 2016 at 12:40 PM, runsun <[hidden email]> wrote:
DanS wrote
> I'm trying to move what you did so the bottom is lying on the x
> axis and the top is on the y axis.  I can get the bottom on the x axis via
> a translate with y value: (r2*(cos(45)))  but when I try to do something
> similar to get the top in line I can't get it right.

Just translate the whole thing with the *correct* formula:


> r1=20;
> r2=40;
> a =60;
>
> translate( [0, r2*(sin(a)), 0] ){
>     rotate( [0,0,-a] ){
>     translate([-r1,0,0]) pie_slice(r1,0,a, 50);
>     translate([r2,0,0]) mirror( [0,1,0]) mirror( [1,0,0])
> pie_slice(r2,0,a, 50);
>     }
> }





-----

$  Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); &nbsp; $ tips: hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2, 3 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf )
--
View this message in context: http://forum.openscad.org/geometry-help-tp18393p18409.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

DanS
In reply to this post by runsun
runsun: I spoke too soon translating by twice the width only works if r1=20,r2=10,w=1.  I'm trying to put the top point for the r2 pie wedge on the y axis

On Sun, Sep 18, 2016 at 12:40 PM, runsun <[hidden email]> wrote:
DanS wrote
> I'm trying to move what you did so the bottom is lying on the x
> axis and the top is on the y axis.  I can get the bottom on the x axis via
> a translate with y value: (r2*(cos(45)))  but when I try to do something
> similar to get the top in line I can't get it right.

Just translate the whole thing with the *correct* formula:


> r1=20;
> r2=40;
> a =60;
>
> translate( [0, r2*(sin(a)), 0] ){
>     rotate( [0,0,-a] ){
>     translate([-r1,0,0]) pie_slice(r1,0,a, 50);
>     translate([r2,0,0]) mirror( [0,1,0]) mirror( [1,0,0])
> pie_slice(r2,0,a, 50);
>     }
> }





-----

$  Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); &nbsp; $ tips: hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2, 3 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf )
--
View this message in context: http://forum.openscad.org/geometry-help-tp18393p18409.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: geometry help

Ronaldo
DanS wrote
runsun: I spoke too soon translating by twice the width only works if
r1=20,r2=10,w=1.  I'm trying to put the top point for the r2 pie wedge on
the y axis
Well, applying my math to runsun code I got:

loin(opening=25, thickness=2, r1=25, r2=40,$fn=60);

module loin(opening, thickness, r1, r2) {
    // right hand half
    intersection() {
        mirror([-1,0]) half_loin(opening, thickness, r1, r2);
        square(2*(r1+r2));
    }
    // mirroring it
    intersection() {
        half_loin(opening, thickness, r1, r2);
        mirror([-1,0]) square(2*(r1+r2));
    }
}

// half arc before cutting
module half_loin(opening, thickness, r1, r2) {
    // my math
    c1x = opening/2 + thickness - r1;
    c1y = 0;
    c2x = r2;
    a = acos((c2x-c1x)/(r1+r2));
    translate([-r1*cos(a)-c1x, r1*sin(a)])
    // runsun's code
    rotate( [0,0,-a] ){
        translate([-r2,0,0]) pie_arc(r2,a,thickness);
        translate([r1,0,0])
            mirror( [0,1,0])
                mirror( [1,0,0]) pie_arc(r1,a,-thickness);
    }
}

module pie_arc(r,a,t)
    difference() {
        pie_slice(max(r,r+t),0,a,50);
        pie_slice(min(r,r+t),0,a,50);
    }

module pie_slice(r, a0, a1)
    intersection(){
        circle(r);
        rotate( a0) translate([-2*r,0]) square(4*r);
        rotate(-a1) translate([-2*r,0]) square(4*r);
    }
Note that $fn is a global variable. See the OpenSCAD manual.