Suppose there is a given cube and a point outside of that cube. Now I want to find out the point on the cube with the least distance to the point outside of the cube.
I have found a similar post: Minimal distance to a cube in 2D and 3D from a point lying outside
But I am not interested in the distance value itself, I want to know the position of the point on the cube that satisfies the nearest distance.
Here also the image from the post above. The point p
is the outside point and r
is the minimal distance to the cube. But I am interested in the point at the end of r
on the cube.
And also follow up question, is there an efficient way to generalize and calculate this for n
-dimension hypercube?