You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are some angle functions I use. The fmod can be omitted if you don't expect the inputs to be outside the range [0, 360].
// returns rotation in the range [-180, 180] such that from + rotation = to (mod 360)floatrotationBetween(float from, float to) {
float raw = fmod((to - from), 360f);
return raw < -180f
? raw + 360f
: raw > 180f
? raw - 360f
: raw;
}
// more efficient version of fabs(rotationBetween(a, b))// returns absolute difference in the range [0, 180]floatabsAngleDifference(float a, float b) {
float raw = fmod(fabs(a - b), 360f);
return raw > 180f ? 360f - raw : raw;
}
The text was updated successfully, but these errors were encountered:
Here are some angle functions I use. The
fmod
can be omitted if you don't expect the inputs to be outside the range [0, 360].The text was updated successfully, but these errors were encountered: