public static double differenceBetweenAngles ( double alpha , double beta ) { double phi = Math . abs ( beta - alpha ) % 360 ; return phi > 180 ? 360 - phi : phi ; }
Returns the smallest angle between two angles .