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!
 A: There are several answers here with a sign error, so this corrects the top voted answer and adds an example that shows why the correction gets the correct answer.
I added a comment but SE is hiding it so I feel an answer is important to ensure folks are not led astray (I spent hours debugging code written based on this answer)

Corrected answer:
The question asks for the angle $A\rightarrow B \rightarrow C$ , which I take to mean the angle where B is the vertex. Thus, reformulating the question we want the angle between the vector from B to A aka $\vec{BA}$ and the vector from B to C aka $\vec{BC}$).,
\begin{array}{ccc}
\vec{BA} & = & A-B \\
\vec{BC} & = & C - B
\end{array}
The scalar product (a.k.a. the dot product) has the property that
$$\vec{BA} \cdot \vec{BC} = \|\vec{BA}\| \, \|\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{BA}$ and $\vec{BC}$. With that, find the dot product $\vec{BA}\cdot \vec{BC}$ and the lengths $\|\vec{BA}\|$ and $\|\vec{BC}\|$. Then substitute to find $\theta$, where
$$\theta = \arccos \left( \frac{\vec{BA}\cdot \vec{BC}}{ \|\vec{BA}\| \, \|\vec{BC}\|}\right).$$
All I did in the last step was to rearrange the formula to solve for $\theta$. 

Worked Example:


*

*A= (1,1,0)

*B= (0,0,0)

*C= (0,1,0)


This obviously forms an equilateral right triangle with legs of 1 and a hypotenuse of $\sqrt2$ and most people will be instantly aware that the correct answer is 45 degrees ($\pi/4$ radians ~ 0.785)
\begin{array}{ccc}
\vec{BA} & = & A-B  & = & (1,1,0) \\
\vec{BC} & = & C - B & = & (0,1,0)
\end{array}
$$\|\vec{BA}\| = \sqrt2$$
$$\|\vec{BC}\| = 1$$
$$\vec{BA} \cdot \vec{BC} = (0\times1) +(1\times1)+(0\times0) = 0 + 1 + 0 = 1 $$
$$\theta = \arccos{(1/(1\times\sqrt2)) = \arccos(1/\sqrt2) = 45 }$$ if we choose to write the answer in degrees of course.

Wrong answers above use:
\begin{array}{ccc}
\vec{AB} & = & B - A & = & (-1,-1,0) \\
\vec{BC} & = & C - B & = & (0,1,0)
\end{array}
Which changes the sign of the dot product:
$$\vec{AB} \cdot \vec{BC} = (0\times-1) +(1\times-1)+(0\times0) = (0) + (-1) + (0) = -1 $$ 
And leads to
$$\theta = \arccos{(-1/(1\times\sqrt2)) = \arccos(-1/\sqrt2) = 135 }$$
There is no angle among any of the 3 points that can be described as 135 degrees. 
As a side note the other answers do seem to give a correct value for the "heading change" or needed to successfully travel to C after traveling to A from B, which could be useful if you wanted to drive a robot along a polygon, but I can't see how one would get that notion from the question.
A: 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.
A: 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
$
A: 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$. 
