我有三个纬度/经度点:P1、P2 和 P3。他们展示了两条相交线 L1 和 L2。 P1 和 P2 分别位于 L1 和 L2。 P3 是线的交点。 通过欧几里得空间中的给定信息,很容易计算线之间的角度。但是,点采用纬度/经度格式。 那么,如何用Java计算线之间的角度呢? 谢谢
最佳答案
您想要获得两个轴承之间的角度。
地球方位可以使用 latlong page 中的公式计算
Formula: θ = atan2( sin Δλ ⋅ cos φ2 , cos φ1 ⋅ sin φ2 − sin φ1 ⋅ cos φ2 ⋅ cos Δλ )
where φ1,λ1 is the start point, φ2,λ2 the end point (Δλ is the difference in longitude)
JavaScript: (all angles in radians)
var y = Math.sin(λ2-λ1) * Math.cos(φ2);
var x = Math.cos(φ1)*Math.sin(φ2) - Math.sin(φ1)*Math.cos(φ2)*Math.cos(λ2-λ1);
var brng = Math.atan2(y, x).toDegrees();
找到从P3到P1和从P3到P2的方位后(请注意,顺序很重要 - P3P1和P1P3给出不同的结果)计算差异。
关于java - 如何通过Java中的纬度/经度点计算两条相交线之间的角度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52416352/