Given three colinear points p , q , r , the function checks if point q lies on line segment ' pr '
bool onSegment ( Point p , Point q , Point r ) { if ( q . x <= max ( p . x , r . x ) && q . x >= min ( p . x , r . x ) && q . y <= max ( p . y , r . y ) && q . y >= min ( p . y , r . y ) ) return true ; return false ; }