@ Pure @ Unefficient public static double distanceSquaredTriangleSegment ( double tx1 , double ty1 , double tz1 , double tx2 , double ty2 , double tz2 , double tx3 , double ty3 , double tz3 , double sx1 , double sy1 , double sz1 , double sx2 , double sy2 , double sz2 ) { double t = getTriangleSegmentIntersectionFactorWithJimenezAlgorithm ( tx1 , ty1 , tz1 , tx2 , ty2 , tz2 , tx3 , ty3 , tz3 , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; if ( Double . isInfinite ( t ) || ( ! Double . isNaN ( t ) && t >= 0. && t <= 1. ) ) { return 0. ; } double d1 = AbstractSegment3F . distanceSquaredSegmentSegment ( tx1 , ty1 , tz1 , tx2 , ty2 , tz2 , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; double d2 = AbstractSegment3F . distanceSquaredSegmentSegment ( tx1 , ty1 , tz1 , tx3 , ty3 , tz3 , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; double d3 = AbstractSegment3F . distanceSquaredSegmentSegment ( tx2 , ty2 , tz2 , tx3 , ty3 , tz3 , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; return MathUtil . min ( d1 , d2 , d3 ) ; }
Replies the squared distance from the triangle to the segment .