def test_rotate2d_rotation_arg(self):
     angle = 'a'
     v = (1, 0)
     with self.assertRaises(
             TypeError,
             msg='should raise TypeError when not passing numeric angle'):
         rotate2d(angle, v)
 def test_rotate2d_vector_arg_dimension(self):
     angle = pi
     v = (1, 0, 0)
     with self.assertRaises(
             TypeError,
             msg='should raise TypeError when not passing 2D vector'):
         rotate2d(angle, v)
 def test_rotate2d_vector_arg_numeric(self):
     angle = pi
     v = ('a', 'b')
     with self.assertRaises(
             TypeError,
             msg='should raise TypeError when not passing numeric 2D vector'
     ):
         rotate2d(angle, v)
Exemplo n.º 4
0
 def transformed(self):
     # before rotation was:
     # return [add((self.x, self.y), v) for v in self.points]
     rotated_points = [
         rotate2d(self.rotation_angle, point) for point in self.points
     ]
     return [
         add((self.x, self.y), rotated_point)
         for rotated_point in rotated_points
     ]
 def test_rotate2d_happy_path(self):
     angle = pi / 2
     v = (2, 2)
     actual_rotate2d_result = rotate2d(angle, v)
     expected_rotate2d_result = (-2, 2)
     self.assertAlmostEqual(actual_rotate2d_result[0],
                            expected_rotate2d_result[0],
                            msg='rotate2d x should approximately match')
     self.assertAlmostEqual(actual_rotate2d_result[1],
                            expected_rotate2d_result[1],
                            msg='rotate2d y should approximately match')