【问题标题】:Azimuth/Bearing calculation in objective-cObjective-c中的方位角/方位角计算
【发布时间】:2011-10-01 22:43:33
【问题描述】:

我一直在尝试这个公式来获得地图两点的方位角/方位角。

我的意思是,用两个坐标得到向量的真正北方向。

θ =atan2(sin(Δlong).cos(lat2),cos(lat1).sin(lat2)−sin(lat1).cos(lat2).cos(Δlong))

方位角=θ*180/M_PI;

方位角=(方位角+360)MOD 360;

我已经从这个网页(http://www.yourhomenow.com/house/havesine.html)获得了这个公式,但我从来没有得到相同的结果。

有没有其他方法可以获得两点的方位角?

谢谢!

【问题讨论】:

    标签: objective-c ios xcode bearing azimuth


    【解决方案1】:

    您还需要以弧度表示 Δlonglat1lat2。因此,您应该在开始计算之前将它们全部乘以M_PI/180

    【讨论】:

    • 现在我有:atan2(sin((to.longitude*180/M_PI)-(from.longitude*180/M_PI))*cos(to.latitude*180/M_PI),cos( from.latitude*180/M_PI)*sin(to.latitude*180/M_PI)-sin(from.latitude*180/M_PI)*cos(to.latitude*180/M_PI)*cos((to.longitude*180 /M_PI)-(from.longitude*180/M_PI)));但我没有得到正确的结果
    • @saimonx 不,我的意思是M_PI/180。 deg到rad的变换是乘以M_PI/180,rad到deg的逆变换是乘以180/M_PI
    • @saimonx 距离这个提问时间已经很长时间了。但是你能分享你编译的解决方案吗?我在这里有完全相同的问题。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2012-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多