Grouping grid points based on voronoi cells

I have grid of points and I want to be able to group the points depending on which cell of a voronoi diagram they are inside of.

The only way I’ve managed to get it to work is by projecting the point on to a surface created from the cell outline and sorting the points based on the intersection.

The problem is this method is extremely slow.

I am sure I’m missing something, is there a more efficient way of solving this?

Cheers

Voronoi-grid-groups.gh (13.1 KB)

1 Like

Faster when using the Point In Curves component.

240421a_Voronoi-grid-groups.gh (16.0 KB)

Here’s another option using Surface Split, that’s a litter bit faster.

240421b_Voronoi-grid-groups.gh (19.4 KB)

-Kevin

2 Likes

consider that a Voronoi diagram is a partitioning of space where each cell represents the locations closest to that particular Point that generates the cell itself

so, even without using the Voronoi component (which draws the cell outlines) you can Closest Point your grid to the Points you are Voronoi-ing

here the Voronoi component is just disabled :slight_smile: and it’s pretty fast:

Voronoi-grid-groups_inno.gh (16.8 KB)

4 Likes

with that logic, you’s assume that Closest Point Calculation with RTree gives same result, and is superfast. (not behind pc with gh to test it now)

if I had to guess, probably Rhino.Collection.Point3dList.ClosestIndex not RTree

by the way, both Rhino.Collection.Point3dList.ClosestIndex and Closest Point output the very same indexes values :+1:

which of course are the same indexes of the Voronoi cells curves

I knew I was missing something! Of course! By nature of the voronoi diagram the closest point to the cell centroid means it belongs to that cell, silly me! I had just assumed that in some edge cases it might not be.

Thank you so much for your help inno, I can continue on with the project now that my computer isn’t grinding to a halt. From the screenshot it looks like your computer also calculates the solution twice as fast as mine, which means I’m so long overdue for an upgrade.

This community is the best.
Cheers

1 Like

I’m on an alienware laptop from 2019 :smiley: but the i7-9700K still does its job :+1:

1 Like