python 轴角转化为旋转矩阵 实现

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) 

你可能感兴趣的:(矩阵,矩阵,python,线性代数)