Inertia matrix representation

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Inertia matrix representation

Post by dpoen »

Hello,

I'm playing with the Shape.MatrixOfInertia, and I've some trouble getting it right.

My main issue is when rotating (by 90°) the object, the matrix change : to be precise, the term m11 and m22 are permuted.

It look like the matrix is given in a origin which is not the part origin, but rather the global or the parent one... But in both way, that seems very strange, and I can't find any way to get the matrix of the part, with respect to is **own** origin.

Any idea ?

I'm adding infos :
Considering this model as PJ (you don't it need to read the following, just as info)

MatrixOfInertia when my part is on the neutral position (translation=0, rotation = 0)
m0 = Matrix ((2.71386e+10,1.04972e-07,1.13596e-07,0),(1.04972e-07,8.52212e+10,-8.72052e-08,0),(1.13596e-07,-8.72052e-08,1.00457e+11,0),(0,0,0,1))
MatrixOfInertia when my part is rotated 90deg around the Z axis
m90 = Matrix ((8.52212e+10,-1.32098e-05,-1.27917e-08,0),(-1.32098e-05,2.71386e+10,1.31195e-07,0),(-1.27917e-08,1.31195e-07,1.00457e+11,0),(0,0,0,1))
Note that the two first diagonals terms are permuted (2.71386e+10 and 8.52212e+10)
If we say that their is some (rotation?) transformation between those two, we should have :
m90 = R * m0
hence, R = m90 * m0.inverse()
R = Matrix ((3.14022,-1.58874e-16,-3.67826e-18,0),(-4.87983e-16,0.318449,1.58242e-18,0),(-4.65711e-18,2.56274e-18,1,0),(0,0,0,1))
but (tr(R)-1)/2 = 1.7293333282009051 (we discard R_44)
and according to https://www.euclideanspace.com/maths/ge ... /index.htm
hence no angle could be computed using acos()...

Note that R.analyse() say that it's a rotation matrix...
Attachments
test_matrix_of_inertia.FCStd
File example
(10.28 KiB) Downloaded 8 times
mac_the_bike
Posts: 42
Joined: Sun Jun 30, 2019 12:56 pm

Re: Inertia matrix representation

Post by mac_the_bike »

You are doing the rotation incorrectly, what you want is:

m90 = R(T) * mo * R

(T) is transposed

R is a 3x3 matrix which contains the direction cosines of the axes systems as rows.

If you set :

Code: Select all

      | 0,  1,  0 |
R  =  |-1,  0,  0 |
      | 0,  0,  1 |
then you get your answer.

Using a Right Handed Coordinate system. In your example, there is a rotation of 90 degrees about the z-axis, in a right handed direction.
If the new rotated axes are called (p,q,r), then we can write:

Code: Select all

|p|     | 0,  1,  0 |  |x|
|q|  =  |-1,  0,  0 |  |y|
|r|     | 0,  0,  1 |  |z|
p is parallel to y and in the same direction.
q is parallel to x but in the opposite direction.
r is parallel to z and in the same direction.

R(T) is the inverse of R, for all angles.
dpoen
Posts: 49
Joined: Wed Feb 02, 2022 10:26 pm

Re: Inertia matrix representation

Post by dpoen »

Dang ! Should have work my maths !

Thanks a lot for the complete explanation, that should indeed solve my troubles !
Post Reply