验证当已知旋转矩阵时计算角度差的公式的正确性

项目场景:

验证公式的正确性
在已知两张图片的旋转矩阵(3*3),求他们之间的角度差时,得知公式在这里插入图片描述
为了验证该公式的正确性,构造两个不同角度的旋转矩阵,代入计算验证该公式是否可以得到正确答案。

问题描述:

提示:在老师的帮助下,查询了scipy的官方文档,了解这个库中Rotation的用法

from scipy.spatial.transform import Rotation
import math
import numpy as np

r1 = Rotation.from_euler('z',[30],degrees=True).as_matrix().squeeze(0)
r2 = Rotation.from_euler('z',[10],degrees=True).as_matrix().squeeze(0)
test = abs(round((np.trace(np.dot(r1.T, r2)) - 1) / 2, 4))
print(test)
print(math.cos(math.pi/9))

#test 2
r11 = Rotation.from_euler('z',[180],degrees=True).as_matrix().squeeze(0)
r22 = Rotation.from_euler('z',[120],degrees=True).as_matrix().squeeze(0)
test2 = abs(round((np.trace(np.dot(r11.T, r22)) - 1) / 2, 4))
print(test2)
print(math.cos(math.pi/3))

在这里插入图片描述


结论:

该公式可以用于计算角度差。

猜你喜欢

转载自blog.csdn.net/weixin_47651805/article/details/114709653