scipy中四元数旋转矩阵互相转换

最近做的东西涉及到坐标系旋转,使用scipy包很方便
文档
https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.html

from scipy.spatial.transform import Rotation as R
r = R.from_quat([0, 0, np.sin(np.pi/4), np.cos(np.pi/4)])
r.as_matrix()
array([[ 2.22044605e-16, -1.00000000e+00,  0.00000000e+00],
       [ 1.00000000e+00,  2.22044605e-16,  0.00000000e+00],
       [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00]])
 r.as_euler('zyx',degrees=True)
array([90.,  0.,  0.])
from scipy.spatial.transform import Rotation as R
r = R.from_matrix([[0, -1, 0],[1,0,0],[0,0,1]])
r.as_quat()
array([0.        , 0.        , 0.70710678, 0.70710678])

你可能感兴趣的:(python,scipy)