找到给出的X,Y的球的自旋,和Z矢量相对于球矢量、相对于

2023-09-08 01:02:20 作者:Akoasm(幻听)

我在Lua使用电的一些3D模拟,而我的东西数学/算法/物理障碍的运行

I'm using Electro in Lua for some 3D simulations, and I'm running in to something of a mathematical/algorithmic/physics snag.

我试图找出如何我会发现,在旋转上的一些轴球体的球的旋转。通过旋转我的意思是沿着该球体与大小相对速度在它被纺纺丝上的轴的向量。予需要此信息的原因是为了能够通过施加反向扭矩球体,直至其停止纺纱减慢球体的自旋

I'm trying to figure out how I would find the "spin" of a sphere of a sphere that is spinning on some axis. By "spin" I mean a vector along the axis that the sphere is spinning on with a magnitude relative to the speed at which it is spinning. The reason I need this information is to be able to slow down the spin of the sphere by applying reverse torque to the sphere until it stops spinning.

我已经获得的唯一信息是在X,Y和Z单元矢量相对于所述球体。也就是说,每个帧,我可以调用三个不同的函数,其中每个在球体模型的局部X,Y和Z轴的方向上返回一个单元指向矢量,分别。我可以基本保持每个向量的previous值,并将其比作新值每帧跟踪如何这些变化的。现在的问题,那么,我将如何使用这些信息来判断球的旋转?我很为难。

The only information I have access to is the X, Y, and Z unit vectors relative to the sphere. That is, each frame, I can call three different functions, each of which returns a unit vector pointing in the direction of the sphere model's local X, Y and Z axes, respectively. I can keep track of how each of these change by essentially keeping the "previous" value of each vector and comparing it to the "new" value each frame. The question, then, is how would I use this information to determine the sphere's spin? I'm stumped.

任何帮助将是巨大的。谢谢!

Any help would be great. Thanks!

推荐答案

我的第一个答案是错的。这是我编辑的答案。

My first answer was wrong. This is my edited answer.

您单元矢量X,Y,Z可以放在一起,以形成一个3×3矩阵:

Your unit vectors X,Y,Z can be put together to form a 3x3 matrix:

A = [[x1 y1 z1],
     [x2 y2 z2],
     [x3 y3 z3]]

由于X,Y,Z随时间变化的,A也随时间变化。

Since X,Y,Z change with time, A also changes with time.

这是一个旋转矩阵! 毕竟,如果让我=(1,0,0)是沿x轴的单位矢量,然后 A I = X 所以A旋转,我到十,同样,它旋转y轴到Y和 z轴为Z.

A is a rotation matrix! After all, if you let i=(1,0,0) be the unit vector along the x-axis, then A i = X so A rotates i into X. Similarly, it rotates the y-axis into Y and the z-axis into Z.

有一个被称为方向余弦矩阵(DCM)。

A is called the direction cosine matrix (DCM).

因此​​,使用 DCM欧拉轴公式

计算

theta = arccos((A_11 + A_22 + A_33 - 1)/2)

THETA是旋转欧拉角。

theta is the Euler angle of rotation.

角速度的大小,| W |,等于

The magnitude of the angular velocity, |w|, equals

w = d(theta)/dt ~= (theta(t+dt)-theta(t)) / dt

旋转轴线是通过e =(​​E1,E2,E3)给出其中

The axis of rotation is given by e = (e1,e2,e3) where

e1 = (A_32 - A_23)/(2 sin(theta))
e2 = (A_13 - A_31)/(2 sin(theta))
e3 = (A_21 - A_12)/(2 sin(theta))