discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

cylinder with surfaceprofile

RW
Ray West
Mon, Nov 1, 2021 12:24 PM

Hi,

I'm trying to generate a cylinder, with the radius throughout its length
varying as a sine wave. Here is the profile

module profile(){
for(i=[0:7212.5])
    translate([i
5,0,0])
       square([6,(cos(i*5)31)+31+(20100)]);
}

I need to rotate the section around the x-axis to generate the cylinder.
it appears that rotate_extrude is limited to the z axis, and a 2d
drawing is limited to the x/y plane. Any solutions welcomed. From an
example, it seems that if I could generate a 2d polygon of the profile,
then that can be rotated into the y/z plane, and then it can be rotated,
but programmatically generating the polygon in openscad has me stumped.
I think there must be a better way than stacking a thousand or so 1mm
thick discs.

Best wishes,

Ray

Hi, I'm trying to generate a cylinder, with the radius throughout its length varying as a sine wave. Here is the profile module profile(){ for(i=[0:72*12.5])     translate([i*5,0,0])        square([6,(cos(i*5)*31)+31+(20*100)]); } I need to rotate the section around the x-axis to generate the cylinder. it appears that rotate_extrude is limited to the z axis, and a 2d drawing is limited to the x/y plane. Any solutions welcomed. From an example, it seems that if I could generate a 2d polygon of the profile, then that can be rotated into the y/z plane, and then it can be rotated, but programmatically generating the polygon in openscad has me stumped. I think there must be a better way than stacking a thousand or so 1mm thick discs. Best wishes, Ray
D
dpa
Mon, Nov 1, 2021 1:40 PM

rotate([0,90,0]) rotate_extrude(convexity=10) rotate (90) profile();

like this?

Am Mo., 1. Nov. 2021 um 13:24 Uhr schrieb Ray West raywest@raywest.com:

Hi,

I'm trying to generate a cylinder, with the radius throughout its length
varying as a sine wave. Here is the profile

module profile(){
for(i=[0:7212.5])
translate([i
5,0,0])
square([6,(cos(i*5)31)+31+(20100)]);
}

I need to rotate the section around the x-axis to generate the cylinder.
it appears that rotate_extrude is limited to the z axis, and a 2d
drawing is limited to the x/y plane. Any solutions welcomed. From an
example, it seems that if I could generate a 2d polygon of the profile,
then that can be rotated into the y/z plane, and then it can be rotated,
but programmatically generating the polygon in openscad has me stumped.
I think there must be a better way than stacking a thousand or so 1mm
thick discs.

Best wishes,

Ray


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

rotate([0,90,0]) rotate_extrude(convexity=10) rotate (90) profile(); like this? Am Mo., 1. Nov. 2021 um 13:24 Uhr schrieb Ray West <raywest@raywest.com>: > Hi, > > I'm trying to generate a cylinder, with the radius throughout its length > varying as a sine wave. Here is the profile > > module profile(){ > for(i=[0:72*12.5]) > translate([i*5,0,0]) > square([6,(cos(i*5)*31)+31+(20*100)]); > } > > I need to rotate the section around the x-axis to generate the cylinder. > it appears that rotate_extrude is limited to the z axis, and a 2d > drawing is limited to the x/y plane. Any solutions welcomed. From an > example, it seems that if I could generate a 2d polygon of the profile, > then that can be rotated into the y/z plane, and then it can be rotated, > but programmatically generating the polygon in openscad has me stumped. > I think there must be a better way than stacking a thousand or so 1mm > thick discs. > > Best wishes, > > Ray > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RP
Ronaldo Persiano
Mon, Nov 1, 2021 1:42 PM

Is that what you want?

rotate_extrude(convexity=10) rotate(90) profile();

Note that 2d objects like squares and circles live in the plane XY. You are
allowed to rotate them in an axis other than z or translate them off the XY
plane and get a preview image. But that is misleading because render will
keep them in the XY plane despite the transforms. The rule of thumb is
never transform 2d objects off the XY plane. linear_extrude and
rotate_extrude operate on objects in the XY plane. After extrude you may
transform the shape as you want.

Em seg., 1 de nov. de 2021 às 13:24, Ray West raywest@raywest.com
escreveu:

Hi,

I'm trying to generate a cylinder, with the radius throughout its length
varying as a sine wave. Here is the profile

module profile(){
for(i=[0:7212.5])
translate([i
5,0,0])
square([6,(cos(i*5)31)+31+(20100)]);
}

I need to rotate the section around the x-axis to generate the cylinder.
it appears that rotate_extrude is limited to the z axis, and a 2d
drawing is limited to the x/y plane. Any solutions welcomed. From an
example, it seems that if I could generate a 2d polygon of the profile,
then that can be rotated into the y/z plane, and then it can be rotated,
but programmatically generating the polygon in openscad has me stumped.
I think there must be a better way than stacking a thousand or so 1mm
thick discs.

Best wishes,

Ray


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Is that what you want? rotate_extrude(convexity=10) rotate(90) profile(); Note that 2d objects like squares and circles live in the plane XY. You are allowed to rotate them in an axis other than z or translate them off the XY plane and get a preview image. But that is misleading because render will keep them in the XY plane despite the transforms. The rule of thumb is never transform 2d objects off the XY plane. linear_extrude and rotate_extrude operate on objects in the XY plane. After extrude you may transform the shape as you want. Em seg., 1 de nov. de 2021 às 13:24, Ray West <raywest@raywest.com> escreveu: > Hi, > > I'm trying to generate a cylinder, with the radius throughout its length > varying as a sine wave. Here is the profile > > module profile(){ > for(i=[0:72*12.5]) > translate([i*5,0,0]) > square([6,(cos(i*5)*31)+31+(20*100)]); > } > > I need to rotate the section around the x-axis to generate the cylinder. > it appears that rotate_extrude is limited to the z axis, and a 2d > drawing is limited to the x/y plane. Any solutions welcomed. From an > example, it seems that if I could generate a 2d polygon of the profile, > then that can be rotated into the y/z plane, and then it can be rotated, > but programmatically generating the polygon in openscad has me stumped. > I think there must be a better way than stacking a thousand or so 1mm > thick discs. > > Best wishes, > > Ray > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
MM
Michael Möller
Mon, Nov 1, 2021 1:56 PM

This does not generate thousands of little squares or little disks:

Vector=[for( i = [0:7212.5]) [i5,(cos(i5)31)+31+(20100) ] ] ;  // your
formula
Poly=[for(L=[[[0,200]], Vector, [[72
12.5*5,200]]], a=L) a];  // add the
end points
polygon(Poly);//echo(Poly) ; // verify the flat shape
rotate_extrude() rotate(90) polygon(Poly) ; // and there it is ?

On Mon, 1 Nov 2021 at 14:42, Ronaldo Persiano rcmpersiano@gmail.com wrote:

Is that what you want?

rotate_extrude(convexity=10) rotate(90) profile();

Note that 2d objects like squares and circles live in the plane XY. You
are allowed to rotate them in an axis other than z or translate them off
the XY plane and get a preview image. But that is misleading because render
will keep them in the XY plane despite the transforms. The rule of thumb is
never transform 2d objects off the XY plane. linear_extrude and
rotate_extrude operate on objects in the XY plane. After extrude you may
transform the shape as you want.

Em seg., 1 de nov. de 2021 às 13:24, Ray West raywest@raywest.com
escreveu:

Hi,

I'm trying to generate a cylinder, with the radius throughout its length
varying as a sine wave. Here is the profile

module profile(){
for(i=[0:7212.5])
translate([i
5,0,0])
square([6,(cos(i*5)31)+31+(20100)]);
}

I need to rotate the section around the x-axis to generate the cylinder.
it appears that rotate_extrude is limited to the z axis, and a 2d
drawing is limited to the x/y plane. Any solutions welcomed. From an
example, it seems that if I could generate a 2d polygon of the profile,
then that can be rotated into the y/z plane, and then it can be rotated,
but programmatically generating the polygon in openscad has me stumped.
I think there must be a better way than stacking a thousand or so 1mm
thick discs.

Best wishes,

Ray


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

This does not generate thousands of little squares or little disks: Vector=[for( i = [0:72*12.5]) [i*5,(cos(i*5)*31)+31+(20*100) ] ] ; // your formula Poly=[for(L=[[[0,200]], Vector, [[72*12.5*5,200]]], a=L) a]; // add the end points polygon(Poly);//echo(Poly) ; // verify the flat shape rotate_extrude() rotate(90) polygon(Poly) ; // and there it is ? On Mon, 1 Nov 2021 at 14:42, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > Is that what you want? > > rotate_extrude(convexity=10) rotate(90) profile(); > > > Note that 2d objects like squares and circles live in the plane XY. You > are allowed to rotate them in an axis other than z or translate them off > the XY plane and get a preview image. But that is misleading because render > will keep them in the XY plane despite the transforms. The rule of thumb is > never transform 2d objects off the XY plane. linear_extrude and > rotate_extrude operate on objects in the XY plane. After extrude you may > transform the shape as you want. > > Em seg., 1 de nov. de 2021 às 13:24, Ray West <raywest@raywest.com> > escreveu: > >> Hi, >> >> I'm trying to generate a cylinder, with the radius throughout its length >> varying as a sine wave. Here is the profile >> >> module profile(){ >> for(i=[0:72*12.5]) >> translate([i*5,0,0]) >> square([6,(cos(i*5)*31)+31+(20*100)]); >> } >> >> I need to rotate the section around the x-axis to generate the cylinder. >> it appears that rotate_extrude is limited to the z axis, and a 2d >> drawing is limited to the x/y plane. Any solutions welcomed. From an >> example, it seems that if I could generate a 2d polygon of the profile, >> then that can be rotated into the y/z plane, and then it can be rotated, >> but programmatically generating the polygon in openscad has me stumped. >> I think there must be a better way than stacking a thousand or so 1mm >> thick discs. >> >> Best wishes, >> >> Ray >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RW
Ray West
Mon, Nov 1, 2021 2:29 PM

Yes, exactly. I tried a single rotate rotate_extrude(convexity=10)
rotate ([0,90,0]) profile();  and it gives a <WARNING: Scaling a 2D
object with 0 - removing object>

I didn't realise it would know which axis to rotate with just the single
value, so never tried the two rotates.

Thanks

On 01/11/2021 13:40, dpa wrote:

rotate([0,90,0]) rotate_extrude(convexity=10) rotate (90) profile();

Yes, exactly. I tried a single rotate rotate_extrude(convexity=10) rotate ([0,90,0]) profile();  and it gives a <WARNING: Scaling a 2D object with 0 - removing object> I didn't realise it would know which axis to rotate with just the single value, so never tried the two rotates. Thanks On 01/11/2021 13:40, dpa wrote: > rotate([0,90,0]) rotate_extrude(convexity=10) rotate (90) profile();
D
dpa
Mon, Nov 1, 2021 2:39 PM

Well.. You can also use the "full" vector specification, but you need
to turn the 2D profile() by Z-axis.

rotate_extrude() rotate ([0,0,90]) profile();
which, admittedly, is a bit confusing, but it wokrs

Am Mo., 1. Nov. 2021 um 15:30 Uhr schrieb Ray West raywest@raywest.com:

Yes, exactly. I tried a single rotate  rotate_extrude(convexity=10)
rotate ([0,90,0]) profile();  and it gives a <WARNING: Scaling a 2D
object with 0 - removing object>

I didn't realise it would know which axis to rotate with just the single
value, so never tried the two rotates.

Thanks
On 01/11/2021 13:40, dpa wrote:

rotate([0,90,0]) rotate_extrude(convexity=10) rotate (90) profile();


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Well.. You can also use the "full" vector specification, but you need to turn the 2D profile() by *Z*-axis. rotate_extrude() rotate (*[0,0,90]*) profile(); which, admittedly, is a bit confusing, but it wokrs Am Mo., 1. Nov. 2021 um 15:30 Uhr schrieb Ray West <raywest@raywest.com>: > Yes, exactly. I tried a single rotate rotate_extrude(convexity=10) > rotate ([0,90,0]) profile(); and it gives a <WARNING: Scaling a 2D > object with 0 - removing object> > > I didn't realise it would know which axis to rotate with just the single > value, so never tried the two rotates. > > Thanks > On 01/11/2021 13:40, dpa wrote: > > rotate([0,90,0]) rotate_extrude(convexity=10) rotate (90) profile(); > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Mon, Nov 1, 2021 5:47 PM

On 11/1/2021 6:56 AM, Michael Möller wrote:

This does not generate thousands of little squares or little disks:

Vector=[for( i = [0:7212.5]) [i5,(cos(i5)31)+31+(20100) ] ] ;  //
your formula
Poly=[for(L=[[[0,200]], Vector, [[72
12.5*5,200]]], a=L) a];  // add
the end points
polygon(Poly);//echo(Poly) ; // verify the flat shape
rotate_extrude() rotate(90) polygon(Poly) ; // and there it is ?

I don't see why you offset the base +200 in Y.

The lists can be a bit simpler.

Simplest is probably to build the whole polygon in one shot:

Poly=[
    [ 0, 0 ],
    for( i = [0:72*12.5]) [i*5, (cos(i*5)*31)+31+(20*100) ],
    [ 72*12.5*5, 0 ]
 ] ;  // your formula

but if you want to maintain the pattern of generating the curve
separately, you can use concat:

Poly=concat([[72*12.5*5, 0], [0, 0]], Vector );  // add the end points

or you could use the "each" list comprehension operator:

Poly=[
    [ 0, 0 ],
    each Vector,
    [ 72*12.5*5, 0 ]
 ] ;  // your formula

But the first lesson, that I'm kind of surprised that nobody has
explicitly mentioned, is that when you're planning to do a
rotate_extrude, you need to design your 2D model with the intended
radius in +X and the intended Z in Y.  I guess that you can put the
shape entirely in -X, but I wouldn't.

The sine wave should be drawn as x = f(y) to avoid the need for the
initial rotate.

Poly=[
    [ 0, 0 ],
    for( i = [0:72*12.5]) [ (cos(i*5)*31)+31+(20*100), i*5 ],
    [ 0, 72*12.5*5 ]
 ] ;  // your formula

rotate_extrude() polygon(Poly);

Note that I transposed the coordinates rather than rotating, so the
figure is in +X / +Y.

On 11/1/2021 6:56 AM, Michael Möller wrote: > This does not generate thousands of little squares or little disks: > > Vector=[for( i = [0:72*12.5]) [i*5,(cos(i*5)*31)+31+(20*100) ] ] ;  // > your formula > Poly=[for(L=[[[0,200]], Vector, [[72*12.5*5,200]]], a=L) a];  // add > the end points > polygon(Poly);//echo(Poly) ; // verify the flat shape > rotate_extrude() rotate(90) polygon(Poly) ; // and there it is ? > I don't see why you offset the base +200 in Y. The lists can be a bit simpler. Simplest is probably to build the whole polygon in one shot: Poly=[     [ 0, 0 ],     for( i = [0:72*12.5]) [i*5, (cos(i*5)*31)+31+(20*100) ],     [ 72*12.5*5, 0 ]  ] ;  // your formula but if you want to maintain the pattern of generating the curve separately, you can use concat: Poly=concat([[72*12.5*5, 0], [0, 0]], Vector ); // add the end points or you could use the "each" list comprehension operator: Poly=[ [ 0, 0 ], each Vector, [ 72*12.5*5, 0 ] ] ; // your formula --- But the first lesson, that I'm kind of surprised that nobody has explicitly mentioned, is that when you're planning to do a rotate_extrude, you need to design your 2D model with the intended radius in +X and the intended Z in Y.  I guess that you can put the shape entirely in -X, but I wouldn't. The sine wave should be drawn as x = f(y) to avoid the need for the initial rotate. Poly=[ [ 0, 0 ], for( i = [0:72*12.5]) [ (cos(i*5)*31)+31+(20*100), i*5 ], [ 0, 72*12.5*5 ] ] ; // your formula rotate_extrude() polygon(Poly); Note that I transposed the coordinates rather than rotating, so the figure is in +X / +Y.
RW
Ray West
Mon, Nov 1, 2021 8:34 PM

Thanks. All done and dusted now.  Printing as I type. The offset was to
show the sort of radius I was aiming for. I couldn't find out how to set
it up for programmatically generating the polygon, so thanks for the
explanation.

On 01/11/2021 17:47, Jordan Brown wrote:

On 11/1/2021 6:56 AM, Michael Möller wrote:

This does not generate thousands of little squares or little disks:

Vector=[for( i = [0:7212.5]) [i5,(cos(i5)31)+31+(20100) ] ] ; 
// your formula
Poly=[for(L=[[[0,200]], Vector, [[72
12.5*5,200]]], a=L) a];  // add
the end points
polygon(Poly);//echo(Poly) ; // verify the flat shape
rotate_extrude() rotate(90) polygon(Poly) ; // and there it is ?

I don't see why you offset the base +200 in Y.

The lists can be a bit simpler.

Simplest is probably to build the whole polygon in one shot:

 Poly=[
      [ 0, 0 ],
      for( i = [0:72*12.5]) [i*5, (cos(i*5)*31)+31+(20*100) ],
      [ 72*12.5*5, 0 ]
   ] ;  // your formula

but if you want to maintain the pattern of generating the curve
separately, you can use concat:

 Poly=concat([[72*12.5*5, 0], [0, 0]], Vector );  // add the end points

or you could use the "each" list comprehension operator:

 Poly=[
      [ 0, 0 ],
      each Vector,
      [ 72*12.5*5, 0 ]
   ] ;  // your formula

But the first lesson, that I'm kind of surprised that nobody has
explicitly mentioned, is that when you're planning to do a
rotate_extrude, you need to design your 2D model with the intended
radius in +X and the intended Z in Y.  I guess that you can put the
shape entirely in -X, but I wouldn't.

The sine wave should be drawn as x = f(y) to avoid the need for the
initial rotate.

 Poly=[
      [ 0, 0 ],
      for( i = [0:72*12.5]) [ (cos(i*5)*31)+31+(20*100), i*5 ],
      [ 0, 72*12.5*5 ]
   ] ;  // your formula

 rotate_extrude() polygon(Poly);

Note that I transposed the coordinates rather than rotating, so the
figure is in +X / +Y.


OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

Thanks. All done and dusted now.  Printing as I type. The offset was to show the sort of radius I was aiming for. I couldn't find out how to set it up for programmatically generating the polygon, so thanks for the explanation. On 01/11/2021 17:47, Jordan Brown wrote: > On 11/1/2021 6:56 AM, Michael Möller wrote: >> This does not generate thousands of little squares or little disks: >> >> Vector=[for( i = [0:72*12.5]) [i*5,(cos(i*5)*31)+31+(20*100) ] ] ;  >> // your formula >> Poly=[for(L=[[[0,200]], Vector, [[72*12.5*5,200]]], a=L) a];  // add >> the end points >> polygon(Poly);//echo(Poly) ; // verify the flat shape >> rotate_extrude() rotate(90) polygon(Poly) ; // and there it is ? >> > > I don't see why you offset the base +200 in Y. > > The lists can be a bit simpler. > > Simplest is probably to build the whole polygon in one shot: > > Poly=[ >     [ 0, 0 ], >     for( i = [0:72*12.5]) [i*5, (cos(i*5)*31)+31+(20*100) ], >     [ 72*12.5*5, 0 ] >  ] ;  // your formula > > but if you want to maintain the pattern of generating the curve > separately, you can use concat: > > Poly=concat([[72*12.5*5, 0], [0, 0]], Vector ); // add the end points > > or you could use the "each" list comprehension operator: > > Poly=[ > [ 0, 0 ], > each Vector, > [ 72*12.5*5, 0 ] > ] ; // your formula > > --- > > But the first lesson, that I'm kind of surprised that nobody has > explicitly mentioned, is that when you're planning to do a > rotate_extrude, you need to design your 2D model with the intended > radius in +X and the intended Z in Y.  I guess that you can put the > shape entirely in -X, but I wouldn't. > > The sine wave should be drawn as x = f(y) to avoid the need for the > initial rotate. > > Poly=[ > [ 0, 0 ], > for( i = [0:72*12.5]) [ (cos(i*5)*31)+31+(20*100), i*5 ], > [ 0, 72*12.5*5 ] > ] ; // your formula > > rotate_extrude() polygon(Poly); > > Note that I transposed the coordinates rather than rotating, so the > figure is in +X / +Y. > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org