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
, bound=Union
[Rational
,float
])) – lower bound of range Uu2 (
TypeVar
(T
, bound=Union
[Rational
,float
])) – higher bound of range Uv1 (
TypeVar
(T
, bound=Union
[Rational
,float
])) – lower bound of range Vv2 (
TypeVar
(T
, bound=Union
[Rational
,float
])) – higher bound of range V
- Return type:
tuple
[Optional
[TypeVar
(T
, bound=Union
[Rational
,float
])],TypeVar
(T
, bound=Union
[Rational
,float
])]- 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