Quaternions/Euler (not the usual question)

Started by
2 comments, last by Prosper/LOADED 21 years, 10 months ago
I''ve recently discovered the evil gimbal lock and a way to avoid it : quaternions. The problem I have is that in order to work properly, quaternions have to be built in an incremental way. If I do : (case A) - convert Euler angles to quaternions - convert convert quaternions to matrix It doesn''t work, so I do this : (case B) - take the last object''s quaternion, - multiply it by the "additionnal rotation" - get the new matrix. This work fine if the object''s rotation is created based on the last one. But now, how can I avoid gimbal lock if the user "set" the three Euler angles. Let''s say the user have some kind of form, fill it with the three new Euler angles to apply to the object. The last object''s quaternion is just useless and I''m stuck with the case A. Does anyone know a solution to this problem ?
Advertisement
You should define a set of coordinate axes for each object. Then allow the user to set Euler angles for rotation about these axes. Then you can convert these Euler angles into a quaternion, which can be done where the order of the angles doesn''t matter. Finally, convert the axis of this quaternion into the space defined by the local coordinate axes of the object and you will have a new quaternion that can be used to rotate the object.
One more thing, when you rotate the object with the new quaternion, also rotate its local axes so you can repeat the whole process with a set of new Euler angles.
quote:Original post by gtdelarosa
Finally, convert the axis of this quaternion into the space defined by the local coordinate axes of the object...


Sorry for being stupid but how must I do this ?

This topic is closed to new replies.

Advertisement