Grasshopper

algorithmic modeling for Rhino

# K-Means clustering on meshes

This does K-Means clustering on meshes, similar to:

## [1] David Cohen-Steiner, Pierre Alliez, and Mathieu Desbrun. Variational
## shape approximation. ACM Transactions on Graphics, 23(3):905-
## 914, August 2004.

I know, this has been done a million times, and I'm not sure, but there are probably already scripts like this one on Grasshopper3d. Still someone asked for help, and I thought this might be useful.

I added the script as a gh (python) component and as a python module. Feel free to fiddle around with the code.

For a graphic description:

Views: 1569

Attachments:

### Replies to This Discussion

Cool! Thanks for sharing

No problem, just keep in mind that it was my first script. So be gentle :)

Great! Thank you!

Thank you, Jesus!

Very interesting work!

Cool

Thank you all. The Variational Shape Approximation paper was very well written, with very little to no guess work involved, so that made it easier. I forgot to mention its limitations:

• The algorithm works best with all the vertices in the mesh welded together (so for example in a cylinder, weld the vertices of the top and bottom planes with the sides). It was better to weld them with Gh's components and have it all streamlined there instead of doing it in Rhino.
• The paper used two metrics: an area-weighted normal metric and a covariant metric. This algorithm only uses the area-weighted normal, since I wasn't able to solve the eigenvalues of the covariant matrix using Python, and I couldn't get Numpy to work on Rhino x64.

Thank you!

• View All

## Videos

• ### INDEXLAB CONTINUING EDUCATION WORKSHOPS 2019.

Added by Carlo Beltracchi

• ### Grasshopper Tutorial (Parametric Architecture)

Added by Parametric House