intersection

emlib.mathlib.intersection(u1, u2, v1, v2)[source]

return the intersection of (u1, u2) and (v1, v2) or None if no intersection

Parameters:
  • u1 (TypeVar(T, float, Fraction)) – lower bound of range U

  • u2 (TypeVar(T, float, Fraction)) – higher bound of range U

  • v1 (TypeVar(T, float, Fraction)) – lower bound of range V

  • v2 (TypeVar(T, float, Fraction)) – higher bound of range V

Return type:

tuple[Optional[TypeVar(T, float, Fraction)], TypeVar(T, float, Fraction)]

Returns:

the intersection between range U and range V as a tuple (start, end). If no intersection is found, start will be None.

Example:

>>> x0, x1 = intersection(0, 3, 2, 5)
>>> if x0 is not None:
...     # there is an intersection