discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Can linear extrude twist elliptically instead of circularly?

N
NathanA
Sun, Jul 3, 2016 6:51 AM

I created a curve using linear_extrude of a circle, with the twist parameter
and the resulting extrusion twists around an invisible cylinder. What I am
looking to do is have the extrusion twist around an elliptical cylinder. I
could scale after the linear_extrude, and while that does make the hole
elliptical, it also stretches the extrusions, which I do not want.

As you can see here, the left shape extrudes around a cylinder - on the
right after using scale the hole becomes elliptical cylinder but the
extrusions are stretched as well.

http://forum.openscad.org/file/n17868/Capture.png

What is the best way to accomplish this?

--
View this message in context: http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I created a curve using linear_extrude of a circle, with the twist parameter and the resulting extrusion twists around an invisible cylinder. What I am looking to do is have the extrusion twist around an elliptical cylinder. I could scale after the linear_extrude, and while that does make the hole elliptical, it also stretches the extrusions, which I do not want. As you can see here, the left shape extrudes around a cylinder - on the right after using scale the hole becomes elliptical cylinder but the extrusions are stretched as well. <http://forum.openscad.org/file/n17868/Capture.png> What is the best way to accomplish this? -- View this message in context: http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868.html Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Sun, Jul 3, 2016 2:25 PM

If you scaled the linear_extrude with, say, [a,b,1], scale the circle
before the linear_extrude with [1/a, 1/b].

2016-07-03 3:51 GMT-03:00 NathanA napter@gmail.com:

I created a curve using linear_extrude of a circle, with the twist
parameter
and the resulting extrusion twists around an invisible cylinder. What I am
looking to do is have the extrusion twist around an elliptical cylinder. I
could scale after the linear_extrude, and while that does make the hole
elliptical, it also stretches the extrusions, which I do not want.

As you can see here, the left shape extrudes around a cylinder - on the
right after using scale the hole becomes elliptical cylinder but the
extrusions are stretched as well.

http://forum.openscad.org/file/n17868/Capture.png

What is the best way to accomplish this?

--
View this message in context:
http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868.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

If you scaled the linear_extrude with, say, [a,b,1], scale the circle before the linear_extrude with [1/a, 1/b]. 2016-07-03 3:51 GMT-03:00 NathanA <napter@gmail.com>: > I created a curve using linear_extrude of a circle, with the twist > parameter > and the resulting extrusion twists around an invisible cylinder. What I am > looking to do is have the extrusion twist around an elliptical cylinder. I > could scale after the linear_extrude, and while that does make the hole > elliptical, it also stretches the extrusions, which I do not want. > > As you can see here, the left shape extrudes around a cylinder - on the > right after using scale the hole becomes elliptical cylinder but the > extrusions are stretched as well. > > <http://forum.openscad.org/file/n17868/Capture.png> > > What is the best way to accomplish this? > > > > -- > View this message in context: > http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868.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, Jul 3, 2016 2:40 PM

a = 3;
b = 2;
scale([a,b,1]) linear_extrude(40, twist=360) translate([2*a,0])
scale([1/a,1/b]) circle(5);

> a = 3; > b = 2; > scale([a,b,1]) linear_extrude(40, twist=360) translate([2*a,0]) > scale([1/a,1/b]) circle(5); <http://forum.openscad.org/file/n17870/twisted.png> -- View this message in context: http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868p17870.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
NathanA
Wed, Jul 6, 2016 5:30 AM

That doesn't seem to work. Try changing a = 4 and b = 1:

a = 4;
b = 1;
scale([a,b,1]) linear_extrude(40, twist=360) translate([2*a,0])
scale([1/a,1/b]) circle(5);

http://forum.openscad.org/file/n17885/Capture.png

The extrusion is not circular.

--
View this message in context: http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868p17885.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

That doesn't seem to work. Try changing a = 4 and b = 1: a = 4; b = 1; scale([a,b,1]) linear_extrude(40, twist=360) translate([2*a,0]) scale([1/a,1/b]) circle(5); <http://forum.openscad.org/file/n17885/Capture.png> The extrusion is not circular. -- View this message in context: http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868p17885.html Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Wed, Jul 6, 2016 12:11 PM

Replace the translate by translate([a*b,0])

2016-07-06 2:30 GMT-03:00 NathanA napter@gmail.com:

That doesn't seem to work. Try changing a = 4 and b = 1:

a = 4;
b = 1;
scale([a,b,1]) linear_extrude(40, twist=360) translate([2*a,0])
scale([1/a,1/b]) circle(5);

http://forum.openscad.org/file/n17885/Capture.png

The extrusion is not circular.

--
View this message in context:
http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868p17885.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

Replace the translate by translate([a*b,0]) 2016-07-06 2:30 GMT-03:00 NathanA <napter@gmail.com>: > That doesn't seem to work. Try changing a = 4 and b = 1: > > a = 4; > b = 1; > scale([a,b,1]) linear_extrude(40, twist=360) translate([2*a,0]) > scale([1/a,1/b]) circle(5); > > <http://forum.openscad.org/file/n17885/Capture.png> > > The extrusion is not circular. > > > > -- > View this message in context: > http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868p17885.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 >
LV
Lucas Vinicius Hartmann
Wed, Jul 6, 2016 12:36 PM

If you mean you want the wires to be constant width but the spiral to be
compressed sideways then linear extrude is probably not going to help.

You may get what you want by creating segment by segment. Translate 2 very
short cylinders (h=0.001) to their positions and hull() them together.
Place these segments in a for loop and you should be good.
Em 3 de jul de 2016 03:52, "NathanA" napter@gmail.com escreveu:

I created a curve using linear_extrude of a circle, with the twist
parameter
and the resulting extrusion twists around an invisible cylinder. What I am
looking to do is have the extrusion twist around an elliptical cylinder. I
could scale after the linear_extrude, and while that does make the hole
elliptical, it also stretches the extrusions, which I do not want.

As you can see here, the left shape extrudes around a cylinder - on the
right after using scale the hole becomes elliptical cylinder but the
extrusions are stretched as well.

http://forum.openscad.org/file/n17868/Capture.png

What is the best way to accomplish this?

--
View this message in context:
http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868.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

If you mean you want the wires to be constant width but the spiral to be compressed sideways then linear extrude is probably not going to help. You may get what you want by creating segment by segment. Translate 2 very short cylinders (h=0.001) to their positions and hull() them together. Place these segments in a for loop and you should be good. Em 3 de jul de 2016 03:52, "NathanA" <napter@gmail.com> escreveu: > I created a curve using linear_extrude of a circle, with the twist > parameter > and the resulting extrusion twists around an invisible cylinder. What I am > looking to do is have the extrusion twist around an elliptical cylinder. I > could scale after the linear_extrude, and while that does make the hole > elliptical, it also stretches the extrusions, which I do not want. > > As you can see here, the left shape extrudes around a cylinder - on the > right after using scale the hole becomes elliptical cylinder but the > extrusions are stretched as well. > > <http://forum.openscad.org/file/n17868/Capture.png> > > What is the best way to accomplish this? > > > > -- > View this message in context: > http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868.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 >
RP
Ronaldo Persiano
Wed, Jul 6, 2016 12:44 PM

I checked it now. You are right, it does not work. But this do it with a
lot more working time:

a = 4;
b = 1;
c = 10;
minkowski(){
scale([a,b,1]) linear_extrude(40, twist=360) translate([c,0])
circle(0.0001);
cylinder(r=5,h=0.0001);
}

2016-07-06 9:11 GMT-03:00 Ronaldo Persiano rcmpersiano@gmail.com:

Replace the translate by translate([a*b,0])

2016-07-06 2:30 GMT-03:00 NathanA napter@gmail.com:

That doesn't seem to work. Try changing a = 4 and b = 1:

a = 4;
b = 1;
scale([a,b,1]) linear_extrude(40, twist=360) translate([2*a,0])
scale([1/a,1/b]) circle(5);

http://forum.openscad.org/file/n17885/Capture.png

The extrusion is not circular.

--
View this message in context:
http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868p17885.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

I checked it now. You are right, it does not work. But this do it with a lot more working time: a = 4; b = 1; c = 10; minkowski(){ scale([a,b,1]) linear_extrude(40, twist=360) translate([c,0]) circle(0.0001); cylinder(r=5,h=0.0001); } 2016-07-06 9:11 GMT-03:00 Ronaldo Persiano <rcmpersiano@gmail.com>: > Replace the translate by translate([a*b,0]) > > > 2016-07-06 2:30 GMT-03:00 NathanA <napter@gmail.com>: > >> That doesn't seem to work. Try changing a = 4 and b = 1: >> >> a = 4; >> b = 1; >> scale([a,b,1]) linear_extrude(40, twist=360) translate([2*a,0]) >> scale([1/a,1/b]) circle(5); >> >> <http://forum.openscad.org/file/n17885/Capture.png> >> >> The extrusion is not circular. >> >> >> >> -- >> View this message in context: >> http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868p17885.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
Wed, Jul 6, 2016 3:03 PM

From the beginning, you were asking for a translational sweeping. Here you

have it:

translational_sweep(elliptical_path(40,10,40,360,$fa=5)) circle(5);

module translational_sweep(path) {
dz = h/(len(path)-1);
for(i=[0:len(path)-2]){
hull(){
translate(path[i])
linear_extrude(0.001) children();
translate(path[i+1])
linear_extrude(0.001) children();
}
}
}

function elliptical_path(a,b,h,ang) =
[ for(x=[0:$fa:ang]) [acos(x), bsin(x), h*x/ang] ];

--
View this message in context: http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868p17892.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

>From the beginning, you were asking for a translational sweeping. Here you have it: > translational_sweep(elliptical_path(40,10,40,360,$fa=5)) circle(5); > > module translational_sweep(path) { > dz = h/(len(path)-1); > for(i=[0:len(path)-2]){ > hull(){ > translate(path[i]) > linear_extrude(0.001) children(); > translate(path[i+1]) > linear_extrude(0.001) children(); > } > } > } > > function elliptical_path(a,b,h,ang) = > [ for(x=[0:$fa:ang]) [a*cos(x), b*sin(x), h*x/ang] ]; -- View this message in context: http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868p17892.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
Ronaldo
Wed, Jul 6, 2016 4:50 PM

The module translational_sweep requires that the section be convex. The
following version accepts closed paths and non-convex sections. It does not
use hull() and minkowski is needed just for horizontal segments in the path.

translational_sweep2(path(), closed=true) star();

module translational_sweep2(path, closed=false) {
p = closed ? concat( path, [ path[0] ]) : path;
for(i=[0:len(p)-2]){
if( p[i+1][2]-p[i][2] > 0 ) {
translate(p[i])
slice(p[i], p[i+1]) children();
}
else if( p[i+1][2]-p[i][2] < 0 ) {
translate(p[i+1])
slice(p[i+1], p[i]) children();
}
else {
minkowski(){
linear_extrude(0.0001) children();
hull() {
translate(p[i]) cube(0.0001);
translate(p[i+1]) cube(0.0001);
}
}
}
}
}

function path() =
concat([ for(x=[0:5:180]) [40cos(x), 40sin(x), 100x/360] ],
[ for(x=[180:-5:0]) [-40
cos(x), -40sin(x), 100x/360] ] ) ;

module star() {
scale([3,1]) rotate(45) square(5,center=true);
scale([1,3]) rotate(45) square(5,center=true); }

module slice(a,b) {
multmatrix(shear([(b[0]-a[0])/(b[2]-a[2]), (b[1]-a[1])/(b[2]-a[2])]))
linear_extrude(b[2]-a[2]) children();
}

function shear(d=[0,0])=
[ [1,0,d[0],0], [0,1,d[1],0],[0,0,1,0],[0,0,0,1] ];

The module translational_sweep requires that the section be convex. The following version accepts closed paths and non-convex sections. It does not use hull() and minkowski is needed just for horizontal segments in the path. > translational_sweep2(path(), closed=true) star(); > > module translational_sweep2(path, closed=false) { > p = closed ? concat( path, [ path[0] ]) : path; > for(i=[0:len(p)-2]){ > if( p[i+1][2]-p[i][2] > 0 ) { > translate(p[i]) > slice(p[i], p[i+1]) children(); > } > else if( p[i+1][2]-p[i][2] < 0 ) { > translate(p[i+1]) > slice(p[i+1], p[i]) children(); > } > else { > minkowski(){ > linear_extrude(0.0001) children(); > hull() { > translate(p[i]) cube(0.0001); > translate(p[i+1]) cube(0.0001); > } > } > } > } > } > > function path() = > concat([ for(x=[0:5:180]) [40*cos(x), 40*sin(x), 100*x/360] ], > [ for(x=[180:-5:0]) [-40*cos(x), -40*sin(x), 100*x/360] ] ) ; > > module star() { > scale([3,1]) rotate(45) square(5,center=true); > scale([1,3]) rotate(45) square(5,center=true); } > > module slice(a,b) { > multmatrix(shear([(b[0]-a[0])/(b[2]-a[2]), (b[1]-a[1])/(b[2]-a[2])])) > linear_extrude(b[2]-a[2]) children(); > } > > function shear(d=[0,0])= > [ [1,0,d[0],0], [0,1,d[1],0],[0,0,1,0],[0,0,0,1] ]; <http://forum.openscad.org/file/n17893/star_sweeping.png> -- View this message in context: http://forum.openscad.org/Can-linear-extrude-twist-elliptically-instead-of-circularly-tp17868p17893.html Sent from the OpenSCAD mailing list archive at Nabble.com.