# [Audyssey] Arc Tangent vs bearing

```Thomas et al;

It occurred to me, that during our last discussion of 3D mapping etc, that
you'd asked how I was converting my arc tangent result to a bearing with zero
being north and degrees ascending clockwise. Here's how I do it. this is my own
way, and is only for a flat plane which is perfect for games. There are other
formulae out there, but they take into account earth curvature. This is not as
elegant as I'd like, but is less expensive than other formulae. -Perhaps
someone else knows of a better formula?… -Would love to hear!… :)```
```
Anyway, this way is very simple. Hope it helps! :)

Smiles,

Cara :)

// x1, y1 is the user's origin and x2, y2 is the point you're trying to get the
angle to.

// subtract the remote point from your origin
// it's important to do this in this order or the result will be opposite what
you want
// I.E. 270 degrees instead of 90 etc

double vectorX = x2 - x1;
double vectorY = y2 - y1;

// get the angle in degrees between the two points

double angle = (atan2(vectorY, vectorX) * 180 / 3.1415926535);

// get the value in the proper negative range

angle-= 450;

// switch to positive so that degrees will ascend clockwise as with a

angle = angle * -1;

// round off result so modulus will be accurate

angle = round(angle);

// use modulus of 360 to get result in the proper range

angle = (int)angle % 360;

// return the result;

return angle;
---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gamers@audyssey.org.
If you have any questions or concerns regarding the management of the list,