def on_segment(p, q, r):
    """
    Checks to see if given three collinear points p, q, r, the function checks if
    point q lies on line segment 'pr'.

    p: First endpoint of line 'pr' described by a tuple.
    q: Point being tested described by a tuple.
    r: Second endpoint of line 'pr' described by a tuple.

    return: True if the point is in collision with tuple and False otherwise.
    """
    
    if ((q[0] <= max(p[0], r[0])) &
        (q[0] >= min(p[0], r[0])) &
        (q[1] <= max(p[1], r[1])) &
        (q[1] >= min(p[1], r[1]))):
        return True

    return False