2

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

I mean, to obtain the real north direction 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!

saimonx
  • 516
  • 1
  • 8
  • 25

1 Answers1

2

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.

Howard
  • 38,639
  • 9
  • 64
  • 83
  • Now i have: 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))); But i haven't got the right result – saimonx Jul 09 '11 at 17:28
  • @saimonx No, I meant `M_PI/180`. The transformation from deg to rad is multiplication by `M_PI/180`, the inverse transformation from rad to deg is multiplication by `180/M_PI`. – Howard Jul 09 '11 at 17:30
  • @saimonx it has been very long time since this questioning time. But can you share your compiled solution pls? I have exact same problem here. Thanks. – emily.mi Aug 12 '20 at 17:05