def test_line_intersect3_example_2(self): # This example tests the opposite direction cross product case from blmath.geometry.segment import line_intersect3 p0, q0 = np.array([[5., 5., 4.], [10., 10., -6.]]) p1, q1 = np.array([[5., 5., 5.], [10., 10., -3.]]) result = line_intersect3(p0, q0, p1, q1) np.testing.assert_array_equal(result, [2.5, 2.5, 9])
def test_line_intersect3_example_1(self): # This example tests the codirectional cross product case from blmath.geometry.segment import line_intersect3 p0, q0 = np.array([[5., 5., 4.], [10., 10., 6.]]) p1, q1 = np.array([[5., 5., 5.], [10., 10., 3.]]) result = line_intersect3(p0, q0, p1, q1) np.testing.assert_array_equal(result, [25./4, 25./4, 9./2])
def test_line_intersect3_example_3(self): from blmath.geometry.segment import line_intersect3 p0, q0 = np.array([[6., 8., 4.], [12., 15., 4.]]) p1, q1 = np.array([[6., 8., 2.], [12., 15., 6.]]) result = line_intersect3(p0, q0, p1, q1) np.testing.assert_array_equal(result, [9., 23./2, 4.])
def test_line_intersect3_with_degenerate_input_q(self): from blmath.geometry.segment import line_intersect3 p0, q0 = np.array([[0., 1., 2.], [0., 10., 20.]]) p1, q1 = np.array([[1., 2., 3.], [0., 10., 20.]]) result = line_intersect3(p0, q0, p1, q1) np.testing.assert_array_equal(result, [0., 10., 20.])
def test_line_intersect3_with_parallel_lines(self): from blmath.geometry.segment import line_intersect3 p0, q0 = np.array([[0., 1., 2.], [0., 10., 20.]]) p1, q1 = np.array([[1., 2., 3.], [1., 11., 21.]]) result = line_intersect3(p0, q0, p1, q1) self.assertIsNone(result)