## Convert angle range from -180 180 to 0 360?

Sep 11 2012 | 10:19 am
Hi all,
A silly problem which I ran into several times and always worked around but never quite solved. I have an angle in the range of -180 to 180 and want to convert it to a range from 0 to 360... Any pointers?

• Sep 11 2012 | 10:42 am
not sure if i get it - but how about addition? + 180?
:?
• Sep 11 2012 | 10:54 am
scale object
"scale -180 180 0 360"
• Sep 11 2012 | 11:20 am
The number is a rotation, a heading. Say 0 is in 'front', -180/180 is in the 'back'. After the conversion 0/360 should be in 'front', 180 in the 'back'. While both solutions will give a number between 0 and 360, the 'front' will be 180
• Sep 11 2012 | 1:04 pm
try [expr (\$i1+360)%360]
mathieu
• Sep 11 2012 | 5:27 pm
Assuming your input is always in the range [-180 .. 180], you could do [if \$i1 >= 0 then \$i1 else out2 \$i1] and pass the rightmost outlet through a [+ 360] object. Leftmost of the [if] and the [+ 360] outlet both connect to the further processing.
But there are a gazillion other ways to do this. Some are more robust for input values outside the specified range.
• Sep 12 2012 | 1:12 pm
Thanks Mathieu; that works like a charm!