# Convert atan2 value to standard 360-degree-system value [duplicate]

This question already has an answer here:

Lets say I'm using atan2 to get the angle between two vectors.

atan2 gives a value in radians. I convert it to degrees using a built in function in Java. This gives me a value between 0 and 180 degrees or between 0 and -180 (the nature of atan2).

Is there a way to convert the value received with this function (after it's been converted to degrees), to the standard 360-degree-system, without changing the angle - only the way it's written? It would make it easier for me to work with.

Thanks

## marked as duplicate by Tim Holt, msell, MichaelHouse♦Feb 1 '14 at 7:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• Four atan2 questions in a row; you might want to head to chat or a similar discussion site and figure out what you don't understand about this. – MichaelHouse Feb 1 '14 at 7:12
• Just do this -> angle = (angle + 720) % 360; – wolfdawn Feb 1 '14 at 9:08

## 2 Answers

You can multiply the result by (180/pi) to convert the magnitude to degrees. If it's negative then you would have to add 360 to it afterwards (assuming you want a range of 0 to 360.)

For example, -pi/2 becomes -90 after the multiplication, and adding that to 360 results in 270, which gives you the amount of degrees to rotate counter-clockwise from the positive x-direction to reach the point (which is what you're looking for I think.)

• Thanks. Please see my edit. If I converted the value in radians given by atan2, to degrees, and only then I want to convert that value (in degrees), to the 360-degree-system. What can I do? – user3150201 Feb 1 '14 at 2:08
• As I said in my answer, you want to add 360 to your value if it's negative. Otherwise (i.e. if it's positive) there is nothing further to do. – Ryan Feb 1 '14 at 2:12
• If this doesn't answer your question, can you please clarify with an example of the functionality you're looking for (i.e. input/output) because I'm not sure I understand otherwise. – Ryan Feb 1 '14 at 2:28

You can add 180 to your converted result to give a range of 0 to 360.

• Most likely not what you want, as it changes the origin of angles - 0 degrees would be at the negative x axis instead of the positive x axis. – Nathan Reed Feb 1 '14 at 2:52