Link to home
Start Free TrialLog in
Avatar of stats786
stats786

asked on

Determine whether a polygon is complex or simple

I have two arrays, storing the x and y values of the polygon.

I want to find out whether the polygon is simple or complex.

The polygon can be concave and is 2d.

Can someone possibly provide suggestions.

Many Thanks.
Avatar of x4u
x4u

A simple polygon has a non-intersecting boundary, while a complex polygon has an intersection somewhere. So a natural approach would be to check whether any two sides of the polygon intersect each other.

The intersection of 2 lines can be tested with an algorithm like this:
http://www.macs.hw.ac.uk/~alison/ds98/node114.html
Avatar of stats786

ASKER

I've tried doing an edge-edge test, but it fails for some reason. Could it be that an edge sharing the same node brings back true when doing the edge on edge test?
Yes, this sounds plausible. But you can simply omit to test the neighbor edges as they will never intersect each other.
ASKER CERTIFIED SOLUTION
Avatar of x4u
x4u

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial