local/global 3D transformation trubles

LukeNeo's picture

Hi, I'm currently working with local transformations in QC, and I'm having a bit of truble with 3D tranformation patch. My guess is that objects inside 3D tranformations don't rotate always using local coordinate system.

Look at the attached composition: If I use 45 as Y rotation, the cube is correctly rotated around the Y axis (fig. X0_Y45_Z0.jpg). From this configuration, if I add a Z rotation of 45, the cube is correctly rotated around the LOCAL Z axis (the blue one, fig. X0_Y45_Z45.jpg).. ..but if instead of adding a Z rotation I add X rotation of 45, the cube is rotated around te GLOBAL X axis, not arounde the local one (witch is the red one, fig. X45_Y45_Z0.jpg).

..am I doing something wrong or it is a QC bug?

PreviewAttachmentSize
X0_Y45_Z0.png
X0_Y45_Z0.png9.07 KB
X0_Y45_Z45.png
X0_Y45_Z45.png16.07 KB
X45_Y45_Z0.png
X45_Y45_Z0.png15.47 KB
local_rot_0.qtz113.67 KB

usefuldesign.au's picture
Re: local/global 3D transformation trubles

I never notice this before. I want an explanation too!

I put inside a trackball and rotated the global context and same thing.

PreviewAttachmentSize
local_rot_1.qtz113.35 KB

toneburst's picture
Re: local/global 3D transformation trubles

I think the translation matrix is applied before the rotation one, so if you translate and then rotate, you end up rotating around the original origin, rather than a translated origin. It would be good if the 3D Transform patch allowed you to specify the order of transformations, but as far as I know, it doesn't, currently.

a|x

toneburst's picture
Re: local/global 3D transformation trubles

Oh, sorry- that doesn't answer your question at all. Still applies though.. ;)

a\x

vade's picture
Re: local/global 3D transformation trubles

I believe the 3D transform patch is rotating relative to macro patch it is sitting in's coordinate system.

I believe figure 2 is actually wrong compare with what you are saying. Its rotating relative to Z in the world coordinate system, which would be Z "into" the image, not the blue line.

So its consistent, in world, not local rotations.

LukeNeo's picture
Re: local/global 3D transformation trubles

Hi vade, the figs I attached reflect correctly their file name rotation, you can try it using my attached composition. Look at these two new pics, here is even more clear that when we use Z rotation the cube is rotated using its local coords while other rotation axes use global coords:

X0_Y90_Z45.png - if I rotate the cube by 90 on Y axis the cube shows the face number 2. If I add a 45 Z rotation, the cube rotates around HIS OWN Z axis (the blue one). X45_Y90_Z0.png - if I rotate the cube by 90 on Y axis the cube shows the face number 2. If I add a 45 X rotation, the cube rotates around WORLD X axis, resulting in the same final position of the previous example.

I think it is really a bug.. isn't it?

PreviewAttachmentSize
X0_Y90_Z45.png
X0_Y90_Z45.png11.18 KB
X45_Y90_Z0.png
X45_Y90_Z0.png11.4 KB

LukeNeo's picture
Re: local/global 3D transformation trubles

..no, it isn't. :) Like a|x said, there is an axes order in the tranformations applied: first X rotation, Y rotation, and then Z rotation. Also, there are NO local tranformations involved: the 3D tranformation rotate/translate/scale the ENTIRE world system coords (which axes are drawn in rgb in my composition). If we think about this, my last two examples are correctly displaying the same result:

X0_Y90_Z45.png - We rotate the cube FIRST on Y by 90, THEN on Z by 45. X45_Y90_Z0.png - We rotate the cube FIRST on X by 45, THEN on Y by 90.

So it is not a bug, but.. like a|x said: "It would be good if the 3D Transform patch allowed you to specify the order of transformations"! :)

To explain better that 3D tranformation apply its transformations on world system coords look at the attachment: there are 2 cubes inside a 3D transformation now, and I applied a X rotation of 45: the entire world rotates around the red axis.

PreviewAttachmentSize
X45_Y0_Z0.png
X45_Y0_Z0.png29.9 KB

apastorello's picture
Re: local/global 3D transformation trubles

As LukeNeo said rotations are implemented in a precise order. Before rotation x, then y and z. In fact the first example works because z rotation is applied to the object 3d after y rotation. As is done intuitively in 3D softwares, rotating y by 45 first, then x by 45, the final position of the 3d object is different than inverting the order we apply rotations. It can't be done in Quartz because it would mean having two cubes with the same rotations and different final positions.

Let's write a formula to translate local rotation movements in global ones!!!

PreviewAttachmentSize
Quartz3dTrubles.jpg
Quartz3dTrubles.jpg140.6 KB