colour.algebra.intersect_line_segments#

colour.algebra.intersect_line_segments(l_1: ArrayLike, l_2: ArrayLike) colour.algebra.geometry.LineSegmentsIntersections_Specification[source]#

Compute \(l_1\) line segments intersections with \(l_2\) line segments.

Parameters
  • l_1 (ArrayLike) – \(l_1\) line segments array, each row is a line segment such as (\(x_1\), \(y_1\), \(x_2\), \(y_2\)) where (\(x_1\), \(y_1\)) and (\(x_2\), \(y_2\)) are respectively the start and end points of \(l_1\) line segments.

  • l_2 (ArrayLike) – \(l_2\) line segments array, each row is a line segment such as (\(x_3\), \(y_3\), \(x_4\), \(y_4\)) where (\(x_3\), \(y_3\)) and (\(x_4\), \(y_4\)) are respectively the start and end points of \(l_2\) line segments.

Returns

Line segments intersections specification.

Return type

colour.algebra.LineSegmentsIntersections_Specification

References

[Boua], [Erda]

Notes

  • Input line segments points coordinates are 2d coordinates.

Examples

>>> l_1 = np.array(
...     [[[0.15416284, 0.7400497],
...       [0.26331502, 0.53373939]],
...      [[0.01457496, 0.91874701],
...       [0.90071485, 0.03342143]]]
... )
>>> l_2 = np.array(
...     [[[0.95694934, 0.13720932],
...        [0.28382835, 0.60608318]],
...       [[0.94422514, 0.85273554],
...        [0.00225923, 0.52122603]],
...       [[0.55203763, 0.48537741],
...        [0.76813415, 0.16071675]]]
... )
>>> s = intersect_line_segments(l_1, l_2)
>>> s.xy  
array([[[        nan,         nan],
        [ 0.2279184...,  0.6006430...],
        [        nan,         nan]],

       [[ 0.4281451...,  0.5055568...],
        [ 0.3056055...,  0.6279838...],
        [ 0.7578749...,  0.1761301...]]])
>>> s.intersect
array([[False,  True, False],
       [ True,  True,  True]], dtype=bool)
>>> s.parallel
array([[False, False, False],
       [False, False, False]], dtype=bool)
>>> s.coincident
array([[False, False, False],
       [False, False, False]], dtype=bool)