I need to calculate angle between three geolocations where two of them are always the same, and only one of them is changing(for example when user is walking).
First point is the starting position of user. Second point is the current position of user, so at the beginning first point equals second point. First point and fixed point are always same. I have latitude and longitude for each point.
I tried to use this formula:
double angle1 = Math.atan2(startingLocation.getLongitude() - destinationLocation.getLongitude(), startingLocation.getLatitude() - destinationLocation.getLatitude());
double angle2 = Math.atan2(currentLocation.getLongitude() - destinationLocation.getLongitude(), currentLocation.getLatitude() - destinationLocation.getLatitude());
return Math.toDegrees(angle1 - angle2);
But for example when first point == second point i except the degree to be 0. But it gives me strange results like 176 degrees. Where is the problem?