Convert angle range from -180 180 to 0 360?
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?
not sure if i get it - but how about addition? + 180?
:?
scale object
"scale -180 180 0 360"
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
try [expr ($i1+360)%360]
mathieu
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.
Thanks Mathieu; that works like a charm!
Hi
the solution of mathieu and Peter are working fine, but I get that problem where my 0 position display 180 and 90 position display 270
and I wish to get it in the right side
