Jump to content
  • Advertisement
Sign in to follow this  
godsenddeath

Finding the center point for a convex polygon

This topic is 2566 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

I'm trying to re-write an obj loader i wrote a while back, and one thing I was wanting to do is handle faces of an arbitrary size (well, n >= 3) since the .obj file format doesn't limit the number of vertices in a face, Then triangulate the face by using the center point along with connected vertices to form triangles. I'm not a huge math guy, so the best thing I can think of is to use (avgx, avgy, avgz), as the center point, but I'm fairly sure that will crash and burn.

does anyone know of a simple (or complex if need be) algorithm to determine the centerpoint of a convex polygon given its vertices.


Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Yup, just convert it to a triangle fan, like Luca said. I believe this is how most 3D applications export to .obj.[color="#000000"][url="../../user/102074-luca-deltodesco/"][/url]

Share this post


Link to post
Share on other sites
Another popular method, which id's engines use, is the following: Given vertices 0,1,...,n-1, you have a triangle strip with vertices,

0, 1, n-1, 2, n-2, 3, n-3, 4, n-4, ...

[Next, on the subject of "center points" of polygons (even though this isn't really what you need): There are various notions of "center points." Any convex combination (weighted sum with weights between 0 and 1, and adding up to 1; sum in the vector addition sense) of vertices is going be "inside" the polygon, so you could e.g. choose all the weights to be 1/n. Other points that have a certain appeal include the actual center of mass (which you typically compute by triangulating the polygon), and the Chebyshev center (the point farthest away from the closest edge; it's the solution to a certain linear program).]

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!