def test_nearest_to_origin(self): p1 = (1, 0, 0) p2 = (0, 1, 0) p3 = (0, 0, 1) plane = PlaneEquation.from_three_points(p1, p2, p3) p = plane.nearest_point_to_origin() self.assert_sverchok_data_equal(tuple(p), (0.3333, 0.3333, 0.3333), precision=4)
def test_projection_2(self): p1 = (1, 0, 0) p2 = (0, 1, 0) p3 = (0, 0, 1) plane = PlaneEquation.from_three_points(p1, p2, p3) point = (3, 3, 3) result = plane.projection_of_point(point) self.assert_sverchok_data_equal(tuple(result), (0.3333, 0.3333, 0.3333), precision=4)
def test_plane_from_three_points(self): p1 = (1, 0, 0) p2 = (0, 1, 0) p3 = (0, 0, 1) plane = PlaneEquation.from_three_points(p1, p2, p3) self.assertEquals(plane.a, 1) self.assertEquals(plane.b, 1) self.assertEquals(plane.c, 1) self.assertEquals(plane.d, -1)
def test_two_vectors(self): p1 = (2, 0, 0) p2 = (0, 1, 0) p3 = (0, 0, 2) plane = PlaneEquation.from_three_points(p1, p2, p3) normal = plane.normal v1, v2 = plane.two_vectors() self.assertTrue(abs(normal.dot(v1)) < 1e-8) self.assertTrue(abs(normal.dot(v2)) < 1e-8) self.assertTrue(abs(v1.dot(v2)) < 1e-8)
def test_projection_4(self): p1 = (1, 0, 0) p2 = (0, 1, 0) p3 = (0, 0, 1) plane = PlaneEquation.from_three_points(p1, p2, p3) point1 = (-3, -3, -3) point2 = (2, 1, 1) point3 = (1, 1, 2) point4 = (1, 2, 1) result = plane.projection_of_points([point1, point2, point3, point4]) expected = np.array([[0.3333, 0.3333, 0.3333], [1,0,0], [0, 0, 1], [0, 1, 0]]) info(result) self.assert_numpy_arrays_equal(result, expected, precision=4)
def test_projection_4(self): p1 = (1, 0, 0) p2 = (0, 1, 0) p3 = (0, 0, 1) plane = PlaneEquation.from_three_points(p1, p2, p3) point1 = (-3, -3, -3) point2 = (2, 1, 1) point3 = (1, 1, 2) point4 = (1, 2, 1) result = plane.projection_of_points([point1, point2, point3, point4]) expected = np.array([[0.3333, 0.3333, 0.3333], [1, 0, 0], [0, 0, 1], [0, 1, 0]]) info(result) self.assert_numpy_arrays_equal(result, expected, precision=4)