Simple Angle from X and Y Axes Input

31 Views Asked by At

I am trying, given the position along the $X$ and $Y$ axes from a controller, where the positions range from $-1$ to $1$ ($1$ being up on the Y and right on the X) to convert this to the direction of travel in degrees on a compass.

e.g.
X=1 and Y=-1 = 315 degrees
X=-1 and Y=0 = 180 degrees
X=0 and Y=1 = 90 degrees

Could someone help with the math please?

1

There are 1 best solutions below

0
On BEST ANSWER

I'm assuming this is programming related, in which case the atan2(y,x) function is designed exactly for this (though it probably outputs in radians, so you'd have to multiply by $\frac{180}{\pi}$ to get degrees)