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.
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$$\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 01 '16 at 15:38