Find the number of internal corners of the polygon, greater than 180º

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

Each vertex always needs an internal angle, not an external one.

Thank you Brazil.

+5
source share
6 answers

You can determine the angle of two vectors simply by taking the scalar product (point 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 are:

  • V0 V1 ( ), 90 ( (x y) (-y x))
  • V1 V2 ( )
  • ( (x1 * x2) + (y1 * y2))
  • , ,
  • ...
  • , ,
  • (.. Vn V0 V0 V1)

edit: , , :

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

n - . x(n) y(n) x(0) y(0) ( ).

, , .

edit: , - x1*y2 - x2*y1. :

  • V0 V1 ( , )
  • dito V1 V2
  • ((x1 * y2) - (x2 * y1))
  • ,

.

+4
  • .
  • , . 180 .
  • ( , ).
+2

, , 180 .

. , , , , .

,

tan(angle_to_left) = (v.y-left.x)/(v.y-left.y)
tan(angle_to_right) = (v.y-right.x)/(v.y-right.y)

.

, , 180, . , , 180.

0

- x == 0. , , , - .

, , ( , ?). - , .

0

( ), :

angleRadians = Math.acos((vx1 * vx2 + vy1 * vy2)/(Math.sqrt(vx1 * vx1 + vy1 * vy1) * Math.sqrt(vx2 * vx2 + vy2 * vy2)));

Dot- . ,

" ", -, , , - ( (ext) 360.

JS- : https://gist.github.com/3741816.

: D

0

, , .

, , , .

, , .

For example, look at the polygon:

Polygon

We can build a triangle like:

Construct internal triangle

-1
source

All Articles