Converting non-continuous angle to 360

227 Views Asked by At

I have a computer program which outputs an unusual angle system.

All angles on the left are $0$ (top) to $-180$ degrees (bottom) and all angles on the right are $0$ (top) to $+180$ (bottom)

Is there a straightforward mathematical way to convert this system into $0$ to $360$ angles? For example, $0$ on top and increasing clockwise from there toward $360$ degrees?

1

There are 1 best solutions below

0
On BEST ANSWER

So, your current angle measures look like this:

    -1  1  
 -90     90
  -179 179

To convert the above to

   359  1  
 270     90
   181 179

you can use the formula $$ y = \begin{cases} x,\quad &\text{if } x\ge 0 \\ 360-x \quad & \text{if }x<0\end{cases} $$

Or you could convert to counterclockwise variant

    1  359  
  90     270
   179  181

with $$ y = \begin{cases} 360 - x,\quad &\text{if } x> 0 \\ -x \quad & \text{if }x\le 0\end{cases} $$