# Group Centroid

Hello GH Community,
I need to find the centroid of a group of curves instead of each individual curve centroid. “Group” does not allow me to use “area” component to locate the common centroid of the grouped curves.

Is there a way to locate the centroid of a group of curves?

I have hundreds of move translations i would like to make. Thanks for your time community.
Centroid Group.gh (5.3 KB)

Use “Average” on your center points. This will give you the center of all Centers.

1 Like

Or use Bounding Box

Right click on BB component and click on Union Box.
Then Box Properties then use C point.

2 Likes

Boom! Thank you to you both!
Both are great solutions, but the Bounding Box seems to be more accurate for what I need.

If you want to do it the way how it is done in Rhino (_AreaCentroid command) what is right way how to do, then you should calculate it as Weighted arithmetic mean. The code in C# component is simple:

``````    private void RunScript(List<double> Area, List<Point3d> AreaCentroid, ref object AvgCentroid)
{
Point3d pointSum = new Point3d();
double AreaSum = 0;
for (int i = 0; i < Area.Count; i++)
{
pointSum += Area[i] * AreaCentroid[i];
AreaSum += Area[i];
}
AvgCentroid = pointSum / AreaSum;
}
``````

Here is the ghfile Centroid Group 02.gh (5.3 KB)

and here is link to Wikipedia Weighted arithmetic mean

1 Like

Gh has a weighted average component which gets that results.

2 Likes

I am not using gh often and did not know about this component so I just do it with few lines of code.
Thanks

1 Like

Hey sure yea, Just putting it there. I think many miss this component (and the interpolate data component) I did for awhile also

1 Like

Does anyone know how to find central point (or centre line) of multiple geometries (so I could use it as axis later on):

So essentially I have a series of boxes (their amount and heights driven by sliders), and I’d like to determine centre of all of them. Using Average gives me all the central points, and I would like just one central point

right click over the bounding box component and set it to union box

Hey @Baris , thank you for your quick reply. I changed it to union but I still get the same points?

playing with multiple elements.3dm (141.4 KB) playing with multiple elements.gh (12.5 KB)

You will need to flatten the input to content.

1 Like

Fabulous! Thank you @christopher.ho