def test_rotate1(self): """ """ r1 = RotationMatrix.from_basic_rotations(000., 000., 000.) r2 = RotationMatrix.from_basic_rotations(360., 360., 360.) r3 = RotationMatrix.from_basic_rotations(000., 000., 090.) r4 = RotationMatrix.from_basic_rotations(090., 000., 000.) r5 = RotationMatrix.from_basic_rotations(090., 000., 090.) p1 = Point(1, 1, 0).rotate(r1) p2 = Point(1, 1, 0).rotate(r2) p3 = Point(1, 0, 0).rotate(r3) p4 = Point(0, 1, 0).rotate(r4) p5 = Point(1, 0, 0).rotate(r5) self.assertEqual(p1, (+1, +1, +0)) self.assertEqual(p2, (+1, +1, +0)) self.assertEqual(p3, (+0, +1, +0)) self.assertEqual(p4, (+0, +0, +1)) self.assertEqual(p5, (+0, +1, +0))
def test_from_basic_rotations(self): """ """ r1 = RotationMatrix.from_basic_rotations(000., 000., 000.) r2 = RotationMatrix.from_basic_rotations(360., 360., 360.) r3 = RotationMatrix.from_basic_rotations(000., 000., 090.) r4 = RotationMatrix.from_basic_rotations(090., 000., 000.) r5 = RotationMatrix.from_basic_rotations(090., 000., 090.) self.assertTrue( (r1._array == np.array([[+1, +0, +0], [+0, +1, +0] ,[+0, +0, +1]])).all()) self.assertTrue( (r2._array == np.array([[+1, +0, +0], [+0, +1, +0] ,[+0, +0, +1]])).all()) self.assertTrue( (r3._array == np.array([[+0, -1, +0], [+1, +0, +0] ,[+0, +0, +1]])).all()) self.assertTrue( (r4._array == np.array([[+1, +0, +0], [+0, +0, -1] ,[+0, +1, +0]])).all()) self.assertTrue( (r5._array == np.array([[+0, +0, +1], [+1, +0, +0] ,[+0, +1, +0]])).all())
def test_rotate2(self): """ Rotate 90 degrees around z in (1, 1, 0). """ o1 = (1, 1, 0) o2 = Point(*o1) rotation_matrix = RotationMatrix.from_basic_rotations(0, 0, 90) c1 = self.c.rotate(rotation_matrix, origin=o1) c2 = self.c.rotate(rotation_matrix, origin=o2) self.assertEqual(c1[2], (2, 1, 0)) self.assertEqual(c2[2], (2, 1, 0))
def test_rotate1(self): """ """ r1 = RotationMatrix.from_basic_rotations(000., 000., 000.) r2 = RotationMatrix.from_basic_rotations(360., 360., 360.) r3 = RotationMatrix.from_basic_rotations(000., 000., 090.) r4 = RotationMatrix.from_basic_rotations(090., 000., 000.) r5 = RotationMatrix.from_basic_rotations(090., 000., 090.) c1 = self.c.rotate(r1) c2 = self.c.rotate(r2) c3 = self.c.rotate(r3) c4 = self.c.rotate(r4) c5 = self.c.rotate(r5) self.assertEqual(c1[+0], self.c[+0]) self.assertEqual(c1[+1], self.c[+1]) self.assertEqual(c2[+0], self.c[+0]) self.assertEqual(c2[+1], self.c[+1]) self.assertEqual(c3[+2], (0, 1, 0)) self.assertEqual(c4[+3], (0, 0, 1)) self.assertEqual(c5[+2], (0, 1, 0))
def test_rotate2(self): """ Rotate (1, 0, 0) 90 degrees around z in (1, 1, 0). """ p = Point(1, 0, 0) o1 = (1, 1, 0) o2 = Point(*o1) rotation_matrix = RotationMatrix.from_basic_rotations(0, 0, 90) p1 = p.rotate(rotation_matrix, origin=o1) p2 = p.rotate(rotation_matrix, origin=o2) self.assertEqual(p1, (2, 1, 0)) self.assertEqual(p2, (2, 1, 0))