Exercise 3 solution (Python) import math def grid_bearing(e1, n1, e2, n2): """Clockwise angle from grid north, 0 to 360.""" return math.degrees(math.atan2(e2 - e1, n2 - n1)) % 360 def distance(e1, n1, e2, n2): return math.hypot(e2 - e1, n2 - n1) def grid_to_magnetic(grid, variation_w): return (grid + variation_w) % 360 def magnetic_to_grid(mag, variation_w): return (mag - variation_w) % 360 def drift(error_degrees, metres): return metres * math.tan(math.radians(error_degrees)) legs = [(450, 200, 600, 350), (300, 300, 300, 100), (100, 500, 400, 100), (700, 250, 500, 450), (0, 0, 10, -10)] for leg in legs: g = grid_bearing(*leg) print(round(g), round(distance(*leg), 1), round(grid_to_magnetic(g, 2))) g = magnetic_to_grid(128, 2) print(g, (g + 180) % 360) print(round(drift(3, 800), 1), round(drift(5, 500), 1)) Output: 45 212.1 47 180 200.0 182 143 500.0 145 315 282.8 317 135 14.1 137 126 306 41.9 43.7 atan2(across, along) takes care of the quadrant for you; the % 360 turns a negative angle into the matching positive bearing (for example -90 becomes 270).