Symmetrical Rotation

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

Symmetrical Rotation

Factotum
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
Reply | Threaded
Open this post in threaded view
|

Re: Symmetrical Rotation

runsun
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
Reply | Threaded
Open this post in threaded view
|

Re: Symmetrical Rotation

Factotum
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
Reply | Threaded
Open this post in threaded view
|

Re: Symmetrical Rotation

runsun
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
Reply | Threaded
Open this post in threaded view
|

Re: Symmetrical Rotation

Chow Loong Jin
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/2FDdTL8

Perhaps 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
Reply | Threaded
Open this post in threaded view
|

Re: Symmetrical Rotation

wolf
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 . . .
Reply | Threaded
Open this post in threaded view
|

Re: Symmetrical Rotation

runsun
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
Reply | Threaded
Open this post in threaded view
|

Re: Symmetrical Rotation

runsun
In reply to this post by Chow Loong Jin
Chow Loong Jin wrote
It looks of identical length above and below the Z=0 plane to me..
u r right. That was a wrong approach.
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: Symmetrical Rotation

runsun
This post was updated on .
In reply to this post by Factotum
I am not sure the exact 30 degree is the requirement:

    rotate([30,0,0])    //Rotate bar x-axis
    rotate([0,0,30])    //Rotate bar z-axis

If not, make z-rotation to 90 and you will get what you want. Here is the code and an animating object with varying ax from 0 to 60:
length= 400;
width = 35;
thick = 80;
steps = 90;
offs  = 95;
ax = 0;
az = 90;
w =width;
th=thick;
l =length;

module bar(x=w,y=th,z=l,off){
    translate([offs,0,0])
    rotate([ax,0,0])    //Rotate bar x-axis
    rotate([0,0,az])    //Rotate bar z-axis
    cube([x,y,z],center=true);
}

module Obj(){
    for (i=[0:(steps-1)]) {
        rotate([0, 0, i*(360/steps)])
        bar(width, thick, length, offs);
      }
  }      
 
module animateRot3d( t=$t, loc=[0,0,0] ){
    //http://forum.openscad.org/Animating-gif-with-3D-rotation-td14011.html
    tt = 540*t;
    rot = t< 1/3 ? [ tt,0,0 ]
          : t<2/3 ? [ 180, tt-180,0 ]
          : [180,180,tt];
   
    translate(loc)
    rotate(rot)    
    translate( -1*loc) children();
}
   
t=$t;
animateRot3d(t=t)    
Obj();  


The animation was made using runscad.py (see my signature) in command line :
  $ python ../../runscad.py 20151004_sym_rotate.scad 151004_sym_rot.png D="t=%(t)s;ax=sin(180*%(t)s)*60" n=30  
  $ convert -delay 30 -loop 0 ./151004_sym_rot000??.png 151004_sym_rot.gif
 
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets