Given three colinear points p , q , r , the function checks if point q lies on line segment ' pr '
def onSegment ( p , q , r ) : NEW_LINE INDENT if ( ( q . x <= max ( p . x , r . x ) ) and ( q . x >= min ( p . x , r . x ) ) and ( q . y <= max ( p . y , r . y ) ) and ( q . y >= min ( p . y , r . y ) ) ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT def orientation ( p , q , r ) : NEW_LINE