Dr Robert Nurnberg, Imperial College London
Copyright
c 2013. All Rights Reserved. www.ma.ic.ac.uk/~rn/centroid.pdf
Calculating the area and centroid of a polygon in 2d
1
Let {(xi , yi )}N 2
i=0 R be a closed polygon in the plane, and let the vertices be ordered counter
clockwise. Then it is well-known that the polygon encloses the area
N 1
1 X
A= (xi yi+1 xi+1 yi ) ,
2 i=0
and its centroid is given by
N 1 N 1
!T
1 X X
(xi + xi+1 ) (xi yi+1 xi+1 yi ), (yi + yi+1 ) (xi yi+1 xi+1 yi ) R2 ;
6A i=0 i=0
see e.g. paulbourke.net/geometry/polygonmesh.
Calculating the volume and centroid of a polyhedron in 3d
Similar formulas exist for the enclosed volume and centroid of a polyhedron P in R3 , but these
appear to be less well-known. In the following we assume without loss of generality that the
boundary of the polyhedron is given by a union of triangles. (More general facets can easily be
subdivided into triangles.) We stress that P need not be convex.
Let Ai , i = 0, . . . , N 1, be the N triangular faces of the polyhedron, with vertices (ai , bi , ci ),
which are assumed to be ordered counter clockwise on Ai . This means that we can define the
outer unit normal n to P on each Ai as ni = ni /|ni |, where ni = (bi ai ) (ci ai ). Then the
volume of P is given by
Z Z N 1 Z N 1
1 1 X 1 X
V = 1= xn= ai ni = ai ni ,
P 3 P 3 i=0 Ai 6 i=0
where we have used the divergence theorem, the fact that x ni is constant on each Ai , and the
fact that the area of Ai is given by 12 |ni |.
Let c R3 denote the centroid of P , i.e. c = V1 P x. Applying the divergence theorem
R
once again, and on denoting the standard basis in R3 by {e1 , e2 , e3 }, we obtain for the three
coordinates of the centroid that
Z N 1 Z
1 1 2 1 X
c ed = (x ed ) (n ed ) = (x ed )2 (ni ed ) , d = 1, 2, 3 .
V P 2 2V i=0 Ai
It remains to compute that
Z
1
(x ed )2 (ni ed ) = ni ed [ 21 (ai + bi ) ed ]2 + [ 12 (bi + ci ) ed ]2 + [ 12 (ci + ai ) ed ]2
Ai 6
1
ni ed [(ai + bi ) ed ]2 + [(bi + ci ) ed ]2 + [(ci + ai ) ed ]2 ,
=
24
where we have observed that the integrand is a quadratic function on Ai , so that the standard
midpoint sampling quadrature formula for triangles yields the integral exactly, see e.g. [1].
References
[1] A. H. Stroud, Approximate calculation of multiple integrals, Prentice-Hall Inc., Englewood
Cliffs, N. J., 1971.