# Compute the Centroid of a 3D Planar Polygon Without Projecting It To Specific Planes

Given a list of coordinates of a coplanar plane (pt1, pt2, pt3 and so on), how to compute the centroid of the coplanar plane?

One way to do it is to project the plane onto XY and YZ plane, but I don't really favor this approach as you have to check the orientation of the coplanar plane first before doing the projection and computing the centroid.

More specifically, I'm looking for a natural extension of the 2D centroid plane algorithm in 3D:

Any idea?

-

You can take any two orthogonal vectors $\vec{e_1}$ and $\vec{e_2}$ on the plane and use them as a basis. You also need some point $(x_0, y_0, z_0)$ on the plane as origin.

Given point with coordinates $(x_1, y_1, z_1)$ on your plane you calculate it's coordinates with respect to new basis:

$x = (x_1 - x_0) e_{1x} + (y_1 - y_0) e_{1y} + (z_1 - z_0) e_{1z}$
$y = (x_1 - x_0) e_{2x} + (y_1 - y_0) e_{2y} + (z_1 - z_0) e_{2z}$

And after that you can apply your formulae to get $C_x$ and $C_y$. Those coordinates are easyly transformed back into original 3d coordinates:
$x = x_0 + e_{1x} C_x + e_{2x} C_y$
$y = y_0 + e_{1y} C_x + e_{2y} C_y$
$z = z_0 + e_{1z} C_x + e_{2z} C_y$

-
So, the final formula is? –  Graviton Aug 2 '10 at 7:19
Also, where is Cz? –  Graviton Aug 2 '10 at 11:53
There is no $C_z$. You convert original 3d problem into 2d problem, find $C_x$ and $C_y$ and convert back to 3d. –  falagar Aug 2 '10 at 12:14
The answer is $(x, y, z)$ given by the last formulae. –  falagar Aug 2 '10 at 12:20
converting this 3d problem into 2d problem is the last thing i want. –  Graviton Aug 9 '10 at 12:12