Rotation matrix and quaternion

mikon
Posts: 6
Joined: Tue Sep 18, 2007 3:15 pm
Location: Germany

Rotation matrix and quaternion

Post by mikon »

Hi all,
I have some problem with representation of quaternion. I do following:

Code: Select all

float yaw, pitch, roll;
yaw = 1.5f; pitch = 1.f; roll = 0.5f;
btQuaternion orn;
orn.setEuler(yaw, pitch, roll);
But the real rotation of the object doesn’t correspond to the wishful values. I mean that the object rotates around axis Z for 0.5 rad (roll), around Y – 1.5 rad (yaw) and around X – 1.0 rad (pitch)… For me it’s pleasant to use such relation: yaw-pitch-roll = z-y-x… May be I do something wrong?

Second problem:
The function getBasis() returned the product of matrixes RyRxRz, where Rx, Ry, Rz – rotation matrixes around axis X, Y, Z correspondently. If is it possible to get the RxRyRz or RzRyRx product?

Thx/Brgds
Mikhail Konev
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Rotation matrix and quaternion

Post by Erwin Coumans »

I think your problem is more about Euler angles ordering rather then about rotation matrices or quaternion.

The Bullet matrix class also has a 'setEulerZYX'. There is also a MatrixToEulerXYZ implemented in bullet\src\BulletDynamics\ConstraintSolver\btGeneric6DofConstraint.cpp. If there are more requests, we can add various versions (with different ordering) in the btMatrix3x3 class.

You can get other orderings from http://www.geometrictools.com/LibFounda ... 3.inl.html

Hope this helps,
Erwin
mikon
Posts: 6
Joined: Tue Sep 18, 2007 3:15 pm
Location: Germany

Re: Rotation matrix and quaternion

Post by mikon »

Erwin Coumans wrote:I think your problem is more about Euler angles...

The Bullet matrix class also has a 'setEulerZYX'...
You have right, that my problem is in representation of Euler angles. Yesterday evening I had implemented rotation movement without Euler angles, using Basis matrix.
In any case, thx a lot.

p.s. May be it'll be better to add setEulerZYX and setEulerYPR to the btQuaternion ;)

Thx/Brgds
Mikhail Konev