Competitive Programing Problem Solutions/Geometry/test (2).cpp
double DistToLine(PT p, PT A, PT B){
    double scale=dot(p-A,B-A)/dot(B-A,B-A);
    PT c;
    c.x=A.x+scale*(B.x-A.x);
    c.y=A.y+scale*(B.y-A.y);
    return dist2D(p, c);
}
/// Computes minimum distance from a point 'p' to a line 'AB'

Computes minimum distance from a point 'p' to a line 'AB'
Computes minimum distance from a point ' p ' to a line ' AB '
double DistToLine(PT p, PT A, PT B){
    double scale=dot(p-A,B-A)/dot(B-A,B-A);
    PT c;
    c.x=A.x+scale*(B.x-A.x);
    c.y=A.y+scale*(B.y-A.y);
    return dist2D(p, c);
}
double DistToLine ( PT p , PT A , PT B ) { double scale = dot ( p - A , B - A ) / dot ( B - A , B - A ) ; PT c ; c . x = A . x + scale * ( B . x - A . x ) ; c . y = A . y + scale * ( B . y - A . y ) ; return dist2D ( p , c ) ; }
Computes minimum distance from a point 'p' to a line 'AB'
Computes minimum distance from a point ' p ' to a line ' AB '