Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Heading/Bearing  RSS feed

 
Robert James Liguori
Author
Ranch Hand
Posts: 587
6
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
Sheriff
Posts: 37222
519
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, ....
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!