P
PlayLight
Guest
I've put together the below formula to convert radians to degrees while clamping to 360º in a C project.
similar to how 'direction' is handled in GM:S.
This works perfectly fine, however i'm sure i've seen a method suggested on the old forums which gives the exact same result without using an if statement.
Any Math Magicians who can think of a more efficient method to use?
similar to how 'direction' is handled in GM:S.
Code:
float rad, deg;
rad = 7.34543 // radian input
rad = abs(rad);
if ( rad >= 6.28319 )
{
rad = fmod(rad, 6.28319);
}
deg = rad *(180 /M_PI);
Any Math Magicians who can think of a more efficient method to use?
Last edited by a moderator: