Centroid of a polygon with weighted vertices I would like to compute a weighted centroid of a polygon where each vertex $V_i$ has an associated weight $W_i$. I know the formula for an "homogeneous" polygon but I'm not sure how to insert the weights into the formula.
 A: Let us compute the centroid of a triangle having a surface density linearly interpolated between the vertices. WLOG, the unit triangle by $(0,0),(0,1),(1,0)$ will do. The density function is $w_{xy}=w_{00}+x(w_{10}-w_{00})+y(w_{01}-w_{00})=ax+by+c$ where the coefficients are deduced from the weights at the corners.
For the mass:
$$\int_{x=0}^1\int_{y=0}^{1-x}(ax+by+c)\,dy\,dx=\int_{x=0}^1(ax(1-x)+\frac{b(1-x)^2}2+c(1-x))\,dx=\frac a6+\frac b6+\frac c2.$$
For the $x$ moment:
$$\int_{x=0}^1\int_{y=0}^{1-x}x(ax+by+c)\,dy\,dx=\int_{x=0}^1(ax^2(1-x)+\frac{bx(1-x)^2}2+cx(1-x))\,dx\\
=\frac a{12}+\frac b{24}+\frac c6.$$
and similarly for $y$.
Then the centroid is
$$\left(\frac{2a+b+4c}{4a+4b+12c},\frac{a+2b+4c}{4a+4b+12c}\right).$$
For an arbitrary triangle, compute the affine transform that maps the canonical triangle to the arbitrary one, and the centroid will just follow.
To get the centroid of a triangulation, compute the centroid of the centroids, each weighted by the corresponding triangle mass.
