Grasshopper

algorithmic modeling for Rhino

I wa wondering if anyone could explain the mathematical method Grasshopper applies for calculating the centroid of a surface/curve, I'm aware that the Polygon Center component uses the average of the vertices and or the average of the edges to calculate the center of a polygonal curve, but I'd like to understand the method it uses to calculate the centroid of an irregular planar curve/srf in the Area Component.

Thank a lot.

Views: 1934

Replies to This Discussion

I had several centroid (not to mention ...er...umbrella sticks[don't ask] stuff) related examples just for fun (polys, curves, cats, dogs, whatever comes first) ... but a recent major crash (in 2 workstations simultaneously: Karma, what else?) caused "some" MIA stuff, he he.

Until I'll fix(?) things(???) get this polygon related thingy that explains the approach (obviously you should "read" the code).

PS: test polys are internalized (I do hope that GH  ... blah, blah).

best, Peter

Attachments:

It uses the Rhino SDK methods, and I'm afraid I don't know the methodology they took, though you can try asking on our discourse forum where the Rhino programmers hang out.

Curves are converted to single face breps for area calculations, but the polygon centroid component (which is way faster) calculates three kinds of centroid:

  • Average of all the vertices (excluding the last vertex which is coincident with the first one for closed polylines).
  • Weighted average of all the edge centres, where the edge length counts as the weight.
  • Actual area centroid from edge triangles. This one only works if the polygon is planar though.

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service