import numpy as np
import math
import scipy.linalg as linalg
轴角转化为旋转矩阵公式定义:
def rotate_mat(axis, radian):
rot_matrix = linalg.expm(np.cross(np.eye(3), axis / linalg.norm(axis) * radian))
return rot_matrix
绕x轴旋转90度:
rand_axis = [1,0,0]
r = math.pi/2
rot_matrix = rotate_mat(rand_axis, r)
print(rot_matrix)
绕y轴旋转90度:
rand_axis = [0,1,0]
p = math.pi/2
rot_matrix = rotate_mat(rand_axis, p)
print(rot_matrix)
绕z轴旋转90度:
rand_axis = [0,0,1]
yaw = math.pi/2
rot_matrix = rotate_mat(rand_axis, yaw)
print(rot_matrix)