nortikin / sverchok

Sverchok
http://nortikin.github.io/sverchok/
GNU General Public License v3.0
2.26k stars 233 forks source link

weighted voronoi diagrams #4405

Open Sinasta opened 2 years ago

Sinasta commented 2 years ago

I would like to know if there is any way to divide a surface into a weighted voronoi. More precisely i would like to have control over the surface of the different cells which could maybe be done by adding a weight or radius to the site vertex. Would this be possible somehow?

summereasy commented 2 years ago

Sorry, I am a bit confused. So, you have a dataset for each of every vertex of a Surface, and you want to inject those data into Vertex Weights or something else, am I right?

Sinasta commented 2 years ago

I am sorry if i did not state my question correctly. As far as i understood the Voronoi lines are drawn be calculating the mean distance between each point. What i would like to be able to is to have an influance over the weight ( or in other word radius) of each of those points. In application this would mean if all the points have the same weight(radius) except one with a bigger weight, the created voronoi cell's surface of this point would be bigger than if it would have the same weight as the others.

image

Sinasta commented 2 years ago

I guess this Wikipedia article describes it better: https://en.wikipedia.org/wiki/Weighted_Voronoi_diagram

Sinasta commented 2 years ago

or this: https://en.wikipedia.org/wiki/Power_diagram https://github.com/Kcnarf/d3-weighted-voronoi

Sinasta commented 2 years ago

image

summereasy commented 2 years ago

Oh, I see. Thanks for the information.

So, based on what you've stated above, I think you should take a look at Voronoi on Mesh Node.

Does that fit your needs?

Sinasta commented 2 years ago

Yes i am using Voronoi on mesh (well Voronoi on solid because Voronoi on mesh creates overlapping faces sometimes). How are you able to do weighted Voronoi diagrams with the Voronoi on mesh Node. Maybe I am missing something.

Sinasta commented 2 years ago

This here is probably the closest example to what i am looking for: https://youtu.be/wKfIddiuG58?t=75 https://github.com/DanielAbalde/PowerDiagrams image

summereasy commented 2 years ago

OK. I see. I didn't look closely. I used to think the "Voronoi on Mesh" node has controls over Weight, But clearly, it doesn't. So... I think the best way to do it may be the "sn-lite" node : )

Durman commented 2 years ago

Here is my solution. The idea is to use slice of 3D dimensional Voronoi diagram with Z dimension as weight.

test.zip

image

Sinasta commented 2 years ago

Thank you very much for your answer. Coincidently i found out yesterday that a unweighted Voronoi of N-dimensions is a weighted diagram of N-1 dimension which makes a lot of sens. Somehow it would still be nice if weights could be implemented in the Voronoi node (But this would probably need a switch from Scipy to Cgal). Anyhow the 2d to 3d will do the trick for now. This will only get a problem as soon as somebody needs a weighted 3D Voronoi.

portnov commented 2 years ago

Scipy supports n-dimensional voronoi. Just need to try...

Sinasta commented 2 years ago

That's great. I will see if i figure out a way to weight 3D Voronois. By the way for those that will use this method: For me it seems that there is no need to bisect the Voronoi if you use 2D Voronoi instead of 3D Voronoi node.

satabol commented 1 year ago

Yes i am using Voronoi on mesh (well Voronoi on solid because Voronoi on mesh creates overlapping faces sometimes).

Hi @Sinasta. Nodes "Voronoi on Mesh" and "Voronoi on Solid" are fixed now. Can you try them if you are using sverchok? You can use any configuration of sites: lines, planes, circles, spheres without restrictions.

satabol commented 1 year ago

Update for the future: http://www.qhull.org/ image So it is not possible realize weighted Voronoi with scipy.spatial.Voronoi (it use qhull). Need something another or some tricks...