gpt4 book ai didi

c++ - 计算刚体惯性张量世界坐标

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:56:17 25 4
gpt4 key购买 nike

我正在尝试实现小型刚体物理模拟,使用 DirectX 绘制我的对象及其数学库以利用 SIMD 计算(XMMATRIX 和 XMVECTOR 类)。

我的问题是关于惯性张量,我知道使用它的倒数我可以像这样计算角加速度:

AngAcc = Inverse(I) * torque

并且那个惯性张量在局部空间中是恒定的...所以我将它的逆存储在我的 RigidBody 类中和其他一些成员:

//'W' suffix means 'world space'
//'L' suffix means 'local space'
XMFLOAT3 m_positionW; //rigid body position
XMFLOAT4 m_orientationW; //angular orientation
XMFLOAT3 m_velocityW; //linear velocity
XMFLOAT3 m_rotationW; //angular velocity (rotation)

XMFLOAT3X3 m_inverseInertiaTensorL; //inverse of the body inertia tensor in local space (constant)

XMFLOAT4X4 m_worldTransform; //transform matrix for converting body space into world space
XMFLOAT3X3 m_inverseInertiaTensorW; //inverse of the body inertia tensor in world space (change every frame)

现在,在每一帧,我必须计算世界坐标中的反惯性张量...此时我有点困惑...

我该怎么做?

  1. 我必须将 m_inverseInertiaTensorL 乘以 m_worldTransform 吗?如果是如何?第一个是 XMFLOAT3X3 而第二个是 XMFLOAT4X4...
  2. 我必须使用方向?我在某处读到类似这样的内容:“inverseWorldInertiaTensor = rot*inverseBodyInertiaTensor*rot.transpose()”,我认为“rot”是这样的矩阵:

    XMMATRIX 旋转 = XMMatrixRotationQuaternion(orientationW);

我很困惑...有人可以帮助我吗?

最佳答案

我发现将 m_inverseInertiaTensorL 乘以 m_worldTransform 是正确的方法; 只需要 m_worldTransform 的旋转部分,因此您可以将 m_inverseInertiaTensorL 乘以 m_worldTransform 的3x3-sub-matrix

关于c++ - 计算刚体惯性张量世界坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18290798/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com