Hi all,
I have been busy trying to integrate Bullet into my project, and am finally getting somewhere. I definitely needed double precision for my project and can tell you it's now working quite well with collision detection on a full earth globe model terrain using geocentric coordinates.
Now for my question. I need to get the euler angles from a btRigidBody (pitch, roll, yaw) but all I can find is the quaternion orientation. What's the best way to convert this to euler angles? Are there some built-in function I've missed? I do have my own set of classes to deal with quaternions but I could not even find a function to get the 4 elements out of the btQuaternion.. (maybe I'm getting blind).
Cheers,
Ola
Euler angle orientation of a btRigidBody
-
- Posts: 169
- Joined: Sun Jan 14, 2007 7:56 pm
- Location: Norway
-
- Posts: 32
- Joined: Sun Jun 18, 2006 10:22 pm
If it's any help, this is how I get Euler angles to use with Irrlicht:
Code: Select all
void CBulletPhysicsObject::QuaternionToEulerXYZ(const btQuaternion &quat,btVector3 &euler)
{
f32 w=quat.getW(); f32 x=quat.getX(); f32 y=quat.getY(); f32 z=quat.getZ();
double sqw = w*w; double sqx = x*x; double sqy = y*y; double sqz = z*z;
euler.setZ((atan2(2.0 * (x*y + z*w),(sqx - sqy - sqz + sqw))));
euler.setX((atan2(2.0 * (y*z + x*w),(-sqx - sqy + sqz + sqw))));
euler.setY((asin(-2.0 * (x*z - y*w))));
}
-
- Posts: 169
- Joined: Sun Jan 14, 2007 7:56 pm
- Location: Norway