# 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!

-

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.

-

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$.

-
Thanks! I'm not sure I understand, the last line seems to be defined in terms of itself? As AB dot BC includes theta? –  James Apr 14 '13 at 17:24
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$ –  constantius Sep 12 '13 at 20:01
@FlybyNight, can you include your comment in the answer? –  sindikat Jul 5 at 15:46