Grasshopper

algorithmic modeling for Rhino

# centroid

hi everybody,

is there a way in gh to calculate directly the center of gravity of a more or less complicated polygon?

Views: 7920

### Replies to This Discussion

You can use Brep area (Surface>Analysis>m²) - which has a centroid output, if you make it a Planar surface ( Surface>Freeform>Planar Srf) first.
Thanks, Daniel.
You can also use the Brep Volume (Surface>Analysis>m3) for the center of a volume...try a boolean union of all the solids and the volume of that should give you a centroid for the whole form...probably not exactly where the center of gravity would be though
The fastest way (computing wise) is just add together the vertices of the polygon and divide the result by the number of vertices.
This solves faster than the m2 and m3 components, maybe it's because these also compute area calculations or/and maybe it's because it doesn't special case polygons and uses a slower method that solves any type of nurb surface.
Hi Vicente,

I was curious and tried your vertices addition to see what the outcome would be relative to computational speed. But the results were different. I tried it two ways vector addition/divide (magenta) and point decomposition etc (blue) see picture. Have I made a mistake or is there a wheel off here? My Brep is only created from boxes in the regular world axis, there's no bulges in the faces etc.

The adding vertices only works for regular polygons and triangles, sorry. But also serves as a quick approximation for more complex ones. To find the centroid of breps and more complex polygons you have to use other methods.
Another option for non-planar curves:

Hi I am currently working a lot with center-points of srfs. Anyone found out a way to just get the centroid without calculating the areas/volumes so far?

super effective. thanks!

by Akira

• View All