Jump to content
  • Advertisement
Sign in to follow this  
MrSparkle27

Is a polygon convex or concave?

This topic is 3616 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 wonder how I can check wether a 3d polygon is convex or concave. Is there a way without projecting the polygon into 2d space? Thank you! Christian

Share this post


Link to post
Share on other sites
Advertisement
Iterate through all your vertices. For each vertex you take the cross product of the two vectors pointing to the adjacent points (connected by the two adjoining edges), and checking that the sign of these cross products are all the same. They should all have the same direction if convex, otherwise some will point in the opposite direction.

In general, you can just check the sign for each component of the cross product. It is often sufficient to just use (and therefore compute) one component, but this assumes that the plane of the polygon is not parallel to the associated axis.

For efficiency, I would take the first 3 vertices, compute normal of their triangle, and find the largest component. For the rest of the vertices, I would only compute the component of the cross product associated wit this component. This is roughly equivalent to choosing a non-degenerate projection plane and projecting it to 2D and searching for reflex angles.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!