示例#1
0
    def setUp(self):
        self.theta1 = 0.123
        self.theta2 = math.radians(30)

        self.q1 = Quaternion()
        # q2 is a quaternion by rotating 0.123 (radians) w.r.t x axis
        self.q2 = Quaternion(
            Vector4(math.cos(self.theta1 / 2), math.sin(self.theta1 / 2), 0,
                    0))

        # q3 is a quaternion by rotaing 30 (degrees) w.r.t z axis
        self.q3 = Quaternion(
            Vector4(math.cos(self.theta2 / 2), 0, 0,
                    math.sin(self.theta2 / 2)))
示例#2
0
 def test_matrix_roundtrip(self):
     rot2 = self.q2.to_rotation_matrix()
     q = Quaternion(rot2)
     np.testing.assert_array_almost_equal(q.as_vector(),
                                          self.q2.as_vector())