import numpy as np
import cv2
from PIL import Image, ImageDraw
import copy
from scipy.spatial.transform import Rotation as R
def eulerAnglesToRotationMatrix(theta):
# 將角度轉(zhuǎn)換為弧度
theta_rad = np.radians(theta)
# 構(gòu)造繞 x、y、z 軸的旋轉(zhuǎn)矩陣
R_x = np.array([[1, 0, 0],
[0, np.cos(theta_rad[0]), -np.sin(theta_rad[0])],
[0, np.sin(theta_rad[0]), np.cos(theta_rad[0])]])
R_y = np.array([[np.cos(theta_rad[1]), 0, np.sin(theta_rad[1])],
[0, 1, 0],
[-np.sin(theta_rad[1]), 0, np.cos(theta_rad[1])]])
R_z = np.array([[np.cos(theta_rad[2]), -np.sin(theta_rad[2]), 0],
[np.sin(theta_rad[2]), np.cos(theta_rad[2]), 0],
[0, 0, 1]])
# 計算總的旋轉(zhuǎn)矩陣
R = np.dot(R_z, np.dot(R_y, R_x))
return R
def rotation_matrix_to_euler_angles(rotation_matrix):
r = R.from_matrix(rotation_matrix)
euler_angles = r.as_euler('xyz', degrees=True)
return euler_angles
旋轉(zhuǎn)矩陣和歐拉角之間的相互轉(zhuǎn)換代碼
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 歐拉角轉(zhuǎn)旋轉(zhuǎn)矩陣 對于兩個三維點 ,,由點經(jīng)過旋轉(zhuǎn)矩陣旋轉(zhuǎn)到,則有: 任何一個旋轉(zhuǎn)可以表示為依次繞著三個旋轉(zhuǎn)軸旋三...
- 參考文章[https://blog.csdn.net/u011906844/article/details/121...
- 運行結(jié)果: 另外一篇可供參考的博客
- 四元數(shù)(quaternion)和旋轉(zhuǎn)矩陣(rotation matrix)之間的相互轉(zhuǎn)換在計算機圖形學(xué)和三維計算中...