Find closest point on surface interpolated by 2d matrix of points I have rectangular matrix of 3d points sampled from a parametric surface. In my program this matrix provides base points for bilinear interpolation of surface (In any (u,v) point it returns 3d point interpolated from neighboring sampled values). Now I want to find closest point on surface from any other point in 3d space, considering values "between" sampled points of grid.

I'll attach picture with example on 2d curve. Here yellow points are sampled points, red point - point to which we want to find closest, and green - point which we need to find as closest (witness point).
This is only a rough idea, though I hope it may inspire better answers.

The closest point on a surface is as far as I know always forms together with the red point a line that is orthogonal to the surface.

If you know which yellow vertices form the surface that the green point lies on, this is easy. You could just formulate the normal form of the surface (which is piecewise linear so it works out) formulate the orthogonal line to the surface that goes through the red point and solve for the intersection point. Though I don't have the exact math here, this step should be easy to look up.

Now the problem is: Which linear piece of your surface is the closest one.
Either you calculate the green-point candidates for all linear pieces and also the distance and take the closest one, or you find some other possibly faster way for this.
For that I don't have a more clever idea.