• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Heading/Bearing

 
Robert James Liguori
Author
Ranch Hand
Posts: 551
5
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two coordinates (original and new).

I need to get the bearing/heading from these two coordinates (e.g., NORTH, NORTHEAST, etc).

Can anyone point me in the right direction so I can code this up in Java. I'm using Math.atan2(), but am missing a bunch of logic.

Thanks, Robert
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34851
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How accurate do you need to be? If the answer is it needs to be one of north, south, east, west, northeast, northwest, southeast, southwest - it seems like this could be done without any trig.

If the x is smaller on the first one than the second, you know it is north, northeast or northwest. If the y is smaller, ....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic