@@ -245,6 +245,19 @@ def test_line_plane_intersection(self):
245
245
np .testing .assert_array_equal (plane .line_xsection (pt = [0. , - 1. , 0. ], ray = [0. , 1. , 0. ]), [0. , 0. , 0. ])
246
246
np .testing .assert_array_equal (plane .line_xsection (pt = [0. , - 1. , 0. ], ray = [1. , 1. , 0. ]), [1. , 0. , 0. ])
247
247
248
+ def test_line_plane_intersections (self ):
249
+ # x-z plane
250
+ normal = np .array ([0. , 1. , 0. ])
251
+ sample = np .array ([0. , 0. , 0. ])
252
+
253
+ plane = Plane (sample , normal )
254
+ pts = np .array ([[0. , - 1. , 0. ], [0. , 0. , 0. ], [0. , - 1. , 0. ], [0. , - 1. , 0. ]])
255
+ rays = np .array ([[1. , 0. , 0. ], [1. , 0. , 0. ], [0. , 1. , 0. ], [1. , 1. , 0. ]])
256
+ expected = np .array ([[np .nan , np .nan , np .nan ], [np .nan , np .nan , np .nan ], [0. , 0. , 0. ], [1. , 0. , 0. ]])
257
+ intersections , is_intserseting = plane .line_xsections (pts , rays )
258
+ np .testing .assert_array_equal (intersections , expected )
259
+ np .testing .assert_array_equal (is_intserseting , [False , False , True , True ])
260
+
248
261
def test_line_segment_plane_intersection (self ):
249
262
# x-z plane
250
263
normal = np .array ([0. , 1. , 0. ])
@@ -257,6 +270,19 @@ def test_line_segment_plane_intersection(self):
257
270
np .testing .assert_array_equal (plane .line_segment_xsection ([0. , - 1. , 0. ], [2. , 1. , 0. ]), [1. , 0. , 0. ])
258
271
self .assertIsNone (plane .line_segment_xsection ([0. , 1. , 0. ], [0. , 2. , 0. ])) # line intersecting, but not in segment
259
272
273
+ def test_line_segment_plane_intersections (self ):
274
+ # x-z plane
275
+ normal = np .array ([0. , 1. , 0. ])
276
+ sample = np .array ([0. , 0. , 0. ])
277
+
278
+ plane = Plane (sample , normal )
279
+ a = np .array ([[0. , - 1. , 0. ], [0. , 0. , 0. ], [0. , - 1. , 0. ], [0. , - 1. , 0. ], [0. , 1. , 0. ]])
280
+ b = np .array ([[1. , - 1. , 0. ], [1. , 0. , 0. ], [0. , 1. , 0. ], [2. , 1. , 0. ], [0. , 2. , 0. ]])
281
+ expected = np .array ([[np .nan , np .nan , np .nan ], [np .nan , np .nan , np .nan ], [0. , 0. , 0. ], [1. , 0. , 0. ], [np .nan , np .nan , np .nan ]])
282
+ intersections , is_intserseting = plane .line_segment_xsections (a , b )
283
+ np .testing .assert_array_equal (intersections , expected )
284
+ np .testing .assert_array_equal (is_intserseting , [False , False , True , True , False ])
285
+
260
286
def test_mesh_plane_intersection (self ):
261
287
# x-z plane
262
288
normal = np .array ([0. , 1. , 0. ])
0 commit comments