Jump to content
  • Advertisement


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.

If you intended to correct an error in the post then please contact us.

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.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!