File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Heading/Bearing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Heading/Bearing" Watch "Heading/Bearing" New topic
Author

Heading/Bearing

Robert James Liguori
Author
Ranch Hand

Joined: Nov 27, 2007
Posts: 532
    
    5

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


My Blog (I frequently post on Java, JSF and NetBeans)
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

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, ....


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Heading/Bearing