Advertisement

Locking Quaternion Axes

Started by July 31, 2003 10:20 PM
1 comment, last by Xetrov 21 years, 6 months ago
How does one eliminate rotation in an quaternion axis (or rather lock it into place). For example, eliminating roll [especially due to the unwanted rotation due to errors when rotating verticle and horizontally] yet allowing changes in pitch).
It''s not easy to do that with quaternions. AFAIK, the only way is to convert to Euler angles, remove the roll, and then convert back.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Advertisement
Assuming you use column major matrices, and a right handed coordinate system, if you convert the quat to a matrix, only pitch and yaw rotations would mean that the y component of the first column of the matrix (the side vector) is 0. the you can do

Matrix Mtx(Quat);Vector Side(Mtx.GetColumn(0));Vector Up  (Mtx.GetColumn(1));Vector Dir;Side.y = 0.0f;Dir = (Side.Cross(Up)).UnitVector();Side = Up.Cross(Dir);Mtx.SetColumn(0, Side);Mtx.SetColumn(1, Up);Mtx.SetColumn(2, Dir);


Everything is better with Metal.

This topic is closed to new replies.

Advertisement