# Differential equation for finding closest point on surface.

Inspired by this question I got to think about a more general case. Say I have any discretized surface and want to find closest point from each point outside of surface to the surface. Say that I can estimate a local tensor for the local tangent space and normal space. Can I create a differential equation to encode with a vector field which optimally points out trajectories to go from each point and end up on a point on the surface of the object which would be the closest point?

Because your surface is discretized, it is a polyhedron. Then you have an exterior point $a$, and you seek $b$ on the polyhedron that is closest to $a$, i.e., which minimizes the distance $|ab|$. This can be formulated as a quadratic programming problem, for which there are many algorithms.

For example, the GJK algorithm is often used:

E. G. Gilbert, D. W. Johnson, and S. S. Keerthi, "A fast procedure for computing the distance between complex objects in three dimensional space", IEEE J. Robot. Automat., vol. 4, pp.193-203. 1988 (PDF download)

So, I think the essence here is not a differential equation, but rather a quadratic equation that must be minimized.

• Thanks a lot for the input. I was stuck in an old way of thinking. Jul 10, 2015 at 13:04

Ok, so I thought I could post what I got stuck on thinking about.

Two rectangular objects in the image below. We want to find shortest distance from any other point to the objects' boundaries. We calculate vectors along the boundaries which are gradients i.e. in the direction normal to the surface. If we fix these vectors as boundary conditions and then try and optimize some local cost function for all the other points. Here is a small experiment. We can for instance try to minimize the gradient of the field. This is what happens if we try that: So the basic idea is that if we follow the arrows we will end up on the closest point on the boundary. We see that minimizing the $L_2$ norm of the gradient really may not be what exactly what we should be doing, although it is not entirely off either. Here is a color coded version of the image. Notice how the boundary condition "reaches out" and causes the surrounding data points to "glow": 