示例#1
0
 def test_rotate_trivial(self):
     np.testing.assert_almost_equal(
         MathUtils.rotate(np.array([[1,0]]),0),
         np.array([[1,0]])
         )
     np.testing.assert_almost_equal(
         MathUtils.rotate(np.array([[1,0]]),math.pi / 2),
         np.array([[0,1]])
         )
     np.testing.assert_almost_equal(
         MathUtils.rotate(np.array([[1,0]]),2 * math.pi / 2),
         np.array([[-1,0]])
         )
     np.testing.assert_almost_equal(
         MathUtils.rotate(np.array([[1,0]]),3 * math.pi / 2),
         np.array([[0,-1]])
         )
示例#2
0
 def test_rotation_matrix_trivial(self):
     np.testing.assert_almost_equal(
         MathUtils.rotation_matrix(0),
         np.eye(2)
         )
     np.testing.assert_almost_equal(
         MathUtils.rotation_matrix(math.pi / 2),
         np.array([[0,-1],[1,0]])
         )
     np.testing.assert_almost_equal(
         MathUtils.rotation_matrix(math.pi),
         np.array([[-1,0],[0,-1]])
         )
     np.testing.assert_almost_equal(
         MathUtils.rotation_matrix(3*math.pi/2),
         np.array([[0,1],[-1,0]])
         )
示例#3
0
 def test_rotate(self, points, radians):
     np.testing.assert_almost_equal(
         MathUtils.rotate(MathUtils.rotate(points, radians), -radians),
         points
         )
示例#4
0
 def test_rotation_matrix_equivalence(self, radians, n_2pi):
     np.testing.assert_almost_equal(
         MathUtils.rotation_matrix(radians),
         MathUtils.rotation_matrix(radians+n_2pi*math.pi*2)
         )