此示例和java脚本代码来自链接文本
查看有关rhumb行的部分.
给定起始点和沿恒定方位θ的距离d,这将计算目标点.如果沿着垂直线保持恒定的方向,则会逐渐向一个极点旋转.
公式:
? = d/R (angular distance)
lat2 = lat1 + ?.cos(?)
?? = ln(tan(lat2/2+?/4)/tan(lat1/2+?/4)) [= the ‘stretched’ latitude difference]
if E:W line q = cos(lat1)
otherwise q = ?lat/??
?lon = ?.sin(?)/q
lon2 = (lon1+?lon+?) % 2.? ? ?
where ln is natural log and % is modulo, ?lon is taking shortest route (<180°), and R is the earth’s radius
Run Code Online (Sandbox Code Playgroud)
JavaScript:
lat2 = lat1 + d*Math.cos(brng);
var dPhi = Math.log(Math.tan(lat2/2+Math.PI/4)/Math.tan(lat1/2+Math.PI/4));
var q = (!isNaN(dLat/dPhi)) …
Run Code Online (Sandbox Code Playgroud)