A bit novice question, please excuse me if this is covered some place, did not find it.
I have an oriented bounding box that I am trying to derive a rigid body from. I know its center and its three axis. I followed bullet API/demos but seems to have problems with the initial quaternion orientation. What I do is setup the rotation matrix with the three ortho-normal vectors. Take transpose to get the inverse of rotation. Then call getRotation() to get back the quaternion representing the rotation matrix. However the quaternion is not what i expect. Using the first of the matrix basis vectors, and rotating it by the quaternion, I would expect to end up in (1,0,0) yet, thats not the case. Anything I am doing completely wrong? Thank you!
Here is an example:
Code: Select all
v1.setValue(0.94085854,-0.21149139,0.26468223);
v2.setValue(-0.28753003,-0.085231327,0.95397180);
v3.setValue(0.17919759,0.97365654,0.14100073);
btMatrix3x3 mtx(
v1.getX(),v1.getY(), v1.getZ(),
v2.getX(),v2.getY(), v2.getZ(),
v3.getX(),v3.getY(), v3.getZ());
mtx = mtx.transpose();
btQuaternion rot;
mtx.getRotation(rot);
rot.normalize();
btQuaternion invrot;
invrot = rot.inverse();
btQuaternion point(
v1.getX(),
v1.getY(),
v1.getZ(),
0
);
point = rot*point*invrot; //Result is point = (0.92, -0.13, 0.34)