# Updating 3d orientation with matrices

This topic is 4357 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm trying to program 3D rotational physics, using matrices. Right now I'm just considering the case of an object spinning at the origin without applied forces. I don't have much experience with this, so please correct me if I get anything wrong. It is my understanding that 3D physics objects have moments of inertia (represented by a 3x3 matrix) and angular momentums (represented by a 3D vector). The moment of inertia of a rigid body is constant, but it is represented in local coordinates so the moment of inertia is world coordinates can change with time. The angular momentum is constant in world coordinates. Say M is the angular momentum vector (in world coordinates), I is the moment of inertia matrix (in local coordinates) and R is the object's current orientation (the matrix that transforms local coordinates to world coordinates). I want to find the angular velocity vector w in world coordinates. I have the equation M = Iw but this isn't quite accurate since I is in local coordinates. To fix it I write M = RIw. w = (I^-1)(R^-1)M. As an alternative method of finding m, I could first convert M to local coordinates, solve for w in local coordinates, and convert to world coordinates. Writing wl for w in local coordinates, this looks like (R^-1)M = Iwl. wl = (I^-1)(R^-1)M. w = Rwl = R(I^-1)(R^-1)M. Unfortunately, these two methods give different results... so where is my error? What is the correct formula for w? Furthermore, after I find w, what do I do with it to update R? Say I have the rotation matrix R and the angular velocity vector w at a given moment, how do I calculate the new rotation matrix after some small delta t? I don't need any super accurate integration method, just something computationally cheap that won't quickly require reorthogonalizing the rotation matrix.

##### Share on other sites
I believe you have the correct solution here:
w = R(I^-1)(R^-1)M
As for your other solution, let's look at the initial equation:
M = RIw
The error has to do with the coordinate spaces involved. The inertia tensor does not represent a change of coordinate systems, so 'RIw' has the effect of transforming w from the local space of the rigid body to world space. However, this is incorrect, since w is represented in world space already.
Quote:
 Say I have the rotation matrix R and the angular velocity vector w at a given moment, how do I calculate the new rotation matrix after some small delta t? I don't need any super accurate integration method, just something computationally cheap that won't quickly require reorthogonalizing the rotation matrix.
One method of updating R is via a skew-symmetric matrix constructed from w. The product of this matrix and R has as its basis vectors the instantaneous velocity of each basis vector of R (this is because multiplying by the skew matrix has the effect of taking the cross product of w and each basis vector in R). In pseudocode:
matrix3x3 Rdot = SkewMatrix(w) * R;R += dt * Rdot; // Or the integration method of your choiceR.Orthogonalize();
Note that I'm not a physics expert, so none of the above should be considered authoritative.

##### Share on other sites
One thing about the inertia tensor - since you only need the inverse of it anyway it's faster to just store the inverse inertia tensor in local space, then to get the inverse inertia tensor in world space you do a similarity tranform:
Iw^-1 = A * Il^-1 * A^T were Iw^-1 and Il^-1 are the world and local inverse inertia tensors, A is the orientation and A^T is the transpose of the orientation. then you get the angular velocity with
W = Iw^-1*Lw

you can find more on this here:
http://www.d6.com/users/checker/pdfs/gdmphys4.pdf

1. 1
2. 2
3. 3
4. 4
Rutin
14
5. 5

• 12
• 12
• 9
• 14
• 10
• ### Forum Statistics

• Total Topics
632655
• Total Posts
3007670
• ### Who's Online (See full list)

There are no registered users currently online

×