Game Development Community

Local Angular Velocity

by Luigi Rosso · in Technical Issues · 07/16/2004 (5:18 pm) · 10 replies

Hi,

I'm trying to get local angular velocity for the rigid body class in Torque. The rigid body stores angular velocity as 3 floating point numbers (radians per second for each world axis). I'd like to transform it to local (body) coordinates. I've tried inverting the body's quaternion and multiplying the angular velocity to get local angular velocity but my results don't look right. Any suggestions?

#1
07/16/2004 (5:58 pm)
Maybe convert the quaternion to a rotation matrix and then extract the global euler angles. Then transform those global euler angles to the local angles of whatever node you're comparing. Then convert back to a the correct quaternion based on the rotation matrix of the current local node. I guess you multiply the vector (???) by the local rotation matrix to get the local angles or something.

Truth be told I'm not exactly sure yet but that sounds good ;)
#2
07/16/2004 (6:36 pm)
Thanks Jeremy but that won't work, I need to calculate exact orientation angles for the rigid body which means that the I can't simply extract euler angles from a matrix. Sorry for not being clearer in my previous post (which I think may be wrong). I'll try to explain better.

I'm not sure if the angular velocity in the rigid body class is a direction vector (axis for the rotation) and the magnitude is the actual units per second or if it's actual changes in orientation per axis. I think it's the first. What I need to do is integrate local axis angular velocities in order to calculate continuous pitch, roll, and yaw angles. I've attempted to do this by calculating inertial rate quaternion however it's not perfect and since I can't quite understand the entire process I may be easily missing/incorrectly performing a step. You can read about that algorithm here: http://www.resonancepub.com/quaterni.htm, it's at the very bottom of the page.

What would seem most intuitive to me would be calculating changes in orientation angles from the angular velocity (which I'm not sure if it's possible, I think not) and integrating those to euler angles.

The only documented solution I could find is the one I posted (and if anyone can elaborate, please do!).
#3
07/17/2004 (12:19 am)
Please try and explain yourself better.

The angular velocity should be in units per second per axis. That would make the most sense to me anyway.
#4
07/17/2004 (6:49 am)
Ok, sorry if that was hard to understand. This is why I don't think the angular velocity is stored in units per second per axis: I tried integrating the angular velocity (in respect to time) for each rigid body integration of the wheeled vehicle. The pitch, roll, and yaw angles which are the result of such an operation are inconsistant with the actual orientation of the vehicle (I've used those to render a secondary vehicle to check the results). They are not absurd values however, they seem correct as long as I simply move along an x/y axis. This is why I was considering that it's world axis angular velocity and not local body axis angular velocity. I tried inverting the object to world quaternion and multiplying what I think is world axis angular velocity to get the local axis one but that doesn't seem correct either.

There are lots of methods for integrating rigid bodies (I've only heard of the common ones) but I think that a 6 degree of freedom approach stores local angular velocity. Would you happen to know the type of system Torque uses so I can research from there?

Thanks again for the time and I apologize if I was unclear.
#5
07/17/2004 (2:18 pm)
Seems like Torque is using the euler method. The 3 floating point units for the velocity vector define the axis of rotation and the magnitude is the angle/second. Is it possible to break this into components for each axis (degrees/second for each axis)?
#6
01/24/2005 (4:10 pm)
I think I understand that you're wanting to know Luigi. I have only just started working with the Torque SDK, but the rigid body stuff is pretty straight forward form what I can see.

I'm not sure what way you were integrating the angular velocity, but it's possible that you were not getting accurate results as this is actually a result of the angular momentum being transformed by the inverse inertial tensor (or mass moment of intertia if you like) in world space.

The angular velocity is calculated from scratch each frame, not integrated.

I would change the angular velocity into a quaternion, and multiply it by the inverse body rotation. This should give you the change in rotation, relative to the bodys current rotation in radians per second.
#7
01/24/2005 (4:15 pm)
I agree with James.
Convert the 3 floats to a quaternion,
convert the quaternion from world to local,
and then if you must extract the euler angles.

Note - "euler method" typically refers to three rotations
around each of the three axes, not a single rotation
around an arbitrary axis.

Also,
you may want to rethink the need to extract the euler angles.
Using euler angles instead of a quaternion or rotation matrix
generally leads to much more complex and confusing math.
#8
01/24/2005 (8:47 pm)
On a little side note, I think you can get the direction of the angular velocity (very handy in ragdolls when blending with animations) by taking the imaginary parts of the quaternion and multiplying by 2.0f.

Not sure where else you would want to use it though.....
#9
01/24/2005 (9:11 pm)
On a little side note, I think you can get the direction of the angular velocity (very handy in ragdolls when blending with animations) by taking the imaginary parts of the quaternion and multiplying by 2.0f.

Not sure where else you would want to use it though.....
#10
02/23/2005 (5:16 pm)
Luigi,

Are you still having problems with this? I believe the above responses may be in the wrong direction. I did write a fairly detailed response but I checked the "Notify me ..." box before submitting and it blew away my response. If you still needing help, I can retype my response.