import numpy as np def quaterniontoeuler(q): q = [w, x, y, z] w, x, y, z = q…
Jump to turn (6)
- 1import numpy as np def quaterniontoeuler(q): # q = [w, x, y, z] w, x, y, z = q #
- 2改为ZYX轴
- 3从excel中分别读取w,x,yz的值计算出对应的欧拉角,w对应 panooriw,x对应 panoorix,y对应 panooriy,z对应 panooriz
- 4File "C:\Users\HXH\AppData\Roaming\Python\Python39\site-packages\pandas\io\excel
- 5data = pd.readexcel('F:\potree\ceshi\py\pano-poses.csv',engine='openpyxl') # 假设数
- 6return self.engine.getloc(castedkey) File "pandas\libs\index.pyx", line 147, in
- User
import numpy as np
def quaternion_to_euler(q): # q = [w, x, y, z] w, x, y, z = q
code# 计算俯仰角(pitch) sinp = 2.0 * (w * x + y * z) cosp = 1.0 - 2.0 * (x * x + y * y) pitch = np.arctan2(sinp, cosp) # 计算滚转角(roll) sinr = 2.0 * (w * y - z * x) cosr = 1.0 - 2.0 * (y * y + z * z) roll = np.arctan2(sinr, cosr) # 计算偏航角(yaw) siny = 2.0 * (w * z + x * y) cosy = 1.0 - 2.0 * (y * y + z * z) yaw = np.arctan2(siny, cosy) return roll, pitch, yaw使用方法:
q = [0.897072, 0.008447, -0.032691, 0.440593] euler_angles = quaternion_to_euler(q) print("Roll: {:.6f}, Pitch: {:.6f}, Yaw: {:.6f}".format( np.degrees(euler_angles[0]), np.degrees(euler_angles[1]), np.degrees(euler_angles[2]) )) 基于度数转换
- Assistant