Esempio n. 1
0
    def test_quaternion_inverse(self):
        q0 = [1, 0, 0, 0]
        q1 = quaternion_inverse(q0)
        q = quaternion_multiply(q0, q1)
        testing.assert_array_equal(q, [1, 0, 0, 0])

        q0 = [1, 2, 3, 4]
        q1 = quaternion_inverse(q0)
        q = quaternion_multiply(q0, q1)
        testing.assert_almost_equal(q, [1, 0, 0, 0])
Esempio n. 2
0
    def inverse(self):
        """Return inverse of this quaternion

        Returns
        -------
        q : skrobot.coordinates.quaternion.Quaternion
            new Quaternion class has inverse of this quaternion

        Examples
        --------
        >>> from skrobot.coordinates.quaternion import Quaternion
        >>> q = Quaternion()
        >>> q
        #<Quaternion 0x127e6da58 w: 1.0 x: 0.0 y: 0.0 z: 0.0>
        >>> q.inverse
        #<Quaternion 0x1281bbda0 w: 1.0 x: -0.0 y: -0.0 z: -0.0>
        >>> q.q = [0, 1, 0, 0]
        >>> q.inverse
        #<Quaternion 0x1282b0cc0 w: 0.0 x: -1.0 y: -0.0 z: -0.0>
        """
        return Quaternion(q=quaternion_inverse(self.q))