def from_linearized(first, second, intersections):
    """Determine curve-curve intersection from pair of linearizations.

    .. note::

       This assumes that at least one of ``first`` and ``second`` is
       not a line. The line-line case should be handled "early"
       by :func:`check_lines`.

    .. note::

       This assumes the caller has verified that the bounding boxes
       for ``first`` and ``second`` actually intersect.

    If there is an intersection along the segments, adds that intersection
    to ``intersections``. Otherwise, returns without doing anything.

    Args:
        first (Linearization): First curve being intersected.
        second (Linearization): Second curve being intersected.
        intersections (list): A list of existing intersections.

    Raises:
        ValueError: If ``first`` and ``second`` both have linearization error
            of ``0.0`` (i.e. they are both lines). This is because this
            function expects the caller to have used :func:`check_lines`
            already.
    """
    # NOTE: There is no corresponding "enable", but the disable only applies
    #       in this lexical scope.
    # pylint: disable=too-many-return-statements
    s, t, success = segment_intersection(
        first.start_node, first.end_node, second.start_node, second.end_node
    )
    bad_parameters = False
    if success:
        if not (
            _helpers.in_interval(s, 0.0, 1.0)
            and _helpers.in_interval(t, 0.0, 1.0)
        ):
            bad_parameters = True
    else:
        if first.error == 0.0 and second.error == 0.0:
            raise ValueError(_UNHANDLED_LINES)

        # Just fall back to a Newton iteration starting in the middle of
        # the given intervals.
        bad_parameters = True
        s = 0.5
        t = 0.5
    if bad_parameters:
        # In the unlikely case that we have parallel segments or segments
        # that intersect outside of [0, 1] x [0, 1], we can still exit
        # if the convex hulls don't intersect.
        if not convex_hull_collide(first.curve.nodes, second.curve.nodes):
            return

    # Now, promote ``s`` and ``t`` onto the original curves.
    orig_s = (1 - s) * first.curve.start + s * first.curve.end
    orig_t = (1 - t) * second.curve.start + t * second.curve.end
    refined_s, refined_t = _intersection_helpers.full_newton(
        orig_s, first.curve.original_nodes, orig_t, second.curve.original_nodes
    )
    refined_s, success = _helpers.wiggle_interval(refined_s)
    if not success:
        return

    refined_t, success = _helpers.wiggle_interval(refined_t)
    if not success:
        return

    add_intersection(refined_s, refined_t, intersections)
def from_linearized ( first , second , intersections ) : s , t , success = segment_intersection ( first . start_node , first . end_node , second . start_node , second . end_node ) bad_parameters = False if success : if not ( _helpers . in_interval ( s , 0.0 , 1.0 ) and _helpers . in_interval ( t , 0.0 , 1.0 ) ) : bad_parameters = True else : if first . error == 0.0 and second . error == 0.0 : raise ValueError ( _UNHANDLED_LINES ) bad_parameters = True s = 0.5 t = 0.5 if bad_parameters : if not convex_hull_collide ( first . curve . nodes , second . curve . nodes ) : return orig_s = ( 1 - s ) * first . curve . start + s * first . curve . end orig_t = ( 1 - t ) * second . curve . start + t * second . curve . end refined_s , refined_t = _intersection_helpers . full_newton ( orig_s , first . curve . original_nodes , orig_t , second . curve . original_nodes ) refined_s , success = _helpers . wiggle_interval ( refined_s ) if not success : return refined_t , success = _helpers . wiggle_interval ( refined_t ) if not success : return add_intersection ( refined_s , refined_t , intersections )
Determine curve-curve intersection from pair of linearizations.

    .. note::

       This assumes that at least one of ``first`` and ``second`` is
       not a line. The line-line case should be handled "early"
       by :func:`check_lines`.

    .. note::

       This assumes the caller has verified that the bounding boxes
       for ``first`` and ``second`` actually intersect.

    If there is an intersection along the segments, adds that intersection
    to ``intersections``. Otherwise, returns without doing anything.

    Args:
        first (Linearization): First curve being intersected.
        second (Linearization): Second curve being intersected.
        intersections (list): A list of existing intersections.

    Raises:
        ValueError: If ``first`` and ``second`` both have linearization error
            of ``0.0`` (i.e. they are both lines). This is because this
            function expects the caller to have used :func:`check_lines`
            already.