scipy.spatial.transform.Rotation.as_rotvec

Rotation.as_rotvec()

表示为旋转向量。

旋转矢量是与旋转轴同向的三维矢量,其范数给出旋转角度。 [1].

退货
rotvecndarray,形状(3,)或(N,3)

形状取决于用于初始化的输入的形状。

degrees布尔值,可选

如果此标志为True,则返回的大小以度为单位,否则以弧度为单位。默认值为False。

参考文献

1

https://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation#Rotation_vector

示例

>>> from scipy.spatial.transform import Rotation as R

表示单次旋转:

>>> r = R.from_euler('z', 90, degrees=True)
>>> r.as_rotvec()
array([0.        , 0.        , 1.57079633])
>>> r.as_rotvec().shape
(3,)

表示以度为单位的旋转:

>>> r = R.from_euler('YX', (-90, -90), degrees=True)
>>> s = r.as_rotvec(degrees=True)
>>> s
array([-69.2820323, -69.2820323, -69.2820323])
>>> np.linalg.norm(s)
120.00000000000001

表示单次旋转的堆栈:

>>> r = R.from_quat([[0, 0, 1, 1]])
>>> r.as_rotvec()
array([[0.        , 0.        , 1.57079633]])
>>> r.as_rotvec().shape
(1, 3)

表示单个对象中的多个旋转:

>>> r = R.from_quat([[0, 0, 1, 1], [1, 1, 0, 1]])
>>> r.as_rotvec()
array([[0.        , 0.        , 1.57079633],
       [1.35102172, 1.35102172, 0.        ]])
>>> r.as_rotvec().shape
(2, 3)