# Compute the Centroid of a 3D Planar Polygon

Given a list of 3D coordinates that define the surface( Point3D1, Point3D2, Point3D3, and so on), how to calculate the centroid of the surface?

More specifically, I am looking for a natural extension of the following 2D centroid algorithm in 3 or more dimension:   Any idea?

P/S: All the points are coplanar, this is the assumption.

• Before asking for the centroid of a surface bounded by a polygonal cycle, you should define more clearly what the surface is. Are all the vertices required to lie on the same plane as each other, so you really just have a 2d polygon embedded into 3d? Or are you trying to describe non-flat 3d surfaces? – David Eppstein Mar 4 '10 at 3:14
• I don't think this question is well-defined unless all your points are coplanar. In that case you'd probably just want to project down onto R^2. – Michael Lugo Mar 4 '10 at 3:16
• Then the centroid sits over the centroid of its projection to any plane. So, you can use the formulas for two coordinates to compute each coordinate for the centroid. – Douglas Zare Mar 4 '10 at 6:43
• to add to what Douglas says, since the points are coplanar, just find that plane and rotate the object so it's in the x,y plane, and proceed as before – Suresh Venkat Mar 18 '10 at 20:18
• To subtract from what Suresh says, you don't need to rotate anything. Just project onto the (x,y)-plane to get the x- and y-coordinates, and project onto the (x,z)-plane to get the z-coordinate. – TonyK May 4 '10 at 20:30

In response to JBL's comment, I offer this answer merely to close out this topic. It has been effectively answered in the comments: Simply project to xy and to xz and compute the centroid there. (One tiny wrinkle not addressed is if the polygon lies in a plane perpendicular to xy or to xz. But then simply chose the coordinate planes in which it does not lie.)

On the advice of Andrew Stacey, I am designating this answer "community wiki," and hope that someone will vote it up so it will no longer be bumped to the top of the active list by the MO background process.

• Well, I would have voted you up in any case. :) Mentioning the "extra wrinkle" is good, too. – JBL Jun 16 '10 at 13:02
• I think you meant 'perpendicular', not 'parallel'. Another wrinkle is that this method generates two values for the x-coordinate of the centroid, and you have to decide what to do when they are not equal due to rounding errors. Probably you should take the one that came from the 'least perpendicular' projection, i.e. the one with the greater area A. – TonyK Jun 17 '10 at 18:41
• @TonyK: Thanks for the correction, now edited. In practice I have simply averaged the two x-coordinates, although your method may be more accurate. – Joseph O'Rourke Jun 29 '10 at 11:25

These formulas could be deduced using Green's theorem . For example the formula used to compute the polygon's area is proved using the vector field F=(-y/2,x/2).

Maybe you can do the same in the space using analogous vector fields and Stokes' theorem .

I'm not sure about the centroid of the surface area, but I might be able to help with the centroid of it's enclosed volume under some specific circumstances.

If each surface formed by the points creates a triangle (as is the case with the vast majority of computer related applications) then you can use this method that i outlined in StackOverflow (i understand its not in the from a mathematician would like it in, but if you read the explanation the answer is fairly simple).

https://stackoverflow.com/questions/2083771/a-method-to-calculate-the-centre-of-mass-from-a-stl-stereo-lithography-file

Hopefully that helps

It seems easiest to give up on the centroid and simply find the average of the vertices of the planar figure you want to find the "center" of. I have a demo program: http://www.mjmtools.com/webgl/tutorial/rhombicTriacontahedron/index.html

With it you can load 3D shapes, and then display new shapes based on the centroid of the each face (using the projection method outlined in the other answers) and you can also display new shapes using the simple vertex average of each face. You can see by visual inspection they are the same, even for shapes with irregular faces (e.g. the Tetartoid.)

Interested to dig deeper and see why these produce the same results.

• Actually upon further review there is a slight difference between the centroid method and the average vertex method on the faces of the tetartoid - the faces of which are irregular pentagons. The difference is very slight, so I think the advice still holds, as the goal I think was to just roughly center a label. – Max Mammel Oct 6 '16 at 4:27