def test_rotate(self): """Test some sample rotations""" point = Point(8, 10) around = Point(7, 7) self.assertEqual(point.rotate(around=around, degrees=90), Point(10, 6)) self.assertEqual(point.rotate(around=around, degrees=180), Point(6, 4)) self.assertEqual(point.rotate(around=around, degrees=270), Point(4, 8)) self.assertEqual(point.rotate(around=around, degrees=-90), Point(4, 8))
def test_rotate_identity(self): """Test rotating a point over itself""" point = Point(4, 4) around = Point(4, 4) rotation = Point(4, 4) self.assertEqual(point.rotate(around=around, degrees=0), rotation) self.assertEqual(point.rotate(around=around, degrees=90), rotation) self.assertEqual(point.rotate(around=around, degrees=180), rotation) self.assertEqual(point.rotate(around=around, degrees=270), rotation)
def test_simple_rotation(self): """Test rotating a shape containing a single point""" origin = Point(4, 4) around = Point(7, 6) shape = Shape.I1(origin) self.assertEqual( shape.rotate(around, 90).origin, origin.rotate(around, 90)) self.assertEqual( shape.rotate(around, 180).origin, origin.rotate(around, 180)) self.assertEqual( shape.rotate(around, 270).origin, origin.rotate(around, 270))