This Demonstration finds the point on a trefoil knot that is the closest to a given point in 3D. Trefoils are the simplest nontrivial knot, and one is used here as an example of a space curve. The Slider2D on the left controls the Locator in the - plane, while the elevation ( coordinate) of the point is controlled by the VerticalSlider on the far right.
You can switch the tube form of the trefoil off to see only the knot's space curve; this is faster. The shortest distance is indicated in magenta. Three extra rays on each side are shown for better visibility; unchecking "extra rays" turns them off.