计算刚体惯性张量世界坐标 [英] Calculating Rigid body Inertia Tensor world coordinates

查看:246
本文介绍了计算刚体惯性张量世界坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to implement a small rigid body physics simulation, using DirectX to draw my objects and its Math library to take advantage of SIMD calculation (XMMATRIX and XMVECTOR classes).

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

My question is about the Inertia Tensor, I know that using its inverse I can calculate the angular acceleration like so:

AngAcc = Inverse(I) * torque

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

and that inertia tensor, in local space, is constant... so I have store its inverse in my RigidBody class with some other members:

//'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)

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

Now, at each frame, I have to calculate the inverse Inertia Tensor in world coordinates... and at this point I'm a little confused...

  1. 我必须将m_inverseInertiaTensorL乘以m_worldTransform吗?如果是,怎么办?第一个是XMFLOAT3X3,第二个是XMFLOAT4X4 ...
  2. 我必须使用方向吗?在某个地方,我读到类似以下内容:"inverseWorldInertiaTensor = rot * inverseBodyInertiaTensor * rot.transpose()",其中"rot"是这样的矩阵:

  1. I have to multiply m_inverseInertiaTensorL by m_worldTransform ? If yes how? the first one is a XMFLOAT3X3 while the second is a XMFLOAT4X4...
  2. I have to use the orientation? Somewhere I read something like: "inverseWorldInertiaTensor = rot*inverseBodyInertiaTensor*rot.transpose()" where I think that 'rot' is a matrix like this:

XMMATRIX旋转= XMMatrixRotationQuaternion(orientationW);

XMMATRIX rotation = XMMatrixRotationQuaternion(orientationW);

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

I'm very confused... someone can help me?

推荐答案

我发现通过m_worldTransform 乘以m_inverseInertiaTensorL 是正确的方法; 仅需要m_worldTransform的旋转部分,因此您可以将m_inverseInertiaTensorL乘以m_worldTransform的 3x3-子矩阵.

I found that multipling m_inverseInertiaTensorL by m_worldTransform is the right way; only the rotation part of m_worldTransform is needed, so you can multiply m_inverseInertiaTensorL by the 3x3-sub-matrix of m_worldTransform.

这篇关于计算刚体惯性张量世界坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆