#### Archived

This topic is now archived and is closed to further replies.

# Detecting convex polygones

This topic is 5982 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I am looking for a fast test for convexity of quadrangles/polygons. I found the following passage in one of M.Abrash''s articles here on gamedev.net: "The best technique I''ve come up with is tracing around the polygon''s boundary, counting the number of times that the boundary reverses X and Y directions. If the boundary reverses both directions no more than twice, the polygon is convex." ... I do not quite understand what exactly he means. Is it like this: for( i = 0 .. number of points) dx = pnt.x - pnt[i + 1].x; dy = ...; if( sign(dx) != sign(last_dx) ) dx_changed++; if( sign(dy) != ... ) dy_changed++; end for convex = dx_changed <= 2 && dy_changed <= 2; ... or is there a better way? Thanks for the help.

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
18

• 11
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×