Competitive Programing Problem Solutions/Geometry/test (2).cpp
double DistToLineSegment(PT p, PT A, PT B){
    PT c;
    if(dot(B-A,p-A)<eps) return dist2D(p, A);
    if(dot(A-B,p-B)<eps) return dist2D(p, B);
    return DistToLine(p, A, B);
}
/// Computes minimum distance from a point 'p' to a line segment 'AB'

Computes minimum distance from a point 'p' to a line segment 'AB'
Computes minimum distance from a point ' p ' to a line segment ' AB '
double DistToLineSegment(PT p, PT A, PT B){
    PT c;
    if(dot(B-A,p-A)<eps) return dist2D(p, A);
    if(dot(A-B,p-B)<eps) return dist2D(p, B);
    return DistToLine(p, A, B);
}
double DistToLineSegment ( PT p , PT A , PT B ) { PT c ; if ( dot ( B - A , p - A ) < eps ) return dist2D ( p , A ) ; if ( dot ( A - B , p - B ) < eps ) return dist2D ( p , B ) ; return DistToLine ( p , A , B ) ; }
Computes minimum distance from a point 'p' to a line segment 'AB'
Computes minimum distance from a point ' p ' to a line segment ' AB '