[vtkusers] Centroid of a surface
Huntsinger, Reid
reid_huntsinger at merck.com
Tue Nov 16 13:04:59 EST 2004
Do you mean the center of mass of the object whose boundary is the surface
you have triangulated? I am not sure what the centroid of a _surface_ would
be, unless you are thinking of a mass distribution concentrated on the
surface.
To compute the center of mass of the volume, you could use the fact that the
volume integral can be written as a surface integral, and the surface
integral written as a line integral, and the line integral evaluated as a
difference.
For example for the x-coordinate of the center of mass, you want to
integrate x over the volume, ie the form x dx dy dz, and divide the result
by the volume.
To get the numerator, you could instead integrate x^2/2 dy dz over the
surface, because d(x^2/2 dy dz) = x dx dy dz, and to integrate d(something)
over a set V is the same as integrating 'something' over the boundary of V.
Now use your triangulation and view this surface integral as a sum over
triangles of the integrals over each triangle. If your surface is
polyhedral, the triangles are flat and lie in an affine plane described by a
linear equation, say ax + by + cz = d. If a = 0 then dy dz = 0 in the plane
so this triangle contributes 0 to the sum; otherwise you can write x = py +
qz + r (p = -b/a, q = -c/a, r = d/a) and you need to integrate (py + qz +
r)^2/2 dy dz over the triangle. This is the same as integrating (py + qz +
r)^3/(3*2*p) dz over the oriented edges of the triangle.
Now use the same argument to lower the dimension again: each edge lies in a
line described by another linear equation relating y and z; if the
coefficient of y is zero then dz = 0 on this line and the edge integral is
0, otherwise y = mz + n say and the edge integral is the integral of
(p(mz+n) + qz + r)^3/(3*2*p) = ((pm+q)z + pn + r)^3/(3*2*p) over the
interval from z0 (the z coordinate of the start of the edge) to z1 (the z
coordinate of the terminal point of the edge).
This integral is ((pm+q)z + pn + r)^4/(4*3*2*p*(pm+q)) evaluated from z1 to
z0, from calculus.
So for each triangle compute p,q,r; then for each edge compute m,n; then
accumulate the difference of the 4th degree polynomial above across
endpoints.
You get the numerator for the y and z coordinates of the center of mass
similarly. You could just permute coordinates and use the above verbatim but
perhaps it's more efficient to use d(yx dy dz) = y dx dy dz and follow the
above recipe with appropriate changes, since you use the same data
p,q,r,m,n, z0, z1 then.
The denominator is the volume, and you can follow the same steps (and do the
computation simultaneously) with the form dx dy dz. You integrate x dy dz
over the boundary, view it as a sum over triangles, get p, q, r, the for
each oriented edge get m,n and evaluate the resulting 3rd degree polynomial
over the start and end z coordinates of the edge.
If you mean the center of mass of a uniform mass distribution concentrated
on the surface, that would be the sum over triangles T of
area(T)*centroid(T) divided by the total surface area, ie the sum over T of
area(T). [This is different from the center of mass of the volume enclosed,
for example for the tetrahedron whose vertices are (0,0,0), (1,0,0),
(0,1,0), (0,0,1).]
Reid Huntsinger
-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
Of David.Pont at ForestResearch.co.nz
Sent: Monday, November 15, 2004 3:21 PM
To: Dr Zeto
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Centroid of a surface
Dr Zeto <dr_zeato at yahoo.com> wrote on 13/11/2004 07:09:52:
> Hi,
> I want to compute the centroid of a closed surface.
> Apparently, the mean of the vertices of the
> triangulated mesh does not work. For instance, if the
> surface is that of a horse, we have more triangles
> around the legs and the face, where we need more
> detail. While the rest of the torso has significantly
> fewer triangles. Hence, the centroid computed from the
> above method is biased towards the legs and the face.
>
> Is there a class to remesh the surface, so that the
> size of triangles is the same or about the same
> everywhere? Or how can I approach this problem?
Mathematically: there may be a smarter way (check the literature)... but
can you use lengths of edges connected to each point to weight the centroid
calculation? Or should it be triangle areas?
Using vtk filters:
vtkSmoothPolyDataFilter will adjust cell sizes, but may well degrade the
surface too much to be useful. Perhaps this is what you want? If you really
smooth heavily you could just about erase all features (legs, face) to get
a torso-blob. The centroid of that blob might correspond to a more
'intuitive' centroid for the original surface?!
You could use vtkImplicitModeller (offset=0?), vtkSampleFunction,
vtkContourFilter, to 're-mesh' the surface, (what a hack!) hopefully
getting more equal triangle sizes. This will be slow, and there will still
be unequal triangle sizes, but more 'randomly' distributed over the
surface. You could smooth this. Sounds bizarre, but might work!
Dave P
> Thanks
> Zeato
>
>
>
> __________________________________
> Do you Yahoo!?
> Check out the new Yahoo! Front Page.
> www.yahoo.com
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://www.vtk.
> org/Wiki/VTK_FAQ>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
<http://www.vtk.org/Wiki/VTK_FAQ>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system.
------------------------------------------------------------------------------
More information about the vtkusers
mailing list