Can linear extrude twist elliptically instead of circularly?

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

Can linear extrude twist elliptically instead of circularly?

NathanA
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.



What is the best way to accomplish this?
Reply | Threaded
Open this post in threaded view
|

Re: Can linear extrude twist elliptically instead of circularly?

Ronaldo
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 <[hidden email]>:
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
[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: Can linear extrude twist elliptically instead of circularly?

Ronaldo
a = 3;
b = 2;
scale([a,b,1]) linear_extrude(40, twist=360) translate([2*a,0]) scale([1/a,1/b]) circle(5);
Reply | Threaded
Open this post in threaded view
|

Re: Can linear extrude twist elliptically instead of circularly?

NathanA
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);



The extrusion is not circular.
Reply | Threaded
Open this post in threaded view
|

Re: Can linear extrude twist elliptically instead of circularly?

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


2016-07-06 2:30 GMT-03:00 NathanA <[hidden email]>:
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
[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: Can linear extrude twist elliptically instead of circularly?

lhartmann
In reply to this post by NathanA
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Can linear extrude twist elliptically instead of circularly?

Ronaldo
In reply to this post by Ronaldo
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 <[hidden email]>:
Replace the translate by translate([a*b,0])


2016-07-06 2:30 GMT-03:00 NathanA <[hidden email]>:
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
[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: Can linear extrude twist elliptically instead of circularly?

Ronaldo
In reply to this post by NathanA
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] ];
Reply | Threaded
Open this post in threaded view
|

Re: Can linear extrude twist elliptically instead of circularly?

Ronaldo
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] ];