1

Let $x, y, z, a, b, c, d$ be vectors, and $t,s$ be scalars.

Let line segments be $y = a + bt, \ t \in [0,1]; \ \ z = c + ds, \ s \in [0,1]$.

The distance $d(z(s), y(t)) = \sqrt{(z(s)- y(t))\bullet (z(s) - y(t))}$. How do I minimize the distance and output two points one for each segment.

If there are an infinite number of solutions, make a "nice-looking" line between the segments, such that if they are paralell and form the sides of a rectangle, then the line is just the line that splits the rectangle. Then choose the output points to be the ends of this beautiful line.

Algorithm? How do I solve this? Calculus?

  • http://geomalgorithms.com/a07-_distance.html – amd Mar 20 '17 at 18:40
  • Also see http://math.stackexchange.com/questions/1188423, http://math.stackexchange.com/questions/210848, and http://math.stackexchange.com/questions/804995; after finding the nearest points on the extended lines, you apply the constraints of endpoints as explained in the answer to http://math.stackexchange.com/questions/846054/closest-points-on-two-line-segments – David K Mar 20 '17 at 18:46
  • 1
    Working with radicals can be painful. Fortunately, the extrema of $d$ are to be reached in the same points as the extrema of $d^2$, which allows you to get rid of the radical and have to solve a much simpler problem. – Alex M. Mar 20 '17 at 20:49

0 Answers0