Problem with angles between lat and longitudes when using the atan function