为什么沿三个轴旋转与分别旋转每个轴不同?

Why rotation along three axis is different than rotation each axis separately?

所以我定义了这个 Box,它的大小为 (1, 2, 3),我沿所有三个轴旋转 45°:

Transform {
  rotation 1 1 1 0.7854
  children [
    Shape {
      appearance Appearance { material Material {} }
      geometry Box { size 1 2 3 }
    }
  ]
}

但是当我分别沿每个轴应用相同的旋转时,我得到另一个结果:

Transform {
  rotation 0 0 1 0.7854
  children [
    Transform {
      rotation 0 1 0 0.7854
      children [
        Transform {
          rotation 1 0 0 0.7854
          children [
            Shape {
              appearance Appearance { material Material {} }
              geometry Box { size 1 2 3 }
            }
          ]
        }
      ]
    }
  ]
}

维基百科告诉我可以像这样乘以所有旋转矩阵:R = R(x)R(y)R(z)?

这是上面代码的结果:

你描述的第一个旋转不是绕三个轴的旋转而是绕轴(1,1,1)的旋转,这是不同的。那么很正常,您得不到预期的结果。 如果您愿意,可以从维基百科的公式计算轴 (1,1,1) 和角度 45 的旋转矩阵,并将其与每个轴 x、y、z 和角度 45 的旋转矩阵相乘进行比较,您会看到你得到不同的矩阵。