trimesh.interval

interval.py

Deal with 1D intervals which are defined by:

[start position, end position]

trimesh.interval.intersection(a: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], b: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]]

Given pairs of ranges merge them in to one range if they overlap.

Parameters:
  • a ((2, ) or (n, 2)) – Start and end of a 1D interval

  • b ((2, ) float) – Start and end of a 1D interval

Returns:

inter – The unioned range from the two inputs, if not inter.ptp(axis=1) will be zero.

Return type:

(2, ) or (2, 2) float

trimesh.interval.union(intervals: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], sort: bool = True) ndarray[Any, dtype[float64]]

For array of multiple intervals union them all into the subset of intervals.

For example: intervals = [[1,2], [2,3]] -> [[1, 3]] intervals = [[1,2], [2.5,3]] -> [[1, 2], [2.5, 3]]

Parameters:
  • intervals ((n, 2)) – Pairs of (min, max) values.

  • sort – If the array is already ordered into (min, max) pairs and then pairs sorted by minimum value you can skip the sorting in this function.

Returns:

unioned – New intervals where m <= n

Return type:

(m, 2)