def CheckLineIntersection(x1, y1, x2, y2, x3, y3, x4, y4):
    """
    Check for line intersection

    :param `x1`: x1 position
    :param `y1`: y1 position
    :param `x2`: x2 position
    :param `y2`: y2 position
    :param `x3`: x3 position
    :param `y3`: y3 position
    :param `x4`: x4 position
    :param `y4`: y4 position

    :returns: a lenght ratio and a k line???

    """
    denominator_term = (y4 - y3) * (x2 - x1) - (y2 - y1) * (x4 - x3)
    numerator_term = (x3 - x1) * (y4 - y3) + (x4 - x3) * (y1 - y3)
    length_ratio = 1.0
    k_line = 1.0
    if denominator_term < 0.005 and denominator_term > -0.005:
        line_constant = -1.0
    else:
        line_constant = float(numerator_term) / denominator_term
    if line_constant < 1.0 and line_constant > 0.0:
        if y4 - y3 < 0.005 and y4 - y3 > -0.005:
            k_line = (x1 - x3 + line_constant * (x2 - x1)) / (x4 - x3)
        else:
            k_line = (y1 - y3 + line_constant * (y2 - y1)) / (y4 - y3)
        if k_line >= 0 and k_line < 1:
            length_ratio = line_constant
        else:
            k_line = 1
    return length_ratio, k_line
