Finding the point closest to a parameteric curve produced by a numerical method

nF = RegionNearest[Cases[simplexPlot, _Line, All][[1]]];
pnt = {2, 2, 2};
npnt = nF @ pnt

{4.56162,6.16536,10.9321}

EuclideanDistance[pnt, nF@pnt]

10.1831

Show[simplexPlot, 
 Graphics3D[{Red, Sphere[pnt, .2], Green, Sphere[npnt, .2], 
   Gray, Dashed, Arrow[{pnt, npnt}]}]]

enter image description here


It seems like the most straightforward way to handle this is to just use NMinimize directly on the norm. I do this here by defining a function to by find the t value which minimizes the distance between the function and the point:

nearestT[f_, pt_, tmin_, tmax_] := 
  Module[{t}, 
   t /. NMinimize[{Norm[f[t] - pt], tmin <= t, t <= tmax}, t][[2]]
  ];

And then subsequently a function which inserts that t value back into the original function to find the nearest point on the curve:

nearestPt[f_, pt_, tmin_, tmax_] := f[nearestT[f, pt, tmin, tmax]];

For gCurve, this is used as:

{nearestT[gCurve, {2, 2, 2}, 0, tmax], nearestPt[gCurve, {2, 2, 2}, 0, tmax]}

{12.9809, {4.25274, 6.24997, 10.07}}

If it's too slow and you suspect that gCurve will be relatively well behaved with regards to the point you're minimizing at, you may wish to use FindMinimum instead. However, FindMinimum does not make nearly as many attempts to find global minima, so it may not always provide the best answer.