algorithm - 如何计算两个轴承之间的最小旋转

标签 algorithm math geometry geo bearing

给定 0 度到 360 度之间的两个方位角 A 和 B,计算 A 到达 B 所需的最小旋转的最有效方法是什么?旋转可以是顺时针(正)或逆时针(负)。最小旋转应在给出较小绝对度数的方向上。

例如,

minRotation(30,20) 产生 -10。

minRotation(350,20) 产生 30。

我们如何制定函数 minRotation(A,B)?

最佳答案

 D = B - A
 while D < -180   // use "if" operator when angles are normalized to 0..360 range
    D = D + 360
 while D > 180
    D = D - 360

关于algorithm - 如何计算两个轴承之间的最小旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46051396/

相关文章:

c++ - 在容器上的循环中同时访问更多元素的 STL 方法

algorithm - 查找数组中出现偶数次的三个数字

algorithm - 选择 Levenshtein vs Jaro Winkler?

c++ - 在 OpenGL 4.0 中绘制球体

c# - "The namespace ' 控制台 ' already contains a definition for ' 圆圈 '"

python - 快速体素遍历 2D

javascript - 查找数组中的一个或多个数字是否可以加起来等于某个数字

math - 简单的基于物理的运动

java - 为简单的支持 vector 机计算拉格朗日乘数

c++ - OpenGL 中的射线球相交