Search Unity

Question What are teh equivalents of inertiaTensorRotation and inertiaTensor form Physix?

Discussion in 'Physics for ECS' started by Occuros, Mar 23, 2023.

  1. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    On the monobehaviour Physix, on the rigidbody there is the `inertiaTensor` as well as the `
    inertiaTensorRotation`, I tried to recreate the same behaviour I achieve in Physix with unity physics, but I don't really know how these are mapped.

    The closest I could find where `InertiaOrientation` and `InverseInertia`,

    Any advice on what the two above values represent or how to recreate the rigibody equivalent values would be appreciated.
     
  2. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    277
    The inverse inertia tensor is given at a specific orientation in rigid body space that makes it a diagonal 3x3 matrix. We call this space the "motion" space. Therefore we only store the 3 diagonal components of this tensor.
    This inverse inertia tensor and also the inertia tensor itself can be brought into local rigid body space by doing a tensor transformation using the provided inertia tensor orientation R as follows:

    I_body = R * I_motion * R^tr

    where I_motion is a 3x3 diagonal matrix containing the 3 inertia tensor components (called the principal components of inertia) which are simply the three components of the vector 1/inverseInertia, I_body is the local body space inertia tensor matrix and ^tr is the transpose operator, yielding the inverse rotation.

    The same can be done with the inverse inertia tensor if it's required.

    In order to bring the inertia tensor into world space, simply take the world space rotation of the rigid body and post-multiply it with the inertia tensor orientation matrix R, obtaining R_world = R_body * R.
    Then do the same operation as previously but with this new matrix:

    I_world = R_world * I_motion * R_world^tr

    yielding these world space inertia tensor I_world.
    For more information on the math involved, have a look at these course notes.
     
    Occuros likes this.