コード例 #1
0
    def test_rotateFromQuat(self):
        from quat import Quat
        from math import pi

        v = Vec3(1., 1., 1.)
        q = Quat.createFromAxisAngle(Vec3([1., 0., 0.]), pi / 2.)
        v.rotateFromQuat(q)

        self.assertEqual(v[0], 1.)
        self.assertEqual(math.floor(v[1]), -1.)
        self.assertEqual(v[2], 1.)
コード例 #2
0
ファイル: vec3.py プロジェクト: AboudFayad/STLIB
    def rotateFromAxisAngle(self, axis, angle):
        """Function rotateFromAxisAngle from the Vec3 class rotates the current vector from the quaternion
        corresponding to the given axis and angle.

        Example:

        >>> v = Vec3(1.,1.,1.)
        >>> v.rotateFromAxisAndAngle([1.,0.,0.],pi/2.)
        >>> print(v)
        [1.,-1,1.]
        """
        from quat import Quat
        q = Quat.createFromAxisAngle(axis, angle)
        self.rotateFromQuat(q)