1
$\begingroup$

I have 5 points and measures of sides of pentagon in 2D. Then how do i find interior angles of pentagon?

Suppose $P_1,P_2,P_3,P_4,P_5$ are five points of Pentagon $P_1P_2P_3P_4P_5$. I know how to find angle of triangle giving sides using cosine formula.To find angle at $P2$, i have made one triangle $P_1P_2P_3$ and also rest of angles have same process. It is fine. But When i move a point to inside of pentagon the angle at some point will be exterior angle. Exactly i want to find interior angles. Please help me any one.

  • 0
    I can find angles for convex pentagon but not concave pentagon. I asked for second case. when i move a point to inside of pentagon, the angle at that point will be shown exterior angle. Actually the angle will increase(>180 degrees) when move a point to inside of pentagon. But it's not like that. It will be shown less than 180 degrees.2012-05-29

1 Answers 1

4

If you have the points then that's all you need. Use the dot product between two sides, going in the same direction along both. So if you want the angle $\angle P_1P_2P_3$, you can do $\pi-\arccos(\frac{(P_2-P_1)\cdot(P_3-P_2)}{|P_2-P_1||P_3-P_2|})$

But this only works for acute angles, as you've seen. So:


If you can see which angles are acute and which aren't, just take $2\pi$ minus the above answer for the reflex angles.


If you need a computer algorithm: don't store the angles as you go, store the signed $\arccos()$ values directly. These are the difference in direction between sides (exterior angles in a convex polygon). Sign them by giving them a third $z$-coordinate of $0$, and computing the cross product $(P_2-P_1)\times (P_3-P_2)$. You'll get one non-zero value along the '$z$' direction. If it's negative, you're turning right. If it's positive, you're turning left. Give the $\arccos()$ values the sign of their corresponding cross-products. Start off by assuming the polygon is on your left. Use this assumption, the above calculation, and the cross product to compute those signed $\arccos()$ values. Also keep a running total of the angle you've turned: what we're looking for is something like the winding number. If your total angle traversed at the end is $2\pi$, then your assumption that the polygon was on your left was correct, and your angles are $\pi$ minus the values you stored. If your total angle traversed is $-2\pi$, then your assumption was wrong, and you should take $\pi$ plus the values you stored instead.