Ejemplo n.º 1
0
    def test_inverse_equivalence(self):
        q = [5.77350000e-01, 5.77350000e-01, 5.77350000e-01, 6.12323400e-17]
        result = matrix33.create_from_quaternion(quaternion.inverse(q))
        expected = matrix33.inverse(matrix33.create_from_quaternion(q))
        np.testing.assert_almost_equal(result, expected, decimal=5)

        q = quaternion.create_from_x_rotation(0.5)
        result = matrix33.create_from_inverse_of_quaternion(q)
        expected = matrix33.inverse(matrix33.create_from_quaternion(q))
        np.testing.assert_almost_equal(result, expected, decimal=5)
Ejemplo n.º 2
0
    def test_inverse_equivalence(self):
        q = [5.77350000e-01, 5.77350000e-01, 5.77350000e-01, 6.12323400e-17]
        result = matrix33.create_from_quaternion(quaternion.inverse(q))
        expected = matrix33.inverse(matrix33.create_from_quaternion(q))
        np.testing.assert_almost_equal(result, expected, decimal=5)

        q = quaternion.create_from_x_rotation(0.5)
        result = matrix33.create_from_inverse_of_quaternion(q)
        expected = matrix33.inverse(matrix33.create_from_quaternion(q))
        np.testing.assert_almost_equal(result, expected, decimal=5)
Ejemplo n.º 3
0
    def test_operators_matrix33(self):
        m1 = Matrix33.identity()
        m2 = Matrix33.from_x_rotation(0.5)

        # add
        self.assertTrue(np.array_equal(m1 + m2, matrix33.create_identity() + matrix33.create_from_x_rotation(0.5)))

        # subtract
        self.assertTrue(np.array_equal(m1 - m2, matrix33.create_identity() - matrix33.create_from_x_rotation(0.5)))

        # multiply
        self.assertTrue(np.array_equal(m1 * m2, matrix33.multiply(matrix33.create_from_x_rotation(0.5), matrix33.create_identity())))

        # divide
        self.assertRaises(ValueError, lambda: m1 / m2)

        # inverse
        self.assertTrue(np.array_equal(~m2, matrix33.inverse(matrix33.create_from_x_rotation(0.5))))

        # ==
        self.assertTrue(Matrix33() == Matrix33())
        self.assertFalse(Matrix33() == Matrix33([1. for n in range(9)]))

        # !=
        self.assertTrue(Matrix33() != Matrix33([1. for n in range(9)]))
        self.assertFalse(Matrix33() != Matrix33())
Ejemplo n.º 4
0
 def test_inverse(self):
     m = matrix33.create_from_y_rotation(np.pi)
     result = matrix33.inverse(m)
     self.assertTrue(
         np.allclose(result, matrix33.create_from_y_rotation(-np.pi)))
Ejemplo n.º 5
0
 def test_inverse(self):
     m1 = Matrix33.identity() * Matrix33.from_x_rotation(0.5)
     m = m1.inverse
     self.assertTrue(np.array_equal(m, matrix33.inverse(m1)))
Ejemplo n.º 6
0
 def test_inverse(self):
     m1 = Matrix33.identity() * Matrix33.from_x_rotation(0.5)
     m = m1.inverse
     self.assertTrue(np.array_equal(m, matrix33.inverse(m1)))
Ejemplo n.º 7
0
 def test_inverse(self):
     m = matrix33.create_from_y_rotation(np.pi)
     result = matrix33.inverse(m)
     self.assertTrue(np.allclose(result, matrix33.create_from_y_rotation(-np.pi)))