# How to calculate the angle made by 3 coordinates without using cosine rule

I have the $x$ and $z$ coordinates of 3 points ($S$, $E$ and $W$) lying on the $x$, $z$ plane. I want to calculate the outer angle made by point $E$, and the line going through points $S$ and $E$, as shown in figure 1.

$\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:$ figure 1

$\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:$

I know I can use the cosine rule to calculate this - by calculating the lengths of $SE$, $EW$ and $SW$ and then plugging these values into the law of cosines equation. But this involves a lot of calculations. Is there a quicker way?

To calculate the angle between $SE$ and the vertical I used the equation:

$$\theta = \cos^{-1} \frac{1 - E_y}{\sqrt{(E_y - 1)^2 + (E_z - 1)^2}}.$$

Which was derived from the dot product equation. Is there a similar equation to calculate the outer angle between $SE$ and $EW$? (the yellow elbow flextion angle shown in figure 1)

• Find the angle between $EW$ and vertical line, subtract one from another. – Kaster Feb 26 '15 at 21:48
• You mention x and z coordinates, but the picture in in the y z coordinates. – John Alexiou Feb 26 '15 at 22:04

1. Create two vectors $A=(S-E)$ and $B=(W-E)$
2. Calculate the dot product $$\cos\theta = A\cdot B = A_x B_x + A_z B_z$$
3. Calculate the magnitude of the cross product $$\sin\theta = |A \times B| = A_x B_y - A_y B_x$$
4. Use the ATAN2() function to get the included angle $$\theta = {\rm atan2}(\sin \theta, \cos \theta)$$
5. Get the desired angle by $\pi - \theta$