# Coordinate system conversion... without a system of equations

I'm trying to come up with a good conversion formula to go from one definition of angles in a circle to another.

In the origin system, zero is up, 90 is right, 180 is down, 270 is left.

In the target system, zero is right, -90 is down, +/- 180 is left, 90 is up.

Going backwards is easy: y=(-x+90)%360. Can anyone figure out how to go forwards in a single equation?

• The exact same equation should work Jul 22, 2017 at 4:17
• @Mohit Nope, it won't. It won't ever result in a negative number, thanks to the mod. Jul 22, 2017 at 4:26
• y = -x + 90 should work without the mod 360 Jul 22, 2017 at 15:19
• @Mohit It works for the first three quadrants, but for origin angles > 270, 90-x results in numbers smaller than -180. Jul 23, 2017 at 1:35
• Oh, sorry you are right. I only tried 0,90,180,270. Jul 23, 2017 at 3:50

In the origin system, zero is up, 90 is right, 180 is down, 270 is left.

Let $\,\alpha \in [0, 360)\,$ be this angle.

In the target system, zero is right, -90 is down, +/- 180 is left, 90 is up.

Let $\,\beta\,$ be this angle, but the +/- 180 part makes it ambiguous whether you mean the target angle to be $\beta \in (-270,90]$ vs. $\beta \in (-180,180]\,$:

• if you mean $\,\beta \in (-270,90]\,$, then just use $\,\beta = 90 - \alpha\,$;

• if you mean $\,\beta \in (-180,180]\,$, then use $\,\beta = 180 - (\alpha + 90) \;\%\; 360\,$.

• That's the conclusion I came to. I'm hoping there's a single equation solution, though. Jul 23, 2017 at 1:36
• @BenEtherington It is a single equation solution, once you clarify which one of the two you want the target range of $\beta$ to be. For example, if you want $\beta$ to be in $(-180,180]$ then the only equation you need to use is the one listed under the second case: $\,\beta = 180 - (\alpha + 90) \;\%\; 360\,$.
– dxiv
Jul 23, 2017 at 1:38
• Oh, sorry, I read too quickly. I see what you mean, yes, you nailed it! Thank you! Jul 23, 2017 at 1:45