# Finding the angle between three points?

I have the cartesian coordinates for three points $A$, $B$, $C$. I need to find the angle formed by $A\rightarrow B\rightarrow C$ using the 'right-hand rule' from B.

I'm having difficulty here as sometimes the angle will be exterior, and sometimes not.

Is there a single formula I can use for this?

Many thanks!

There are, of course, may ways to do this. One way would be to use vector. Note that

\begin{array}{ccc} \vec{AB} & = & B-A \\ \vec{BC} & = & C - B \end{array}

The scalar product (a.k.a. the dot product) has the property that

$$\vec{AB} \cdot \vec{BC} = \|\vec{AB}\| \, \|\vec{BC}\| \, \cos\theta$$

where $\| * \|$ measures the length and $\theta$ is the angle between the two vectors.

If you have $A$, $B$ and $C$ then you can work out $\vec{AB}$ and $\vec{BC}$. With that, find the dot product $\vec{AB}\cdot \vec{BC}$ and the lengths $\|\vec{AB}\|$ and $\|\vec{BC}\|$. Then substitute to find $\theta$, where

$$\theta = \arccos \left( \frac{\vec{AB}\cdot \vec{BC}}{ \|\vec{AB}\| \, \|\vec{BC}\|}\right).$$

All I did in the last step was to rearrange the formula to solve for $\theta$.

• The dot product has its own definition and is a given number. I happens to relate to $\theta$ in the way stated. Let me give an example. $A=(1,2,3)$, $B=(3,2,1)$ and $C = (1,1,1)$. Then $\vec{AB} = (2,0,-2)$ and $\vec{BC} = (-2,-1,0)$. Then the dot product: $$\vec{AB} \cdot \vec{BC} = (-2)(-2)+(0)(-1)+(2)(0)=4$$ The lengths are found using Pythagoras: $$\|\vec{AB}\| = \sqrt{2^2+0^2+(-2)^2} = 2\sqrt{2}$$ $$\|\vec{BC}\| = \sqrt{(-2)^2+(-1)^2+0^2} = \sqrt{5}$$ Putting all of this together: $$\theta = \arccos\left(\frac{4}{2\sqrt{2}\sqrt{5}}\right)$$ $$\theta \approx 50.8^{\circ}$$ – Fly by Night Apr 14 '13 at 17:44
• Your example calculation of dot product is wrong, should have been $\vec{AB} \cdot \vec{BC} = (2)(-2) + (0)(-1) + (-2)(0) = -4$ – Michael Pankov Sep 12 '13 at 20:01
• @FlybyNight, can you include your comment in the answer? – Mirzhan Irkegulov Jul 5 '14 at 15:46
• What if I just need to know if an angle is acute or not? – Max Li Jun 30 '16 at 21:38
• If an angle $0 \le \theta\le 180^{\circ}$ is acute then $\cos \theta$ will be positive. If it is obtuse then $\cos \theta$ will be negative. If $\theta = 90^{\circ}$ then $\cos \theta = 0$. Given two non-zero vectors ${\bf u}$ and ${\bf v}$ separated by an angle $\theta$, we have $$\cos \theta = \frac{{\bf u} \cdot {\bf v}}{\|{\bf u}\| \|{\bf v}\|}$$ Since $\|{\bf u}\|$ and $\|{\bf v}\|$ are both positive, the sign of $\cos \theta$ is the sign of ${\bf u} \cdot {\bf v}$. So the angle is acute if ${\bf u} \cdot {\bf v} > 0$ and obtuse if ${\bf u} \cdot {\bf v} < 0$. – Fly by Night Jul 1 '16 at 15:38

First convert $AB$ and $BC$ into vectors $\vec{x}, \vec{y}$ by subtracting coordinates. Then use the dot product:

$\vec{x} \cdot \vec{y} = |\vec{x}| |\vec{y}| \cos \theta$

where $\theta$ is the angle between the vectors.

In this way you can get the angle between the vectors.

Using properties of triangle you can solve this problem easily,

Let in ABC triangle,

a = distance(C, B)

b = distance(C, A)

c = distance(A, B)

Now the triangle property say,

$\quad\ 1. \quad\ a^{2} = b^{2} + c^{2} - 2.b.c.CosA$

$\quad\ \quad\ \quad\ or, cosA = (b^{2} + c^{2} - a^{2}) / 2.b.c$

$\quad\ \quad\ \quad\ or, A = arccos(b^{2} + c^{2} - a^{2}) / 2.b.c$

$\quad\ 2. \quad\ b^{2} = a^{2} + c^{2} - 2.c.a.cosB$

$\quad\ \quad\ \quad\ or, cosB = (a^{2} + c^{2} - b^{2}) / 2.c.a$

$\quad\ \quad\ \quad\ or, B = arccos(a^{2} + c^{2} - b^{2}) / 2.c.a$

$\quad\ 3. \quad\ c^{2} = a^{2} + b^{2} - 2.a.b.CosC$

$\quad\ \quad\ \quad\ or, cosC = (a^{2} + b^{2} - c^{2}) / 2.a.b$

$\quad\ \quad\ \quad\ or, C = arccos (a^{2} + b^{2} - c^{2}) / 2.a.b$

• Your question is not clear to me? – Jobayer sheikh Jul 8 '17 at 9:07