Try to make sense of each method one line at a time. The following mathematical topics may be useful:
Pythagoras' theorem
Cosines of angles greater than $90^{\circ}$
Distance between two points on a coordinate grid
Trigonometry in right-angled triangles