i want to find the shortest line segment between to line segments, i’ve already calculated the shortest line segments between 2 infinite lines, but this is not excactly what i want
Paul
i want to find the shortest line segment between to line segments, i’ve already calculated the shortest line segments between 2 infinite lines, but this is not excactly what i want
Paul
You probably have the ‘u’ value (of both lines) of the intersection (2d) or smallest distance (3d), so if ‘u’ is less than 0 or more than line-segment-length, clamp ‘u’ to those values. Then recalculate the points with the new ‘u’ values.
Alternatively, this method is very useful: http://java.sun.com/j2se/1.5.0/docs/api/java/awt/geom/Line2D.html#ptSegDist(java.awt.geom.Point2D)
It gives you the distance from a point to an interval, so find the dist from one interval to each of the other interval’s end points and take the smallest one.
By the way, the distance between two infinite lines that aren’t parallel must be zero since they must cross.
Keith