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


Detecting convex polygones

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 "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.

Share this post

Link to post
Share on other sites