Center of mass in the plane
m.pts / Total[m]
Mean @ WeightedData[pts, m]
Normalize[m.pts, Last]
Normalize[m, Total].pts
Divide[{##}, #2] & @@ (m.pts)
all give
{29/15, 1}
So do
☺ = (#.#2)/(+## & @@ #) &;
☺[m, pts]
{29/15, 1}
and
☹ = {##}/#2 & @@ (#.#2) &;
☹[m, pts]
{29/15, 1}
To represent what you are describing I tried to simulate cylinders with equal diameters, but with different heights representing the weight.
The red cylinders are the masses distributed as the sts list is indicating.
The green cylinder represents the base point for this system, in other words, the center of gravity of the cylinder set (ptCG).
pts = {{-1, 1}, {2, -1}, {3, 2}};
m = {3, 4, 8};
ptCG = m.pts/Total[m];
mass = {Red,
Cylinder[{Append[pts[[#]], 0], Append[pts[[#]], m[[#]]]}, .2] & /@
Range[3]};
l1 = Line[{{-1.11094004, 0.83358994, 0}, {1.88905996, -1.16641006,
0}}];
l2 = Line[{{-1.04850712, 1.1940285, 0}, {2.95149288, 2.1940285, 0}}];
l3 = Line[{{2.18973666, -1.06324555, 0}, {3.18973666, 1.93675445, 0}}];
CG = {Green, Cylinder[{Append[ptCG, 0], Append[ptCG, -.2]}, .2]};
Graphics3D[{mass, CG, Red, Dashed, l1, l2, l3}, Boxed -> False]
Since the OP mentioned using RegionCentroid
, here is a RegionCentroid
approach:
Most@RegionCentroid@RegionUnion[
Line[{{-1,1,0},{-1,1,3}}],
Line[{{2,-1,0},{2,-1,4}}],
Line[{{3,2,0},{3,2,8}}]
]
{29/15, 1}