我有一个代表场景中模型的父类(super class)对象。该对象包含一个 3D 向量,position
表示它的位置和三个变量 x
、y
和 z
来描述它的位置围绕这些轴旋转。其变换矩阵计算如下:
Matrix.CreateRotationX(x) *
Matrix.CreateRotationY(y) *
Matrix.CreateRotationZ(z) *
Matrix.CreateTranslation(position)
这一切都很好,除了在某些情况下我需要根据标准化计算 x
、y
和 z
的值方向向量和向上向量。我该怎么做?
最佳答案
将矩阵转换为四元数:
四元数 q = Quaternion.CreateFromRotationMatrix(matrix);
然后复制粘贴the last method found on this page并通过它运行你的四元数。
关于c# - 如何找到给定方向向量和向上向量的 x、y 和 z 旋转角度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8303113/