Calculation of bearings and distances