# Fast - Find centroid of surface component

Hi,

Question, to find the centroid of surfaced I use the ‘Area’ compon.
Unfortunately this component becomes quite slow if there are alot of surfaces…

Does anybody know a faster component / or python script to find the centroids faster?

2023-05-18 centroid of surface - faster compont.gh (101.6 KB)

Many thanks

How about the Eval Surface component? Feed the surface in as input, right click " reparameterize". For the UV input feed in a text panel “.5,.5” this will give you the center point as output.

This only works for that case (AreaMassProperties Centroid is NOT - in general - the same as Surface.PointAt (0.5, 0.5)).

Plus a thread safe // approach is NOT what most people believe (i.e. the holly Grail),

See attached (diffs are indeed BIG … but only for this case).

Parallel_SurfaceCentroids_V1.gh (208.2 KB)

Oh true I guess area centroid is more akin to evaluation of a bounding box center point. Where as a surface center point could be very different especially on a concave curved surface for example

Well … this problem is either a very fast one (in 0.0001% of cases) … or … er … the other thing.

Tip: get cigars + Tequila > let the idiot [i.e. the computer] count the beans.

BTW: Centroid (in general) has nothing to do with Box Center.

What method is utilized to find center typically? Asking out of curiosity and to learn

Better avoid that part. But if you insist Google: “center of mass for irregular 3D object” (i.e. the general case).

I hear you: Math.Exp(Yikes, Yikes);

2 Likes

It depends why you need a center. Evaluate surface at 0.5, 0.5, 0.5 is usually good enough. Depending how you generated your sutfaces you may need to right click the input node and choose reparametrize, which shifts fhe domain of a surface to (0 to 1) which hopefully also shifts their halfway point to the middle.

If you need a better middle but not as taxing as the area node you could consider extracting the boundary curve of your surface and finding the center of that polycurve. Curve math will be quicker than brep math. You might even consider rebuilding those curves as five or ten point polylines before finding their center. That math sounds quite quick, but could takr troubleshooting . Test some things on a subset of yoyr surfaces so you can iterate quickly.

You might also consider finding the 0.5 0.5 0.5 middle via eval surface and then use pull geometry so that your point is guaranteed to be on your surface. Like i said, depends on what you mean by middle and what youre doing with this middle. Edit: sorry if im reiterating pieces of answers peter gave, his answers are always spot on. Edit 2 lol i guess i just reiterated both the thread answers typed while on a bus and didnt read thoroughly (: