eular angle

2020-09-22  本文已影响0人  asl_1da7

pytorch3d.transforms.euler_angles_to_matrix详解

⚠️Attention

  1. X轴方向选择90°(图中的-X实际是指大拇指指向-X
  2. Z轴方向选择90°(图中的-Z实际是指大拇指指向-Z
  3. 先绕X轴方向选择90°,再绕Z轴方向选择90°
  4. 先绕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]])
  1. 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)
  1. 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)
  1. 先绕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)
  1. 先绕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
上一篇下一篇

猜你喜欢

热点阅读