Get simple polygons

I have a C polygon as shown below:

enter image description here

C = 10     0
     2     0
     2     2
     0     2
     2     0
     0     0
     0    10
    10    10

where the first column represents the x coordinate and the second column corresponds to the y coordinate of the polygon C. As you can see in the figure above, this is not a simple polygon (this polygon contains a hole that is specified in white), so I want to get all the simple subpolygons from C, which does not contain holes. In this case, the output should be as follows:

    C1 =  0     2
          2     0
          0     0

    C2 =  2     0
          2     2
          0     2
          0    10
         10    10
         10     0

Where C1 and C2 correspond to a small red triangle and a large red polygon, respectively.

The problem is, how can I generate these subpolygons?

Any idea would be appreciated.

+5
source share
1 answer

, ? , . , - http://en.wikipedia.org/wiki/Bentley%E2%80%93Ottmann_algorithm, .

, . ( -.)

, , , , . ( "" .) , , . ( x 0 , y - 90 , x - 180 , , .) , - :

( 0,  0): ( 2, 0), ( 0, 2)
( 2,  0): (10, 0), ( 2, 2), ( 0, 2), ( 0, 0)
(10,  0): (10,10), ( 2, 0)
( 0,  2): ( 0, 0), ( 2, 0), ( 2, 2), ( 0,10)
( 2,  2): ( 2, 0), ( 0, 2)
( 0, 10): ( 0, 2), (10,10)
(10, 10): (10, 0), ( 0,10)

, , ( ) , ( .. , , , , ). . , , . , ( 0, 0) ( 2, 0), ( 2, 0) , ( 0, 0) (10, 0), (10, 0) , ( 2, 0) (10,10) :

( 0, 0), ( 2, 0), (10, 0), (10,10), ( 0,10), ( 0, 2), ( 0, 0)

( , - .)

( 0, 0) ( 0, 2) :

( 0, 0), ( 0, 2), ( 2, 0), ( 0, 0)

( .)

( 2, 0) ( 2, 2). .

( 2, 0), ( 2, 2), ( 0, 2), ( 0,10), (10,10), (10,0), ( 2, 0)

( .)

( 2, 0) ( 0, 2), :

( 2, 0), ( 0, 2), ( 2, 2), ( 2, 0)

( .)

, , , , , . , . , . . y ( , ). , , ( 2, 0). , , (10, 0), ( 2, 2), ( 0, 2), ( 0, 0). , , , ... , , , . , :

outside:
  - (10, 0), ( 2, 2), ( 0, 2), ( 0, 0)
  - ( 2, 0), ( 0, 2), ( 2, 2), ( 2, 0)

inside:
  - ( 2, 0), ( 2, 2), ( 0, 2), ( 0,10), (10,10), (10, 0), ( 2, 0)
  - ( 0, 0), ( 0, 2), ( 2, 0), ( 0, 0)

.

( , . , , , , . , .)

+2

All Articles