Finding centroid of wavy enclosed curved pieces

I’m struggling to find centroid of these pieces which lies inside the enclosed curves. How can I do it?


Not sure these are OK for the term centroid with them.


1 Like

Indeed that’s not the centroid. In any case, given the opportunity - general case - for any BrepFace the point (called sometimes visual center) is approximated via a Quad/OctTree (derived at start from a Bbox per Face and then recursively sub divided).

Hi @archz2

It sounds like you’re after what is also sometimes known as the ‘pole of inaccesibility’

This has come up before in this thread, though I think there wasn’t a working general solution posted then.

I had a look at the open source library Polylabel that @gankeyu mentioned there…
and saw also this conversion to C#

(this is using the same subdivided grid approach that @PeterFotiadis mentions)

With just a few little changes it works in Grasshopper: (8.7 KB)


Indeed … but is not the Jack for all trades. See so-so results VS the spagetti Crvs (to Polylines)

Plus … hmm …

1 Like

Note the tolerance setting. 0.15 like you show is much too high

Indeed that code doesn’t support shapes with holes though. I didn’t look at how much change it would need for this.

1 Like

Ah, it looks like the library already supports shapes with holes.
So it was just a matter of changing the input arrays
image (12.0 KB)

1 Like

This is going to make my cnc layout definisions so much more robust. Thank you so much.

1 Like

For this example you can use Quadremesh to find the center point or HB straight skeleton from Honeybee addon (55.9 KB)


:thinking: Somehow I have zero memory of having replied to that topic… This feels so weird.

1 Like

Still … result doesn’t “look” like a visual center (whatever this means anyway).

1 Like

Yes, this finds the centre of the largest circle.
In some special cases with perfect offsets or parallel lines this largest circle might not be unique though.
For a rectangle anywhere along the long branch of the medial axis satisfies this as these circles are all equal radius.

and if you have any slight bumps it could be far from what intuitively feels like the ‘visual centre’

So if you know the input consists only of constant width strips, an approach like the ones @HS_Kim or @seghierkhaled proposed might be best.

Otherwise perhaps adding a small weighting towards the actual centroid of the shape could help make it less sensitive to bumps and choose among the possible answers for degenerate cases like the rectangle.

1 Like

Well … get another stupid(*) way to cut(?) the mustard (if it makes any sense at all, but anyway). (54.8 KB)

(*) or very stupid.

1 Like

This idea using Kangaroo physics (10.5 KB)


beautiful approach!!


Thanks a lot. This did it. Actually I wanted to find the centre point in order to place the engraved number tags for fabricating these pieces. This script did the job.

@everyone! Thanks a lot for digging soooo deep! I never thought a seemingly simple query of mine would result in such intense discussion from forum OGs!. :raised_hands: :raised_hands: :raised_hands: :raised_hands: