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)

(Tim Stark) #2

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

(Laurent Delrieu) #3

Or use Bounding Box

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


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

(Radovan Grmusa) #5

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

(Michael Pryor) #6

Gh has a weighted average component which gets that results.

(Radovan Grmusa) #7

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

(Michael Pryor) #8

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