I\'m working on a simple rotate routine which normalizes an objects rotation between 0 and 360 degrees. My C# code seems to be working but I\'m not entirely happy with it. Can a
Add any multiple of 360 degrees between which your possible input values could be (to take it above zero), and just take the remaining with %, like this
angle = 382;
normalized_angle = (angle+3600) %360;
//result = 22
The case above can take input angles down to -3600. You can add any number (multiple of 360) crazily high that would make the input value positive first.
Usually during an animation, your previous frame/step value would probably be already normalized by the previous step, so you'll be good to go by just adding 360:
normalized_angle = (angle+360) %360;