如何通过在 Java 中设置 latitude/longitude 点来计算两条相交线之间的角度?
How to compute angle between two intersecting lines by having latitude/longitude points in Java?
我有三个 latitude/longitude 点,P1、P2 和 P3。他们展示了两条相交线 L1 和 L2。
P1 和 P2 分别位于 L1 和 L2。 P3 是直线的交点。
通过欧几里德 space 中的给定信息,很容易计算出线之间的角度。但是,点数采用 latitude/longitude 格式。
那么,如何计算 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 给出不同的结果) 计算差异。
我有三个 latitude/longitude 点,P1、P2 和 P3。他们展示了两条相交线 L1 和 L2。 P1 和 P2 分别位于 L1 和 L2。 P3 是直线的交点。 通过欧几里德 space 中的给定信息,很容易计算出线之间的角度。但是,点数采用 latitude/longitude 格式。 那么,如何计算 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 给出不同的结果) 计算差异。