0

i'm trying to create a simple navigator, with an arrow that indicate the direction from the location where i'm to the location saved in the map, like a compass with north. i've two location (long and lat), start point and final point. The arrow must rotate from north to the final point direction. I need to calculate this movement i degrees. It's like two side of a triangle, and the movement is the interior angle.

How can calculate this angle, knowing the two distance?

Antonio Viscomi
  • 227
  • 2
  • 5
  • 15

1 Answers1

1

This is just basic trig:

deltaY = P2_y - P1_y
deltaX = P2_x - P1_x
angleInDegrees = atan2(deltaY, deltaX) * (180 / PI)

Via this answer.

Community
  • 1
  • 1
JeffThompson
  • 1,538
  • 3
  • 24
  • 47