I know a way to find the angle difference of two angles between [0,180], but I'm trying to find out a way to find the angle difference of two angles between [-179,180].
My code is as follows; it doesn't work properly:
private int distance2(int alpha, int beta) {
int phi = beta - alpha;// % 360; // This is either the distance or 360 - distance
int distance = 0;
if (phi < -360) {
distance = 360 + phi;
} // end of if
else{
distance = phi;
}
return distance;
}