poo*_*kie 6 c# python algorithm flightpath
我期待为飞机模拟生成一些3D轨迹数据.这个想法是飞机在某个位置起飞x并继续以一些平均上升速度a_v和角度上升,a_theta直到达到最大高度m_a.然后飞机将继续飞行,m_a直到距离d_d目的地一定距离,此时它将以某个角度开始下降,d_theta平均下降速度为d_v.最后,飞机降落在目的地y.
我希望该函数返回一个3D点列表.
我希望在Python(首选)或C#中实现它.
用于说明目的:
有谁知道我怎么能做到这一点?是否有一些开源项目可以做到这一点?我一直在寻找一段时间,但没有找到任何东西.
我建议你分两个独立的步骤来解决这个问题,这样飞机就不会穿过地面:
\n\n对于 1.,您可以在四元数上使用球形插值技术。
\n\nQuaternion slerp(Quaternion v0, Quaternion v1, double t) {\n // Only unit quaternions are valid rotations.\n // Normalize to avoid undefined behavior.\n v0.normalize();\n v1.normalize();\n\n // Compute the cosine of the angle between the two vectors.\n double dot = dot_product(v0, v1);\n\n const double DOT_THRESHOLD = 0.9995;\n if (fabs(dot) > DOT_THRESHOLD) {\n // If the inputs are too close for comfort, linearly interpolate\n // and normalize the result.\n\n Quaternion result = v0 + t*(v1 \xe2\x80\x93 v0);\n result.normalize();\n return result;\n }\n\n // If the dot product is negative, the quaternions\n // have opposite handed-ness and slerp won\'t take\n // the shorter path. Fix by reversing one quaternion.\n if (dot < 0.0f) {\n v1 = -v1;\n dot = -dot;\n } \n\n Clamp(dot, -1, 1); // Robustness: Stay within domain of acos()\n double theta_0 = acos(dot); // theta_0 = angle between input vectors\n double theta = theta_0*t; // theta = angle between v0 and result \n\n Quaternion v2 = v1 \xe2\x80\x93 v0*dot;\n v2.normalize(); // { v0, v2 } is now an orthonormal basis\n\n return v0*cos(theta) + v2*sin(theta);\n}\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
393 次 |
| 最近记录: |