I am trying to blend the nearby weights of voronoi cells

in this example all cell centers are at 0.5, 0.5 for simplicity's sake, and to show the error more clearly

I have tried for a day now to figure out what mistake I'm making, but i just dont understand what I'm doing wrong here

First: I find the N closest points (determined by WEIGHTS)

then I use the longest distance as the "normalizing value" all the way to the end

finally i divide by the total length of the inverted distances (so that the closest point has the strongest weight)

by listening to my brain, this should be working, but it doesn't seem like it's working alright.. :S

Please help!

Note: if you want me to recreate the function in C, that can be arranged since it's not an issue for me..

Here are some example images for 3,4 and 9 weights, first with center at (0.5, 0.5) then with centers at the respective cells for a total of 6 images:

http://art.fwsnet.net/vor/w3c.png

http://art.fwsnet.net/vor/w4c.png

http://art.fwsnet.net/vor/w9c.png

http://art.fwsnet.net/vor/w3.png

http://art.fwsnet.net/vor/w4.png

http://art.fwsnet.net/vor/w9.png

**Edited by Kaptein, 02 November 2012 - 09:29 PM.**