Let say I have figure like cross, and I have coordinates of the points, and I want get a sequence of numbers I mean angles like " 90, 270, 90, 90, 270, 90, 90, 270, 90, 90, 270, 90 ". Thanks for answer.
-
See here: http://stackoverflow.com/questions/1211212/how-to-calculate-an-angle-from-three-points – Michael Simbirsky Dec 24 '13 at 08:41
-
You create a vector from point 2 to point 1 and another from point 2 to point 3. You then get the angle between these 2 vectors. You can use the dotProduct of the two vectors to calculate the angle. – enhzflep Dec 24 '13 at 08:43
2 Answers
Given three points, a, b, c in 2D, the cosine of the angle between the lines ab and bc is (b -a) . (c - b) / (|b - a| * |c - b|). You can take a look at wikipedia to figure out why that is.
From this, you can take the anticosine of each to give you the actual angle. You'll have to convert from radians to degrees too, by multiplying by 180/pi. There's a few more details, for example distinguishing 270 degrees from 90 degrees, but this should get you started.

- 54,811
- 11
- 92
- 118
There also is atan2( http://www.cplusplus.com/reference/cmath/atan2/ ) function. Given a vector, it returns the angle of direction of that vector, in radians. So you could basically calculate directions for all the vectors you have in your figure, and to get internal angles, you just have to subtract adjacent directions.

- 98
- 1
- 7
-
Yes ok but when I count angle between three points I'll get 90 not 270 degree. How do I know which angle is internal? – takanator Dec 24 '13 at 13:19