def _update_parameters(s_min, s_max, start0, end0, start1, end1): """Update clipped parameter range. .. note:: This is a helper for :func:`clip_range`. Does so by intersecting one of the two fat lines with an edge of the convex hull of the distance polynomial of the curve being clipped. If both of ``s_min`` and ``s_max`` are "unset", then any :math:`s` value that is valid for ``s_min`` would also be valid for ``s_max``. Rather than adding a special case to handle this scenario, **only** ``s_min`` will be updated. In cases where a given parameter :math:`s` would be a valid update for both ``s_min`` and ``s_max`` This function **only** updates ``s_min`` Args: s_min (float): Current start of clipped interval. If "unset", this value will be ``DEFAULT_S_MIN``. s_max (float): Current end of clipped interval. If "unset", this value will be ``DEFAULT_S_MAX``. start0 (numpy.ndarray): A 1D NumPy ``2``-array that is the start vector of one of the two fat lines. end0 (numpy.ndarray): A 1D NumPy ``2``-array that is the end vector of one of the two fat lines. start1 (numpy.ndarray): A 1D NumPy ``2``-array that is the start vector of an edge of the convex hull of the distance polynomial :math:`d(t)` as an explicit B |eacute| zier curve. end1 (numpy.ndarray): A 1D NumPy ``2``-array that is the end vector of an edge of the convex hull of the distance polynomial :math:`d(t)` as an explicit B |eacute| zier curve. Returns: Tuple[float, float]: The (possibly updated) start and end of the clipped parameter range. Raises: NotImplementedError: If the two line segments are parallel. (This case will be supported at some point, just not now.) """ s, t, success = geometric_intersection.segment_intersection( start0, end0, start1, end1 ) if not success: raise NotImplementedError(NO_PARALLEL) if _helpers.in_interval(t, 0.0, 1.0): if _helpers.in_interval(s, 0.0, s_min): return s, s_max elif _helpers.in_interval(s, s_max, 1.0): return s_min, s return s_min, s_max
def _update_parameters(s_min, s_max, start0, end0, start1, end1): """Update clipped parameter range. .. note:: This is a helper for :func:`clip_range`. Does so by intersecting one of the two fat lines with an edge of the convex hull of the distance polynomial of the curve being clipped. Args: s_min (float): Current start of clipped interval. If "unset", this value will be ``DEFAULT_S_MIN``. s_max (float): Current end of clipped interval. If "unset", this value will be ``DEFAULT_S_MAX``. start0 (numpy.ndarray): A 1D NumPy ``2``-array that is the start vector of one of the two fat lines. end0 (numpy.ndarray): A 1D NumPy ``2``-array that is the end vector of one of the two fat lines. start1 (numpy.ndarray): A 1D NumPy ``2``-array that is the start vector of an edge of the convex hull of the distance polynomial :math:`d(t)` as an explicit B |eacute| zier curve. end1 (numpy.ndarray): A 1D NumPy ``2``-array that is the end vector of an edge of the convex hull of the distance polynomial :math:`d(t)` as an explicit B |eacute| zier curve. Returns: Tuple[float, float]: The (possibly updated) start and end of the clipped parameter range. Raises: NotImplementedError: If the two line segments are parallel. (This case will be supported at some point, just not now.) """ s, t, success = geometric_intersection.segment_intersection( start0, end0, start1, end1) if not success: raise NotImplementedError(NO_PARALLEL) # NOTE: We can only **widen** the interval with a real intersection. # I.e. we can push the minimum to the left or the maximum to the # right. if _helpers.in_interval(t, 0.0, 1.0): if _helpers.in_interval(s, 0.0, s_min): s_min = s if _helpers.in_interval(s, s_max, 1.0): s_max = s return s_min, s_max