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]]) )
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]]) )
def test_rotate(self, points, radians): np.testing.assert_almost_equal( MathUtils.rotate(MathUtils.rotate(points, radians), -radians), points )
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) )