Rotation, HPB & Quaternions
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/04/2007 at 06:00, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.603
Platform: Windows ;
Language(s) : C++ ;---------
There seems to be a problem with the Quaternion::SetMatrix() function.I'm writing a directX exporter and until now I used matrices to animate a model. Due to the limitations (gimbal lock) I switched to Quaternions.
Now here's the problem:
a cube with a rotation of 360° along the Y axis.
Exporting the animation with a 4x4 Matrix -> everything is fine
Exporting the animation with Quaternions -> everything is fine until the rotation is > 180° (pi).
HPB Values higher than pi get a wrong sign in the quaternion which causes rotation to spin back very fastHas anyone experienced something similar?
And are there solutions?Any help is greatly appreciated
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/04/2007 at 04:12, xxxxxxxx wrote:
After 2 days of comparing values and try and error I found the problem.
To build my quaternion I used
rotquat.SetMatrix(LHPBToMatrix(LV(dtRot)));
But (of course) this doesnt work, because the "regular" Matrix brings the gimbal problem back.
The correct way to do this is like this:
Quaternion rotquat, rotquatX, rotquatY, rotquatZ; //rotquat.SetMatrix(LHPBToMatrix(LV(dtRot))); rotquatX.SetAxis(LVector(1, 0, 0), dtRot.y); rotquatY.SetAxis(LVector(0, 1, 0), dtRot.x); rotquatZ.SetAxis(LVector(0, 0, 1), dtRot.z); //ZYX rotquat = QMul(rotquatZ, QMul(rotquatX, rotquatY));