How to calculate an angle from three points?
If you mean the angle that P1 is the vertex of then using the Law of Cosines should work:
arccos((P122 + P132 - P232) / (2 * P12 * P13))
where P12 is the length of the segment from P1 to P2, calculated by
sqrt((P1x - P2x)2 + (P1y - P2y)2)
It gets very simple if you think it as two vectors, one from point P1 to P2 and one from P1 to P3
so:
a = (p1.x - p2.x, p1.y - p2.y)
b = (p1.x - p3.x, p1.y - p3.y)
You can then invert the dot product formula:
to get the angle:
Remember that just means: a1*b1 + a2*b2 (just 2 dimensions here...)