[英]C# XNA Matrices - find out the current locatin after matrix multiplication
i am making 3D Simulation of Solar System我正在制作 3D 模拟太阳系
for every planet i have an instance of class Celestial Body .对于每个行星,我都有一个 class Celestial Body实例。 I am using the following code for revolution and rotation of sun, planets & their moons.
我正在使用以下代码进行太阳、行星及其卫星的公转和自转。
world = Matrix.CreateTranslation(0,0,0) * Matrix.CreateRotationY(rotation) * Matrix.CreateTranslation(position) * Matrix.CreateRotationY(revolution);
postion = new Vector3(70,0,0)
postion = new Vector3(70,0,0)
Now it works really fine.现在它工作得很好。
But the problem is i need to locate \ get the position of my planet, to where it has been translated after the Matrix multiplication literally in x,y,x co-ordinates.但问题是我需要找到\得到我星球的position,在矩阵乘法之后,它在x,y,x坐标中被翻译到那里。
How To?如何? get the current X, Y, Z coordinates of my planet
获取我星球的当前 X、Y、Z 坐标
the other option for me would be to use some maths formula that calculates a 2D circle for me.对我来说,另一个选择是使用一些数学公式为我计算二维圆。
I think what you're looking for is Matrix.Translation
.我认为您正在寻找的是
Matrix.Translation
。 This gives you the x, y, z co-odinates of the matrix that it's called on in a Vector3
.这为您提供了在
Vector3
中调用的矩阵的 x、y、z 坐标。
So, to get the new position, you should use因此,要获得新的 position,您应该使用
Vector3 newPosition = world.Translation;
after your calculations.在你的计算之后。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.