Cluster Vector to Compute Average Vector


i have a grid (green lines) of lines and a cloud of points. Every Point has a vector with different lenght. My goal is to cluster the vectors and compute one vector with an average lenght within a face of the grid (blue arrows).

Any Ideas?
I attached the GH File.

Hendrik (59.5 KB)

1 Like

Step 1. Figure out for each region which vectors are inside of it.
Step 2. Remove all other vectors (per region).
Step 3. Compute the average of the remainder.

I didn’t have your lunchbox component, so I just created three circles instead. Nice is that you can manually drag them around so you can see the way it affects the average. (69.5 KB)

Pro-tip, you can just multiply numbers and vectors directly, no need to measure the length, multiply the length, then assign the new length.

Also note I scaled the display of the average vectors by a factor of 3 to make them more visible, remove that expression from the Vector Display input if you don’t want that.

1 Like

Or maybe this if i understood well what you need… (59.0 KB)


Thanks @Jakinta and @DavidRutten for the fast respone and the explanation of your GHfile.
I picked components of each of your Files and got the goal i wanted. Thanks!

In the next step i want to change the grid in the beginning dependig of the value of the average vector.
At those areas where there are vectors of higher value, group them in a bigger area. On the other side, compute smaller areas where the vectors are smaller.
Maybe there has to be a kangaroo solver?

I did a sketch but only for some areas and attached the Gh file (55.7 KB)

Maybe like this?
Note: You can manually construct domains. I have made 5 equal ones. (60.8 KB)

1 Like

Thanks for the answer, interesting view.

But what i meant is that the cells of the grids are changing their size depending on its vector lenght/value.
higher Value -> bigger cell
lower value -> smaller cell


That’s quite tricky, because as a cell grows larger it’ll contain more vectors which in turn may bring down the average in that cell. So you could end up with this infinite cycle of growing and shrinking if you’re not careful.

What shapes should these cells have? Voronoi diagram? Circle packing, subdivided rectangles? A deformed rectangular grid? Lots of questions now…

1 Like