How to compute inner angles of polygons

39 Views Asked by At

I'm currently implementing an algorithm to split a concave polygon into y-monotone polygons, so I can triangulate those. As I writing this for my own little library, I'm implementing one of the algorithms I saw during a lecture once.

This algorithm needs to known the inner angle between three vertices of the polygon, but I'm not sure how to compute these. For clarification: I'd like to know the angle indicated in red in the following image:

enter image description here

I would like to solve for the red angle. I've found a formula online that uses atan() but I'm totally not sure how this works and thus I have no idea how to compute this inner angle.

2

There are 2 best solutions below

0
On BEST ANSWER

I think I've found a solution. If I loop over my points in a certain order, and I know if the points are cw or ccw connected, I can conclude what is the inner part.

For example. If I loop over my points clockwise:

  • If three ordered vertices are connected clockwise, I know that I should take the angle < 90°

  • If three ordered vertices are connected counterclockwise, I know that I should take the angle > 90°

3
On

Look at vectors $\mathbf u = BA$ and $\mathbf v = BC$. Then $$ \cos \phi = \frac{\mathbf u \cdot \mathbf v}{|\mathbf u||\mathbf v|}$$ where $\phi = \angle ABC$, "$\cdot$" stands for dot product, and $|\mathbf x|$ is the length of vector $\mathbf x$.