@ Pure public static double distanceSquaredSegmentPoint ( double sx1 , double sy1 , double sz1 , double sx2 , double sy2 , double sz2 , double px , double py , double pz ) { double ratio = getPointProjectionFactorOnSegmentLine ( px , py , pz , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; if ( ratio <= 0. ) return FunctionalPoint3D . distanceSquaredPointPoint ( px , py , pz , sx1 , sy1 , sz1 ) ; if ( ratio >= 1. ) return FunctionalPoint3D . distanceSquaredPointPoint ( px , py , pz , sx2 , sy2 , sz2 ) ; return FunctionalPoint3D . distanceSquaredPointPoint ( px , py , pz , ( 1. - ratio ) * sx1 + ratio * sx2 , ( 1. - ratio ) * sy1 + ratio * sy2 , ( 1. - ratio ) * sz1 + ratio * sz2 ) ; }
Compute and replies the perpendicular squared distance from a point to a segment .