[英]Function to get X, Y position of an object orbiting a point, given a distance and angle in radians?
I am trying to code a function for a camera that orbits a point. 我正在尝试为绕点旋转的相机编写函数。 Assume a 3d coordinate plane where Z is up. 假设Z向上的3d坐标平面。 Ignore Z. 忽略Z。
Let's say the camera's position starts at (0, 0, z). 假设相机的位置从(0,0,z)开始。 The object to orbit is at, say (50, 50, z). 进入轨道的物体位于(50,50,z)。 So we have a distance of ~70 units. 因此,我们的距离约为70个单位。 Calling the function with {(50, 50, z), 70, x} where x is the position in orbit, in radians, should return where the position of the camera should be. 用{(50,50,z),70,x}调用该函数,其中x是弧度的轨道位置,应该返回照相机的位置。
I believe this involves cos
and tan
but my trig isn't that great... 我相信这涉及cos
和tan
但是我的触发不是那么好...
point3d getCameraPosition(point3d objectPosition, float distance, float rotationRadians)
{
// ???
}
return position + Point(distance*cos(angle), distance*sin(angle))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.