我正在尝试实现一个小的刚体物理仿真,使用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)
现在,在每一帧上,我必须计算世界坐标的反惯性张量...在这一点上,我有点困惑...
我怎样才能做到这一点?
XMMATRIX旋转= XMMatrixRotationQuaternion(orientationW);
我很困惑...有人可以帮助我吗?
最佳答案
我发现通过m_worldTransform 乘以m_inverseInertiaTensorL是正确的方法。 只需要m_worldTransform 的旋转部分,因此您可以将m_inverseInertiaTensorL乘以m_worldTransform的 3x3子矩阵。
关于c++ - 计算刚体惯性张量世界坐标,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18290798/