Finding the shortest rotation direction

Hello guys,

I want to rotate a mesh towards an angle, but I can’t find a way to know what’s the shortest direction to rotate the mesh.
For example, I have a mesh with a rotation of 290 , and he should rotate towards 10.
How do I know if the mesh should rotate right or left ?
Is there some magic formula that will allow me to do this ?

Thanks !

I solved that in my game… however, i don’t know how i’ve done it anymore and currently have no access to my source.

But this should do:

Subtract the two numbers. If the result is greater than 180, then that’s the long way.

Ahh, thats way better. I will change that in my code aswell,
Why didn’t i think of that… well i already had that left/right function at that time, so using it for this purpose seemed obvious for me…