How do I calculate the angle between two sides of a polygon?

948 Views Asked by At

So I got a polygon and I have all of the points. What I need, is to find all internal angles of this irregular polygon. How do I do that?

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

If you have all the edge positions of the polygon, then you should definitely compute the angles by the dot product between the two edges vectors that generate this angle. More precisely, if you have three points $A=(x_a,y_a)$, $B=(x_b,y_b)$ and $C=(x_c,y_c)$, and you need to compute the angle $\widehat{ABC}$, then you generate the vectors $\vec{BA}$ and $\vec{BC}$ and you can compute : $$ \theta = \arccos ( \frac{\vec{BA} . \vec{BC}}{\|\vec{BA}\|\|\vec{BC}\|}) $$