discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

geometry help

DS
Dan Shriver
Sun, Sep 18, 2016 4:56 PM

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 runsun@gmail.com 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 );   $ 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <runsun@gmail.com> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
DS
Dan Shriver
Sun, Sep 18, 2016 5:54 PM

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 runsun@gmail.com 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 );   $ 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <runsun@gmail.com> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
R
Ronaldo
Sun, Sep 18, 2016 9:47 PM

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([-r1cos(a)-c1x, r1sin(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([-2r,0]) square(4r);
rotate(-a1) translate([-2r,0]) square(4r);
}

Note that $fn is a global variable. See the OpenSCAD manual
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#.24fa.2C_.24fs_and_.24fn
.

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

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 <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#.24fa.2C_.24fs_and_.24fn> . -- View this message in context: http://forum.openscad.org/geometry-help-tp18393p18412.html Sent from the OpenSCAD mailing list archive at Nabble.com.