从轴和角度确定旋转矩阵的角度

Determining the angle for rotation matrix from axis and angle

我一直在使用 4x4 矩阵进行 3D 旋转。我遇到了很多很棒的信息,但是我对一个主题缺乏了解。我还不明白如何确定轴的角度。

如果我们查看 here,我们会找到一个描述从轴和角度旋转矩阵的 wiki 页面。我知道轴是两个向量的叉积。例如:

Vector1: (1,0,0)
Vector2: (0,0,1)

axis = Cross(Vector1, Vector2)

但是,我不知道如何获取角度。如果有人有任何关于计算角度的专业提示,我将不胜感激。

有一个 well-known 恒等式将两个向量的 cross-product 与它们之间的角度联系起来:

其中 theta 较小的 角。但是,这可以在 [0, 180] 范围内,在该范围内,反正弦函数为 multi-valued:锐角 theta 使得 sin(theta) = sin(180 - theta),所以我们不能直接从这个公式中得到它。

我们可以使用dot-product代替:

反余弦函数single-valued这个范围内,所以我们可以使用它!

dot = Dot(Vector1, Vector2)
cos = dot / (Len(Vector1) * Len(Vector2))
theta_radians = acos(cos)
theta_degrees = theta_radians * 180 / PI