#### Archived

This topic is now archived and is closed to further replies.

# Angle from Positive X Axis?

This topic is 5468 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Does anyone know how i can get the angle from the positive x-axis if i have the x and y coords? i tried tan-1 but it''s only if for the first 180 then the angle resets to 0. i need it to do the whole 360.

##### Share on other sites
In fact the angle always IS <= 180° as long as you don´t add an orientation to the angle like "it should be counter-clockwise from the first vector to the 2nd vector". If you want that just try case branching.

##### Share on other sites
quote:
If you want that just try case branching.

if ((0 == x) && (y > 0)) {    angle = 90;}else if ((0 == x) && (y < 0)) {    angle = 270;}else {    angle = 57.29577950 * atan(y/x);    if (y < 0) angle += 360;}

Edit: Assuming C. Adapt as necessary.

[edited by - Geoff the Medio on October 6, 2003 6:25:06 PM]

##### Share on other sites
oh man! thanks, sorry that was my studpiest question ever

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 16
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632659
• Total Posts
3007691
• ### Who's Online (See full list)

There are no registered users currently online

×