Author Topic: Rotation on 2 axis doesn't give expected result  (Read 14636 times)

altair

  • Newbie
  • *
  • Posts: 39
Rotation on 2 axis doesn't give expected result
« on: March 05, 2014, 01:43:26 PM »
Having finally dived into 3D after at least 12 years of 2D work, I find myself foaming at the mouth & pulling my hair  ;D

Presently, my main problem is this;
A vertical cylinder is rotated around the X axis by 20 deg.
Then it is rotated around the Z axis by 30 deg.

When viewed from the side or the front window, one of the angles is not exactly right in one of the windows.

If I take an identical cylinder and rotate it like the preceeding one, but in reverse order, (30deg around Z and then 20 deg around X ),
it is the other angle that is not right.

Is this just a side effect of the isometric display, or is the part really not being rotated as it should?
I thought that the Front, Top and Side windows were displaying a flat view, as in 2D mode.  Maybe I'm wrong .

I can send the drawing if someone wants to look at it.

Thanks

Guy

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Rotation on 2 axis doesn't give expected result
« Reply #1 on: March 05, 2014, 03:59:36 PM »
Guy,

I think you are looking for the resultant line (axis) of two intersecting planes.  In the attached drawing, the red xy plane was rotated about x axis by 20 deg, then the blue yz plane was rotated about the z axis by 30 deg.  The surface intersection of those two planes is the cylinder axis line you are looking for.  Check out the layer names in the attached file.

Hopefully this is what you want.
« Last Edit: March 05, 2014, 04:02:31 PM by prl »

altair

  • Newbie
  • *
  • Posts: 39
Re: Rotation on 2 axis doesn't give expected result
« Reply #2 on: March 05, 2014, 05:20:35 PM »
PLANES !
INTERSECTION OF PLANES !
My god, how could have I been so dumb ?
I was foolishly tilting the cylinder itself instead of creating one that was already at the correct angle.

Thank you so much for this.
I guess I have a lot to learn, and also to un-learn because there, i was still thinking in 2D, heh?

I think now I'm gonna watch a lot of tutorial videos to get the basics right, before making stupid mistakes like that again.
Thanks again, man. You made my day. Well, what's left of it.  ;)

Lar

  • Hero Member
  • *****
  • Posts: 2621
Re: Rotation on 2 axis doesn't give expected result
« Reply #3 on: March 05, 2014, 06:44:39 PM »
Since altair did not post his drawing (and since he is new to 3d) I have no idea what result he actually got but here's something interesting:

When I do what he describes (which has the same result as Prl's drawing, but minus the planes), if you measure the final angle in the XY plane (from the original vertical position)it is 30 degrees. However, if you measure the angle from the 2nd position (after the 1st rotation) to the final position, the angle is 28.152 degrees (well, Prl's drawing says 28.5)... even though the 2 endpoints of the 2 angles line up in the YZ plane (ie, if you look at the 2 arcs from the front 2d view they will start and end at the same XY coordinates)  ...even though, when viewing from the front 2d view the arcs appear to end in the same line. This would lead into thinking they are the same angle, when they are not.

If in 3d you draw 2 arcs to describe these angles and rotate the 28.152 one -20 degrees on the X axis, so it lays starts in the same plane as the 30 degree arc, you will see why this happens: the 2 arcs do not have the same radius  ...arc-2 does not end in the same plane as arc-1, but is actually twisted forward.

Therefor when rotating with the XYZ system you have to keep in mind what plane your rotation angle relates to. If altair wanted his cylinder's 2nd rotation to be 30 degrees in the tilted plane he would have to maybe change the working plane to match the plane of the cylinder (I say maybe because I'm sure there's another way to achieve this**) and then do the 30 degree rotation in the Z axis (and then reset the working plane, of course).

Also, the final result of a series of XYZ rotations differ depending on which axis is rotated first, 2nd and third. To get a consistent result regardless of the order of the rotations you would have to use the HPB system (heading, pitch, bank)... well at least according to Cinema4D. Their manual goes to great length to explain this but it lost me completely (testing their words in both systems prove them right, however). This is important in animation systems so the results are the same every time.

Lar
** now I remember: use 'rotate about a line' (if, like me, you would group a center line with the cylinder) or 'about 2 points' (if, like me, you have sticky handles on and you keep the automatic handles you can snap on handles 0 and 1).
« Last Edit: March 06, 2014, 10:18:22 AM by Lar »

DrollTroll

  • Kindly Curmudgeon
  • Administrator
  • *****
  • Posts: 4191
Re: Rotation on 2 axis doesn't give expected result
« Reply #4 on: March 05, 2014, 07:50:08 PM »
All I will add is "yes, sometimes this 3D stuff is FAR from intuitive".
25 years with DesignCAD

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Rotation on 2 axis doesn't give expected result
« Reply #5 on: March 06, 2014, 12:07:18 AM »
. . . .  (well, Prl's drawing says 28.5)...

See graphic.  The black arrow is the surface intersection of the two planes (and the axis of the cylinder).
« Last Edit: March 06, 2014, 12:20:07 AM by prl »

samdavo

  • Hero Member
  • *****
  • Posts: 2588
  • the trick is knowin...^ > v < - which way's up?
Re: Rotation on 2 axis doesn't give expected result
« Reply #6 on: March 06, 2014, 03:51:42 AM »
All I will add is "yes, sometimes this 3D stuff is FAR from intuitive".
Absolutely DT.
I enclose a dcd and jpeg of what happens when you rotate a vertical line (could be the axle of a cylinder if you wish)
a) -45 degrees about the Z axis, THEN -45 degrees about the X axis; and also
b) -45 degrees about the X axis, THEN -45 degrees about the Z axis

For a), line OA goes to OB, then OC.
for b). line OA goes to OD, then OE.

The final result is that there is no similarity whatsoever between the alignment of OC and OE - in fact there is 16.8 degrees between them.   (or 29mm assuming that OA is 100mm)
cheers

PS If you look at the second jpeg, then with OA = 100, 
then the height of B is 71 ( i.e. 100/ sqrt(2))
then the height of C is 50 ( i.e. 71/ sqrt (2))
 
XC projects as 50 on the XZ plane
ZE likewise
and the distance between C and E is 29  i.e. (71-50)(sqrt2).

In summary, there is no way that the result of rotating about X and then Z ( by -45 and -45,  or by 20 and 30 if you prefer)
gives the same result (FINAL ALIGNMENT) as rotating about Z and then X ( by -45 and -45,  or by 30 and 20).

But I agree it is certainly counter-intuitive.
 
« Last Edit: March 06, 2014, 06:08:50 PM by samdavo »

samdavo

  • Hero Member
  • *****
  • Posts: 2588
  • the trick is knowin...^ > v < - which way's up?
Re: Rotation on 2 axis doesn't give expected result
« Reply #7 on: March 06, 2014, 03:55:46 AM »
Here's the same principle with 20 about x and 30 about z.
Note that there are two directions of the "centreline" - which is the axis of the cylinder that altair was initially talking about. 

altair

  • Newbie
  • *
  • Posts: 39
Re: Rotation on 2 axis doesn't give expected result
« Reply #8 on: March 06, 2014, 04:17:15 AM »
Wow guys, you're really getting into this.
I wonder what the result would be in a different CAD program.
Maybe this doesn't happen only in DC.

Guy

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Rotation on 2 axis doesn't give expected result
« Reply #9 on: March 06, 2014, 04:24:41 AM »
Wow guys, you're really getting into this.

Sure, when the obvious isn't obvious, obviously we need to know why not.

DrollTroll

  • Kindly Curmudgeon
  • Administrator
  • *****
  • Posts: 4191
Re: Rotation on 2 axis doesn't give expected result
« Reply #10 on: March 06, 2014, 08:02:19 AM »
Just for grins, I just worked through it using matrix math (boy was that a pain!). DesignCAD's right. It's not the same to rotate first about X then Z as when you rotate first about Z then X. One of the principles of matrix math which I had blissfully forgotten is that for two matrices A and B, AxB is NOT equal to BxA.

The math is described here: http://en.wikipedia.org/wiki/Rotation_matrix#In_three_dimensions
This description uses right-hand coordinates, so there will be some sign differences from DesignCAD along one or more axes, but the values are the same as I get in DC.
« Last Edit: March 06, 2014, 08:29:50 AM by DrollTroll »
25 years with DesignCAD

Lar

  • Hero Member
  • *****
  • Posts: 2621
Re: Rotation on 2 axis doesn't give expected result
« Reply #11 on: March 06, 2014, 08:34:10 AM »
. . . .  (well, Prl's drawing says 28.5)...

See graphic.  The black arrow is the surface intersection of the two planes (and the axis of the cylinder).
Prl, measure the angle between the end of the 20 degree dimension and the black arrow (set the 1st point at the bottom where the dashed lines intersect so the dimension does not lay in the XY plane). It should not be 30 degrees.

Lar

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Rotation on 2 axis doesn't give expected result
« Reply #12 on: March 06, 2014, 08:54:36 AM »
Prl, measure the angle between the end of the 20 degree dimension and the black arrow (set the 1st point at the bottom where the dashed lines intersect so the dimension does not lay in the XY plane). It should not be 30 degrees.

I'm guessing you are talking about one of the vector angles.  In this graphic, if you switch y and z, are you referring to the gamma angle?


Lar

  • Hero Member
  • *****
  • Posts: 2621
Re: Rotation on 2 axis doesn't give expected result
« Reply #13 on: March 06, 2014, 11:10:10 AM »
See attached image and Prl's original file, modifies by moi...
(I know, I should have posted an image when I first started this fire storm, but that was deep in the a.m., forgive me...)

Lar  ;)
I think this can fit into Prl's 'Impossible Objects' series he is currently wrapped up in, even though this image is not halfway as pretty as his:
http://forum.designcadcommunity.com/index.php?topic=5394.0
http://forum.designcadcommunity.com/index.php?topic=5376.0;topicseen
http://forum.designcadcommunity.com/index.php?topic=5419.0;topicseen
« Last Edit: March 06, 2014, 12:31:02 PM by Lar »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Rotation on 2 axis doesn't give expected result
« Reply #14 on: March 06, 2014, 11:32:14 AM »
See attached image and Prl's original file, modifies by moi...

Beautiful!  Thanks Lar.   Add the Gamma angle to your work image and one would get three angles when viewed from the front 34.31, 30, and 28.481.

Reinforces knowing the difference between a front view (3d) and front elevation (2d).
« Last Edit: March 06, 2014, 12:12:14 PM by prl »