[英]Function to generate flight trajectory (list of 3D points, lat, lon, alt)
I am looking to generate some 3D trajectory data for an aircraft simulation. 我期待为飞机模拟生成一些3D轨迹数据。 The idea is that the aircraft takes off at some location
x
and continues to ascend at some average ascent velocity a_v
and angle a_theta
until it reaches a maximum altitude m_a
. 该想法是飞机在某个位置
x
处起飞并且继续以某个平均上升速度a_v
和角度a_theta
上升直到其达到最大高度m_a
。 The aircraft would then continue at its m_a
until it reaches a certain distance d_d
from its destination, at which point it will begin its descent at some angle d_theta
with an average descent velocity of d_v
. 然后飞机将继续其
m_a
直到它从目的地到达某个距离d_d
,此时它将以某个角度d_theta
开始下降,其平均下降速度为d_v
。 Finally, the aircraft lands at destination y
. 最后,飞机降落在目的地
y
。
I would like the function to return a list of 3D points. 我希望该函数返回一个3D点列表。
I am looking to implement this in either Python (preferred) or C#. 我希望在Python(首选)或C#中实现它。
For illustration purposes: 用于说明目的:
Does anyone know how I can achieve this? 有谁知道我怎么能做到这一点? Is there perhaps some open source project which does this?
是否有一些开源项目可以做到这一点? I have been looking for a while now, but have not found anything.
我一直在寻找一段时间,但没有找到任何东西。
I recommend you to solve the problem in 2 independent steps so that the airplane does not pass through the ground : 我建议你通过2个独立的步骤解决问题,这样飞机就不会穿过地面了:
For 1. you can use the spherical interpolation techniques on Quaternions . 对于1.您可以在四元数上使用球面插值技术 。
Quaternion slerp(Quaternion v0, Quaternion v1, double t) {
// Only unit quaternions are valid rotations.
// Normalize to avoid undefined behavior.
v0.normalize();
v1.normalize();
// Compute the cosine of the angle between the two vectors.
double dot = dot_product(v0, v1);
const double DOT_THRESHOLD = 0.9995;
if (fabs(dot) > DOT_THRESHOLD) {
// If the inputs are too close for comfort, linearly interpolate
// and normalize the result.
Quaternion result = v0 + t*(v1 – v0);
result.normalize();
return result;
}
// If the dot product is negative, the quaternions
// have opposite handed-ness and slerp won't take
// the shorter path. Fix by reversing one quaternion.
if (dot < 0.0f) {
v1 = -v1;
dot = -dot;
}
Clamp(dot, -1, 1); // Robustness: Stay within domain of acos()
double theta_0 = acos(dot); // theta_0 = angle between input vectors
double theta = theta_0*t; // theta = angle between v0 and result
Quaternion v2 = v1 – v0*dot;
v2.normalize(); // { v0, v2 } is now an orthonormal basis
return v0*cos(theta) + v2*sin(theta);
}
You didn't write any code, so I won't write any either. 你没有写任何代码,所以我也不会写任何代码。 Python with
math
package is more than enough to solve this problem. 带有
math
包的Python足以解决这个问题。
Required steps: 所需步骤:
a_theta
. a_theta
旋转。 Find the point where it reaches m_a
altitude. m_a
高度的点。 d_theta
. d_theta
旋转。 Find the point where it reaches m_a
altitude. m_a
高度的点。 EarthRadius + m_a
EarthRadius + m_a
For a list of 3D points, you don't need either a_v
, d_v
or d_d
. 对于3D点列表,您不需要
a_v
, d_v
或d_d
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.