Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

centre of gravity and volume for mesh model

1,760 views
Skip to first unread message

jefm

unread,
Nov 11, 2009, 2:17:38 PM11/11/09
to
newbie question:
is it possible to calculate (or approximate) the COG (centre-of-
gravity) and volume for a mesh model (e.g. as imported from an OBJ
model) ?
What would be the approach ?
regards
Jef

John Tsiombikas

unread,
Nov 11, 2009, 5:17:32 PM11/11/09
to

For the center of gravity you could just use the centroid of the mesh.
You can calculate the centroid by averaging the positions of all its
vertices.

As for the volume, you could easily calculate it using monte carlo
integration. Just generate random samples inside a bounding box of known
volume, and test how many of those samples fall inside the object. The
volume then is inside / num_samples * box_volume.

--
John Tsiombikas (Nuclear / Mindlapse)
http://nuclear.sdf-eu.org/

Wolfgang Draxinger

unread,
Nov 12, 2009, 3:04:33 AM11/12/09
to
John Tsiombikas wrote:

> For the center of gravity you could just use the centroid of the mesh.
> You can calculate the centroid by averaging the positions of all its
> vertices.

Actually, to get an acurate position of the center of gravity, you first
need the volume.



> As for the volume, you could easily calculate it using monte carlo
> integration. Just generate random samples inside a bounding box of known
> volume, and test how many of those samples fall inside the object. The
> volume then is inside / num_samples * box_volume.

And why would you do it with a monte carlo method? Making a MC efficient,
requires to prepare the mesh data with some acceleration structure, some
spatial subdivision scheme. Like BSP or a Kd tree. But if you have the
spatial subdivision, one can directly compute the volume from that.


Wolfgang

fungus

unread,
Nov 12, 2009, 8:31:39 AM11/12/09
to
On Nov 11, 11:17 pm, John Tsiombikas <nucl...@siggraph.org> wrote:
>
> For the center of gravity you could just use the centroid of the mesh.
> You can calculate the centroid by averaging the positions of all its
> vertices.

This can fail - some parts of the model might have more
detail/vertices than others.

A real center of gravity is quite hard to calculate from
a polygon mesh.

--
<\___/>
/ O O \
\_____/ FTB.

Dave Eberly

unread,
Nov 12, 2009, 6:38:19 PM11/12/09
to
"fungus" <opengl...@artlum.com> wrote in message
news:2ac1453d-0be8-4a38...@t2g2000yqn.googlegroups.com...

> This can fail - some parts of the model might have more
> detail/vertices than others.
>
> A real center of gravity is quite hard to calculate from
> a polygon mesh.

If the mesh is a simple polyhedron, then the computation is fairly easy.
http://www.geometrictools.com/Documentation/PolyhedralMassProperties.pdf

If the mesh is not a simple polyhedron but can be decomposed into
a disjoint union of polyhedra, then you can apply this same result
to each polyhedron and combine.

--
Dave Eberly
http://www.geometrictools.com


pjrich

unread,
Nov 12, 2009, 8:15:02 PM11/12/09
to

There's a script on http://blenderartists.org/forum/showthread.php?p=1262210
which suggests the following:

To find the center of gravity (or "centroid") of a polygonal mesh:
convert all of its faces to triangles, and average the centroids of
all of the triangles, weighted by the doubled area of each face.
Wikipedia calls it <a href="http://en.wikipedia.org/wiki/
Centroid#Centroid_by_geometric_decomposition">Centroid by Geometric
Decomposition</a>.

C = Centroid <vector>, A = (area of a face * 2)
R = face centroid = average of vertices making the face <vector>
C = [sum of all (A*R)] / [sum of all R]

jefm

unread,
Nov 13, 2009, 10:23:15 AM11/13/09
to
thanks,
this was all very useful.
Jef

pjrich

unread,
Nov 17, 2009, 11:52:59 AM11/17/09
to

Hey Jef,
There's a typo in the last line of my last post. That should be C =
[sum of all (A*R)] / [sum of all A]
And that's ultimately from http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/
Cheers,
Peter

Leclerc

unread,
Nov 19, 2009, 10:28:08 AM11/19/09
to

Do you want to calculate CG of "material" enclosed by the mash, or GC of
the mesh itself?

pjrich

unread,
Nov 19, 2009, 11:38:45 AM11/19/09
to
On Nov 19, 10:28 am, Leclerc <gordan.sikic.rem...@this.inet.hr> wrote:
> Do you want to calculate CG of "material" enclosed by the mash, or GC of
> the mesh itself?

Good point -- to be clear, the formula I posted applies only to a mesh
as if it was constructed from 2-dimensional sheets of constant
density, and ignores any enclosed volume.

Rui Maciel

unread,
Nov 19, 2009, 1:42:17 PM11/19/09
to
pjrich wrote:

> To find the center of gravity (or "centroid") of a polygonal mesh:

Just to nit pick, the center of gravity (and even center of mass) isn't exactly the same thing as the
centroid, as the centroid is the geometric center while the center of gravity is the point on a solid where
it is possible to apply a single force which is statically equivalent to the effect gravity has on it. It
just happens that under some circumstances the two points coincide.


Rui Maciel

pjrich

unread,
Nov 19, 2009, 4:24:17 PM11/19/09
to

Precisely -- and those points coincide for any 2D shape or 3D mesh
with no thickness -- correct?
My apologies for the ambiguity. Nits are our business, after all.
P

Rui Maciel

unread,
Nov 20, 2009, 5:03:32 AM11/20/09
to
pjrich wrote:

> Precisely -- and those points coincide for any 2D shape or 3D mesh
> with no thickness -- correct?

Not necessarily. They do only if a couple of specific conditions are verified. If the mass isn't distributed
uniformly or if the gravity field is not constant across the domain then the centroid, center of mass and
center of gravity will not coincide.


Rui Maciel


0 new messages