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)
def create_from_inverse_of_quaternion( quat ): """Creates a matrix with the inverse rotation of a quaternion. This can be used to go from object space to intertial space. :param numpy.array quat: The quaternion to make the matrix from (shape 4). :rtype: numpy.array :return: A matrix with shape (4,4) that respresents the inverse of the quaternion. """ # set to identity matrix # this will populate our extra rows for us mat = create_identity() # we'll use Matrix33 for our conversion mat[ 0:3, 0:3 ] = matrix33.create_from_inverse_of_quaternion( quat ) return mat
def test_create_from_inverse_of_quaternion(self): q = quaternion.create_from_x_rotation(np.pi / 2.0) result = matrix33.create_from_inverse_of_quaternion(q) self.assertTrue( np.allclose(result, matrix33.create_from_x_rotation(-np.pi / 2.0)))
def test_create_from_inverse_of_quaternion(self): q = quaternion.create_from_x_rotation(np.pi / 2.0) result = matrix33.create_from_inverse_of_quaternion(q) self.assertTrue(np.allclose(result, matrix33.create_from_x_rotation(-np.pi / 2.0)))