In bullet, calling getAngularVelocity() on a rigid body node returns the angular velocities about the global x, y, and z axes. Is there a way to get or calculate the angular velocities about the local x, y, z axes of the node.
For example, in a flight simulator, how would you calculate the rate at which the aircraft is yawing, pitching and rolling regardless of its orientation in global space?
I hope I did think careful enough about this one (it late already):
I’d say it is enough to transform the vector returned by getAngularVelocity in whatever coordinate system you want (from global coordinates).
At least this is what the Blender game engine seems to do:
letworyinteractive.com/blend … ource.html (line 01047 ff)
A little bit of explanation:
A body does not rotate around several axis (x/y/z) at the same time, it rotates around one single axis. But this axis might be any direction. The value returned by getAngularVelocity is exactly this vector: direction plus magnitude.
To break it down into rotations around x/y/z you simply project the vector onto this axis. This can be done in any coordinate system.
This does work. Thank you. For anyone interested in the solution:
#get the local coordinate axes of the rigid body (in my case, a spaceship)
mat = rigidBodyNP.getNetTransform().getMat()
shipX = mat.getRow3(0)
shipY = mat.getRow3(1)
shipZ = mat.getRow3(2)
#get the angular velocity (axis magnitude vector)
angularVel = rigidBodyNode.getAngularVelocity()
#project the angular velocity vector onto the local coordinate axes
pitchRate = shipX.x * angularVel.x + shipX.y * angularVel.y +shipX.z * angularVel.z
rollRate = shipY.x * angularVel.x + shipY.y * angularVel.y +shipY.z * angularVel.z
yawRate =shipZ.x * angularVel.x + shipZ.y * angularVel.y +shipZ.z * angularVel.z