How to find the centre of a polygon?

Hi,

my trig is a bit weak and I sincerely hope that this is not a beginners question…

Can anyone tell me how to work out the coordinates of the centre of a polygon with n vertices?

Many thanks

matthew

Originally posted by mcsellski:
[b]Hi,

my trig is a bit weak and I sincerely hope that this is not a beginners question…

Can anyone tell me how to work out the coordinates of the centre of a polygon with n vertices?

Many thanks

matthew[/b]

That depends on how you define the centre. Do you want the ‘centre of mass’ or do you want the ‘point with a minimal average distance to all of the vertices’ or do you want the centre by some other definition…

A simple approach is to sum all vertex coordinates and divide by the number of vertices.
This may or may not result in the centre you’re looking for.

HTH

Jean-Marc

It is the same for any arbitrary mesh…
If your vertices have associated weights, then you must compute the sum of all weight(i)*vertex(i), then divide by the global weight (i.e., sum of all weight(i)).
The reciprocal approach is much more difficult, and I haven’t figured out how I could compute vertices weights based on the global weight and a “center wannabe” yet…

Julien.

Thanks for the help. I’d thought that an average would be what I needed. I only need a rough approximation to indicate a users selection.

Thanks again

Matthew

It depends on what you are trying to do :

  • Find the real Center of Mass in which case you use Sum(Pos[i]*Wheight[i])/Sum(*Wheight[i])

  • Find a center for the poligon, in which case Wheigth[i] = 1 and you divide by the number of vertices.

    Dissadvantages of this 2nd method :
    Let’s consider a human mesh : Usualy the face is more refined than the rest ( it contains more vertices ). If you want to compute the Center of Mass it will appear somewhere near the head as the head concentrates more vertices. This is not at all correct.

If you just want to find a turning point the method works.
However there is a method of computing the wheights in a way that will provide an uniform mass distribution.

You could slice your 3D object with several Horizontal planes equally distributed on the Y axis and compute the number of points that fall between 2 consecutive planes. If you attribute a mass to each region (space between 2 planes) you can divide that mass to the nimber of points contained there, and that will give a more equally distributed mass.

If you want precise results increase the number of slicing planes and try to consider vertical and perpendicular planes too

Hope that helps,
For more Questions -> : barsanpipu@yahoo.com

Clau