def _compute_lineline_intersection(line1_pt1, line1_pt2,
                                    line2_pt1, line2_pt2):
    """Algorithm to compute a line to line intersection, where the
    two lines are both defined by two points. Based on this article:
        https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection

    :param line1_pt1: First point on first line
    :type line1_pt1: tuple
    :param line1_pt2: First point on first line
    :type line1_pt2: tuple
    :param line2_pt1: First point on first line
    :type line2_pt1: tuple
    :param line2_pt2: First point on first line
    :type line2_pt2: tuple
    :return: intersection point (p_x, p_y), if it exists
    :rtype: tuple or None
    """
    (x1, y1) = line1_pt1
    (x2, y2) = line1_pt2
    (x3, y3) = line2_pt1
    (x4, y4) = line2_pt2

    # Check for parallel lines
    denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)

    if denominator == 0:
        return None

    p_x = ((x1*y2 - y1*x2) * (x3 - x4) - (x1 - x2) * (x3*y4 - y3*x4)) \
            / denominator
    p_y = ((x1*y2 - y1*x2) * (y3 - y4) - (y1 - y2) * (x3*y4 - y3*x4)) \
            / denominator
    return (p_x, p_y)