作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试实现小型刚体物理模拟,使用 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)
现在,在每一帧,我必须计算世界坐标中的反惯性张量...此时我有点困惑...
我必须使用方向?我在某处读到类似这样的内容:“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/
有谁知道如何旋转 CannonJS(物理库)CANNON.RigidBody?我试图让物体随相机旋转,所以两者都朝向相同的方向。我知道我必须修改四元数,但这不能正常工作: mPlayer.object
我是一名优秀的程序员,十分优秀!