开发者

Determining required vectors

I have an object that is aligned with the direction that I want the forces acting on its body's axis to move it in the direction of my camera's +z axis . Since the body is aligned where its local axis are all aligned with the camera's axis, just adding a force to the body's +z axis, it moves in the direction that I want.

If I rotate the body, its axis are no longer alig开发者_运维知识库ned with the camera. But I still want the body to move forward in the camera's +z direction. How do I determine how to calculate the forces to the body's local rotated axis (X,Y,Z) to make it move in the camera's +z direction?

So I have a body that is rotated (30,135,-36) on the X,Y, and Z axis respectively. And I want to calculate the forces on each axis needed to move the body in the camera's +z direction. The coordinate system is left hand: X is right, Y is Up, Z is forward.

Any help or insight is greatly appreciated.


If your transformation are being performed with a matrix (which is most likely the case), then you can take the inverse of the matrix which results from the rotations, and then multiply the force vector by the inverse. Since the force vector is aligned with the z-axis, it should have the form (0,0,z) before the multiplication.

Alternatively, if you don't use matrices, then this should work as well:

Start with the force vector (0,0,z), you can then apply the negative of each rotation in reverse order. If I understand your question correctly, you rotated by +30 degrees around the X, then +135 degrees around Y, and finally -36 degrees around the Z. So to calculate the necessary force vector, start with the vector (0,0,z), rotate it by +36 degree around the Z axis, then -135 degrees around the Y, and lastly -30 degrees about X. This should give you the force vector relative to the object's local coordinate system.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜