eular angle
2020-09-22 本文已影响0人
asl_1da7
pytorch3d.transforms.euler_angles_to_matrix
详解
⚠️Attention
- 绕轴旋转时,大拇指指向轴的负方向。例如, 绕X轴旋转,大拇指指向-X方向
- 一般角度都是用弧度表示
-
conversion
表示的是旋转的顺序:-
XYZ
表示依次按照X
,Y
,Z
的顺序旋转 -
ZYX
表示依次按照Z
,Y
,X
的顺序旋转
-
- points的坐标右乘旋转矩阵,
- 连续旋转时,依次在右边添加要乘的旋转矩阵
下面是四个例子:
- 绕
X
轴方向选择90°(图中的-X
实际是指大拇指指向-X
- 绕
Z
轴方向选择90°(图中的-Z
实际是指大拇指指向-Z
- 先绕
X
轴方向选择90°,再绕Z
轴方向选择90° - 先绕
Z
轴方向选择90°,再绕X
轴方向选择90°
import pytorch3d.transforms as pyt
import numpy as np
def rotate_matrix(angles, order):
return pyt.euler_angles_to_matrix(angles, order)
from pytorch3d.transforms import Rotate
def rotate(m, points):
return Rotate(m).transform_points(points)
points = torch.Tensor([[1,-2,3],[4,5,6]])
- 绕
X
轴方向选择90°(图中的-X
实际是指大拇指指向-X
# rotate 90° around the -X direction
angles = torch.Tensor([np.pi/2,0,0])
m = rotate_matrix(angles, "XYZ")
new_points = roate(m, points)
- 绕
Z
轴方向选择90°(图中的-Z
实际是指大拇指指向-Z
# rotate 90° around the -Z direction
angles = torch.Tensor([0,0,np.pi/2])
m = rotate_matrix(angles, "XYZ")
new_points = roate(m, points)
- 先绕
X
轴方向选择90°,再绕Z
轴方向选择90°
# rotate 90° around the -X direction then rotate 90° around the -Z direction
angles = torch.Tensor([np.pi/2,0,np.pi/2])
m = rotate_matrix(angles, "XYZ")
new_points = roate(m, points)
- 先绕
Z
轴方向选择90°,再绕X
轴方向选择90°
# rotate 90° around the -Z direction then rotate 90° around the -X direction
angles = torch.Tensor([np.pi/2,0,np.pi/2])
m = rotate_matrix(angles, "ZYX")
new_points = roate(m, points)
image.png
image.png