# Thread: Centroid of a Quadrilateral?

1. ## Centroid of a Quadrilateral?

Hi,

I am writing a program where I need to work out the centroid of a quadrilateral given the coordinates of its 4 corners. I know this can be done graphically quite easily but I was wondering if there is a formula I can use to code it?

Advanced Thanks.

Mark.

2. Here's one way to do it: draw either of the diagonals, dividing the quadrilateral into two triangles. Triangles have the nice property that the centroid of a triangle is the average of the three vertices- that is, add each the x coordinates of the three triangles, the y coordinates, and the z coordinates (if this is in three dimensions) and divide by three. Those three averages will be the x, y, and z coordinates of the centroid of the triangle.

Once you have the centroids of the two triangles, the centroid of the quadrilateral is the weighted average of the two points, weighted by the area of the triangles. That is, if $P_1= (x_1, y_1, z_1)$ and $A_1$ are the centroid and area, respectively, of the first triangle, and $P_2= (x_2, y_2, z_2)$ and $A_2$ of the second triangle, then the centroid of the quadrilateral is $\frac{A_1P_1+ A_2P+2}{A_1+ A_2}$ $= \left(\frac{A_1x_1+ A_2x_2}{A_1+ A_2}, \frac{A_1y_1+ A_2y_2}{A_1+ A_2}, \frac{A_1z_1+ A_2z_2}{A_1+ A_2}\right)$

3. ## Re: Centroid of a Quadrilateral?

What a pity HallsofIvy, you almost had a beautiful answer. The weighing is not necessary, just divide the quadrilateral by one of its two diagonals like you suggested and connect the centers of gravity of both resulting triangles, i.e. their centroids, and repeat the procedure with the OTHER diagonal of the quadrilateral. The intersection of both connectors of centers of gravity must be the center of gravity of the Quadrilateral!

,

,

,

,

,

,

,

,

,

,

,

# formula to find the centroid of a quadrilateral

Click on a term to search for related topics.