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 (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.

1 Like

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 (5.3 KB)

and here is link to Wikipedia Weighted arithmetic mean

1 Like

Gh has a weighted average component which gets that results.

1 Like

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

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 :smiley:

1 Like