Animation Rotation Complication
Hi. I've been coding a simple animation system for OpenGL. It works by taking the rotation, translation, etc. for each key frame and interpolating (is that the right word) them over a set delay. I have absolutely no problems with translation and scaling, they work as expected.
My difficulty lies in rotation. If I tell it to rotate from 0 to 90 degrees, it will do this correctly. The same is true for any other numbers less than 360. The problem is, I would like it to realise that 0 and 360 are the same angle, and as such no movement is needed to change between the two. At current there is no way to do a full rotation, sending it from 360 to 0 will just make it quickly flip all the way back round.
Does anyone have any suggestions for a way to make this work? Any help would be appreciated.
My difficulty lies in rotation. If I tell it to rotate from 0 to 90 degrees, it will do this correctly. The same is true for any other numbers less than 360. The problem is, I would like it to realise that 0 and 360 are the same angle, and as such no movement is needed to change between the two. At current there is no way to do a full rotation, sending it from 360 to 0 will just make it quickly flip all the way back round.
Does anyone have any suggestions for a way to make this work? Any help would be appreciated.
Just make sure that it never goes 360 degrees.
if (angle >= 360) angle -= 360;
if (angle >= 360) angle -= 360;
Hey - thanks. I'd thought about doing something like that for ages, but I've only just realised where to put that code. It all works beautifully now.
If your angle is an integer then you can also do:
[SOURCECODE]angle %= 360;[/SOURCECODE]
This will make sure 0 <= angle < 360.
[SOURCECODE]angle %= 360;[/SOURCECODE]
This will make sure 0 <= angle < 360.
Woah, that's neat. I need to learn these little C tricks.

