如何计算两个角度量度的差?
如何在Java中计算两个角度量度(以度为单位)的差,使结果在[0°,180°]范围内?
例如:
350° to 15° = 25°250° to 190° = 60°
回答:
/*
* Shortest distance (angular) between two angles.
* It will be in range [0, 180].
/
public static int distance(int alpha, int beta) {
int phi = Math.abs(beta - alpha) % 360; // This is either the distance or 360 - distance
int distance = phi > 180 ? 360 - phi : phi;
return distance;
}
以上是 如何计算两个角度量度的差? 的全部内容, 来源链接: utcz.com/qa/433869.html