Watch and enjoy! :) Feel free to see inside, or just mess around with the variables. To reduce lag: https://sulfurous.aau.at/#199028733 Clustering: how often points cluster together vs. being random. Num Areas: number of regions to divide the points into. Num Points: number of points to divide up.
This will contribute to my Color Quantization NPR project since it is a way to divide a picture's colors into sets with similar colors in each. The way k-means clustering works is that you start by adding k random centers that will represent the clusters. Each time, you make a voronoi diagram out of the centers (a diagram that colors each point based on the closest center, look it up if you need more info). Then, take the average position of each point in a given cluster and set the center to that average. Over enough iterations, the points should be arranged into k clusters. Maybe it's just my computer, but this runs surprisingly smoothly for 1000+ points and several areas!