开发者

Azimuth/Bearing calculation in objective-c

开发者 https://www.devze.com 2023-03-19 14:24 出处:网络
I have been trying this formula to obtain the azimut/bearing of two points of the map. I mean, to obtain the real north di开发者_StackOverflow中文版rection of the vector done with the two coordinates

I have been trying this formula to obtain the azimut/bearing of two points of the map.

I mean, to obtain the real north di开发者_StackOverflow中文版rection of the vector done with the two coordinates.

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

azimut=θ*180/M_PI;

azimuth=(azimuth+360)MOD 360;

I have obtain this formula from this webpage(http://www.yourhomenow.com/house/haversine.html), but i never get the same result.

Is there any other way to obtain the azimut of two points?

Thanks!


You also need to have Δlong, lat1 and lat2 in radians. Therefore you should multiply all of them by M_PI/180 before starting the calculation.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号