Transforming compass direction output

Tags: , ,



I have directional outputs which are both flipped and + – as appose to genuine compass outputs. I want to convert these using math to give me the correct output. I am pretty sure this can be done using trigonometric functions, i would welcome any advice i have drawn a quick sketch excuse the rough jotting.
Left the current situation on the right the desired output

I hope that makes sense. North and south are flipped, if they were flipped back then we would have north to east positive 0-180, north to west negative 0-(-180), however i need it flipped and represented as normal compass headings,

Answer

Going off the image, it looks like simply newAngle = oldAngle+180 (assuming input of -180…180).



Source: stackoverflow