I have seen the hill-climbing approach used in this forum and I think its a good approach for a lot of code I write.
I thought it would be good to write wrapper recursive functions for linear, 2d and 3d hill climbing that look for the best approximate result.
Example linear wrapper function that would would find the approximate nearest point on a pollyine would take these arguments,
a function that results in a number value eg. '(lambda (dist) (distance pt (vlax-curve-getPointAtDist en dist)))
a sorting function '< (looking for the lowest value or shortest distance)
a maximum number of repetitions 50
and a minimum tolerance/ error value 0.01
min search value 0
max search value (vlax-curve-getdistatparam en (vlax-curve-getendparam en))
The wrapper would then try different distances along the polyline looking for the one with the lowest value (closest point) and then recursively try new points close to the nearest point found until the maximum number of repetitions have been reach, or our search distance is less than the minimum tolerance/ error value.
The result would be the distance along the polyine to the closest point.
How would you go about this.
I hope my idea is clear.
Cheers, Rod.