Angular distance
Jump to navigation
Jump to search
In general, the smallest angle (angular distance) between two vectors is given by:
(if and are unit/normalized, then this can be simplified further).
Given two angles and , you could substitute and above, or you could use the following code:
// https://gamedev.stackexchange.com/a/4472
// a0 and a1 are in radians (always positive)
float delta_angle(float a0, float a1)
{
return M_PI - fabs(fabs(a1 - a0) - M_PI);
}