44 G4double sq_VecAZ, inner_prod, unit_projection ;
46 VecAZ= OtherPnt - EndpointA;
47 sq_VecAZ = VecAZ.
mag2();
49 inner_prod= VecAtoB.
dot( VecAZ );
53 if( fABdistanceSq != 0.0 )
56 unit_projection = inner_prod/fABdistanceSq;
58 if( (0. <= unit_projection ) && (unit_projection <= 1.0 ) )
60 dist_sq= sq_VecAZ - unit_projection * inner_prod ;
67 if( unit_projection < 0. )
75 dist_sq = VecBZ.
mag2();
81 dist_sq = (OtherPnt - EndpointA).mag2() ;
88 return std::sqrt(dist_sq) ;