Issue with Colouring Mesh Based on Face Distance to Point Cloud

Hello,

I have mesh that I need to apply a colour gradient to.

The colour for each face will be determined as a function of the distance between the centre of the face and the closest point in a cloud of points.

I can do all this, but my results are wrong.

Indeed, in parallel, I have also coloured a grid of points by applying the same gradient. Points at position similar to the mesh should then be of a relatively similar colour. As you can see on the following pictures, that is not the case.

I hope you can help me.



Intern.gh (509.0 KB)

I find my mistake