Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the number of internal angles of a polygon, bigger than 180º

Tags:

How can I find the number of internal angles of a polygon, bigger than 180º, having only the vertices of the polygon?

For each vertex I want always the internal angle, not the external.

Thanks from Brazil.

like image 387
lucasbls1 Avatar asked Feb 03 '09 16:02

lucasbls1


People also ask

What polygon that has an interior angles greater than 1800?

A Concave polygon is a polygon that has at least one interior angle greater than 180 degrees. It must have at least four sides.

Can interior angle of a polygon be greater than 180?

3) If at least one angle of a polygon is more than 180∘, it is called concave polygon. 4) If at least one angle of a polygon is less than 180∘, it is called convex polygon.

How do you find the number of interior angles in a polygon?

To find the sum of interior angles of a polygon, multiply the number of triangles in the polygon by 180°. The formula for calculating the sum of interior angles is ( n − 2 ) × 180 ∘ where is the number of sides.


1 Answers

You can determine the angle of two vectors simply by taking the scalar product (dot product). A useful property is that if the vectors are orthogonal, their scalar product is zero; if their angle is obtuse, the product is negative, otherwise positive. So, the steps to take are:

  • find the first edge from V0 to V1 (as a vector, you get this by subtracting the coordinates), then rotate it by 90 degrees to the left (this is just transforming (x y) to (-y x))
  • find the second edge from V1 to V2 (not rotated)
  • take the scalar product (this is just (x1 * x2) + (y1 * y2))
  • if the scalar product is negative, it is a right turn, otherwise a left turn
  • next edge...
  • if you go through the vertices counter-clockwise, count the number of right turns, otherwise the number of left turns
  • for the last vertex, you have to return to the first (i.e. use the edges Vn to V0 and V0 to V1)

edit: You can find whether the vertices are ordered counter-clockwise or clockwise by using the following formula to calculate the polygon's area:

     1  n-1
A = --- SUM( x(i)*y(i+1) - x(i+1)*y(i) )
     2  i=0

where n is the number of vertices. x(n) and y(n) are the same as x(0) and y(0) (to close the polygon).

If it is positive, then the vertices are ordered counter-clockwise, otherwise clockwise.

edit: When you simplify the steps of rotation and scalar product, you arrive at the formula for the two-dimensional cross product, x1*y2 - x2*y1. This simplifies the first steps above:

  • find the first edge from V0 to V1 (as a vector, by subtracting the coordinates)
  • dito for the second edge from V1 to V2
  • take the cross product ((x1 * y2) - (x2 * y1))
  • if the cross product is positive, it is a left turn

Sorry for the convoluted first approach.

like image 118
Svante Avatar answered Oct 01 '22 22:10

Svante