Rotation axis bizarre behavior…

Software: Away3D 4.x

Kicker, Member
Posted: 07 May 2015 01:09 PM   Total Posts: 52

Hi,

I had a problem recently with an object I wanted to rotate on Y and Z axis.
Specifically, it was an eyeball, and I wanted this eyeball to follow the mouse cursor.
The pupil was on the X axis, and by default, the eyeball was looking to the left, so I was subtracting 90° to rotationZ to make it look at the user.

Then I would play with rotationZ to make it look more to the right or to the left, and rotationY to make it look more to the top or to the bottom.
Rotating on the X axis had of course no useful effect, since the eye was symmetrical around that axis.
But modifying rotationY didn’t work: Instead of going up and down, the eyeball was rotating around the pupil.

So I thought to myself “Maybe the coordinate system is absolute, and by rotating the eyeball -90° on the Z axis to make it look at the screen, I aligned its pupil to the Y axis, so rotating the eyeball on the X axis instead should solve the problem”.

Except that it didn’t. Instead, and to my surprise, rotating the eyeball to the X axis had the EXACT opposite effect as rotating it to the Y axis: it made the eyeball rotate around its pupil, but in the opposite direction.
It was as if the X and Y axis were aligned somehow, thus breaking the coordinate system.
As if rotating the eyeball on the Z axis had modified the X axis’ vector, but not the Y axis vector…

In a nutshell before setting rotationZ to -90, I had this :
http://i.imgur.com/qmrCjiy.png
And after the rotation, I had this :
http://i.imgur.com/qFeS9Hd.png

It makes absolutely no sense, but it’s the only explanation to what I observed.

To solve the problem, I added my eyeball to a container, and set the container rotationZ to -90 instead.
Then, the eyeball’s rotation Y started behaving as I wanted.

But there’s something fundamentally flawed here.
There must be a bug somewhere.
I’m not a geometry master, but I can’t see any situation in which modifying rotationY and rotationX doing pretty much the same thing could make sense…

   

Avatar
Fabrice Closier, Administrator
Posted: 07 May 2015 01:53 PM   Total Posts: 1265   [ # 1 ]

Keep in mind Away3D is left handed. Also if you have loaded right handed content from 3ds or collada, you may get similar inversion.
And finally, gimbal lock may also be in the game.

   

Kicker, Member
Posted: 07 May 2015 02:30 PM   Total Posts: 52   [ # 2 ]

*Google “gimbal lock”...*

Ok, but isn’t there any way to force the coordinate system to stay orthonormal, not matter what rotation I apply?
Gimbal lock is definitely something I want to avoid…
When I apply a rotation to an object, I expect the coordinate system to stay the same.
I want the object to rotate, not the axes…

   

Avatar
Fabrice Closier, Administrator
Posted: 07 May 2015 03:00 PM   Total Posts: 1265   [ # 3 ]

Well use the math.Quaternion.as class then.

   

Kicker, Member
Posted: 08 May 2015 01:31 PM   Total Posts: 52   [ # 4 ]

Ok, I’ll give it a try.
Thanks for your help.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X