# Symmetrical Rotation

9 messages
Open this post in threaded view
|

## Symmetrical Rotation

 Hi everyone. I've been an OpenSCAD user for some time - it's awesome. I recently upgraded from 2014.x to the latest 2015.x and the new changes are fantastic! I'm doing a bit of design project at the moment - what I want : a rectangular 'bar' rotated about the z-axis and the x-axis (an interesting twist) and then iterated (circularly) around the z-axis. Code : length = 400; width = 35; thick = 80; steps = 90; offs = 95; module bar(x,y,z,off){     translate([off,0,0])     rotate([30,0,0])    //Rotate bar x-axis     rotate([0,0,30])    //Rotate bar z-axis     cube([x,y,z],center=true); } for (i=[0:(steps-1)]) {     rotate([0, 0, i*(360/steps)])     bar(width, thick, length, offs);   } I'm expecting it to be a mirror image through the XY plane (but it's not). Can anyone see what fatal assumption I've made? The "steps" variable is set high to make it easier to see the imbalance.. Addendum - Marius recommended the following trick to further help with visualising the problem : .. try this: rotate([0,0,\$t*180-90]) //Rotate bar z-axis .. then go to View->Animate. set FPS to 30 or so and Steps to 100. That should give you some way of playing with this. _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Symmetrical Rotation

 Not sure if this is what you want: Factotum wrote       length = 400;         width = 35;         thick = 80;         steps = 90;         offs = 95;                   module bar(x,y,z,off){             translate([off,0,0])             rotate([30,0,0])    //Rotate bar x-axis             //rotate([0,0,30])    //Rotate bar z-axis  <====== take this out             cube([x,y,z],center=true);         }                   for (i=[0:(steps-1)]) {             rotate([0, 0, i*(360/steps)])             bar(width, thick, length, offs);           } \$ Runsun Pan, PhD \$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); \$ Tips; \$ Snippets
Open this post in threaded view
|

## Re: Symmetrical Rotation

 That leaves me with no rotation of the 'bar' around its z-axis which is a required part of the design... I realised my description isn't quite correct either - I said 'mirrored about the XY plane' - what I actually mean is the final object should be of identical length / rotation above / below the XY plane (I'm sure there is a better way of saying this)...   On 5/10/2015 12:19 PM, runsun wrote: ```Not sure if this is what you want:     //rotate([0,0,30])    //Rotate bar z-axis <====== take this ``` --   _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Symmetrical Rotation

 In reply to this post by Factotum Then, try this: 1) Take out the translate([off,0,0]). This will make it symmetric off XY plane 2)  Add a new translate( [offx, offy,0] ) as shown below. This will simply push the bar away from the center. The idea is to delay the translation until the final rotation is made. The offx, offy are to be calculated using cos and sin, which shouldn't be hard. Factotum wrote             length = 400;         width = 35;         thick = 80;         steps = 90;         offs = 95;                   module bar(x,y,z,off){             //translate([off,0,0])   <============== take this out             rotate([30,0,0])    //Rotate bar x-axis             rotate([0,0,30])    //Rotate bar z-axis             cube([x,y,z],center=true);         }                   for (i=[0:(steps-1)]) {             translate( [offx,offy,0] )   // <========= add this             rotate([0, 0, i*(360/steps)])             bar(width, thick, length, offs);           }   \$ Runsun Pan, PhD \$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); \$ Tips; \$ Snippets
Open this post in threaded view
|

## Re: Symmetrical Rotation

 In reply to this post by Factotum On Mon, Oct 05, 2015 at 12:28:26PM +0800, Factotum Industries wrote: > That leaves me with no rotation of the 'bar' around its z-axis which is a > required part of the design... > > I realised my description isn't quite correct either - I said 'mirrored about > the XY plane' - what I actually mean is the final object should be of identical > length / rotation above / below the XY plane (I'm sure there is a better way of > saying this)... It looks of identical length above and below the Z=0 plane to me.. http://imgur.com/2FDdTL8Perhaps you should draw it out on paper? -- Kind regards, Loong Jin _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org signature.asc (836 bytes) Download Attachment
Open this post in threaded view
|

## Re: Symmetrical Rotation

 In reply to this post by runsun Your thinking is wrong, meaning your visualisation of what should have happened is not quite what you have actually done. Use the % operator in front of the bar(...) statement inside the for loop, to make your bars transparent. Then use your mouse to rotate your shape, and you'll see . . . for (i=[0:(steps-1)]) {     rotate([0, 0, i*(360/steps)])  %   bar(width, thick, length, offs); Because your bar is not rotation symmetric, your shape isn't either. Replace cube([x,y,z],center=true); with cylinder(d=x,h=z,center=true); and get the hyperboloid you're after . . .
Open this post in threaded view
|

## Re: Symmetrical Rotation

 wolf wrote Because your bar is not rotation symmetric, your shape isn't either. Replace cube([x,y,z],center=true); with cylinder(d=x,h=z,center=true); and get the hyperboloid you're after . . . The shape looks nice. But it is specifically mentioned that "rotation of the 'bar' around its z-axis is a required part of the design", which this answer failed to fulfill. \$ Runsun Pan, PhD \$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); \$ Tips; \$ Snippets