3

I am trying to find out how to compute the azimuth and elevation angles from a moving air-vehicle simulation to some point on the ground.

I have the vehicle's position vector P, and its orientation quaternion vehQ. I have the target position T, and I have built the difference vector dPT by subtracting P from T.

How do I go about computing the az/el angles to the target? As you can guess, I am not very familiar with 3D math, so some helpful explanation would be wonderful.

Thanks

4

1 回答 1

4

dPT首先,求车辆到目标的相对位置向量:

worldspace target vector dPT = T - P

由于车辆位置P和目标位置T在世界坐标中,因此结果向量dPT也将在世界坐标中表示。因此,您必须使用车辆方向四元数dPT从世界坐标旋转到车辆坐标。执行此操作的正确方法取决于生成四元数的任何内容所使用的约定,但数学可能是以下之一:

vehicle target vector U = vector_part( vehQ * quaternion(0,dPT) * conjugate(vehQ) )
                 or
                      U = vector_part( conjugate(vehQ) * quaternion(0,dPT) * vehQ )

由于您没有提供有关四元数约定的信息,因此我无法知道其中哪一个对您的应用程序是正确的。但是,您的四元数源很可能还提供了使用其四元数旋转矢量的函数或方法。所以,你实际上应该做的是找到这些函数,阅读它们的文档,并在你自己动手之前尝试使用它们。

在车辆坐标中获得目标矢量后,您可以使用标准公式来查找方位角和仰角。这取决于您的坐标约定,但作为示例,如果您的坐标约定是右手的,Z 轴作为“向上”方向:

azimuth = atan2(U.y, U.x)
elevation = atan2(U.z, sqrt(U.x^2 + U.y^2))

这应该计算从 到 的弧度高度和从-PI/2+PI/2的弧度方位角,沿 +x 轴-PI+PI0,逆时针增加(只要高度不是垂直的......)。

于 2013-05-13T23:03:33.080 回答