def _is_on_line(x, y, ax, ay, bx, by):
    """
    Check if point `x`/`y` is on the line segment from `ax`/`ay` to `bx`/`by`
    or the degenerate case that all 3 points are coincident.

        >>> _is_on_line(0.5, 0.5, 0.0, 0.0, 1.0, 1.0)
        True

        >>> _is_on_line(0.0, 0.0, 0.0, 0.0, 1.0, 1.0)
        True

        >>> _is_on_line(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
        True

        >>> _is_on_line(0.0, 0.5, 0.0, 0.0, 1.0, 1.0)
        False

        >>> _is_on_line(0.5, 0.0, 0.0, 0.0, 1.0, 1.0)
        False

    """
    return ((bx - ax) * (y - ay) == (x - ax) * (by - ay) and
            ((ax <= x <= bx or bx <= x <= ax) if ax != bx else
             (ay <= y <= by or by <= y <= ay)))