我用Eigen::Affine3f来表示相机矩阵。(我已经知道如何从初始的"lookAt“和"up”向量设置视图矩阵/lookAt)
现在,我想支持改变相机的方向。简单的问题:将旋转应用于这个Affine3f的最佳方法是什么,即俯仰、偏航、滚动?
发布于 2016-01-20 10:00:19
使用内置功能非常简单。您可以使用AxisAngle对象来乘现有的Affine3f。只需注意,轴需要标准化:
Vector3f rotationAxis;
rotationAxis.setRandom(); // I don't really care, you determine the axis
rotationAxis.normalize(); // This is important, don't forget it
Affine3f randomAffine3f, rotatedAffine;
// Whatever was left in memory in my case,
// whatever your transformation is in yours
std::cout << randomAffine3f.matrix() << std::endl;
// We'll now apply a rotation of 0.256*M_PI around the rotationAxis
rotatedAffine = (AngleAxisf(0.256*M_PI, rotationAxis) * randomAffine3f);
std::cout << rotatedAffine.matrix() << std::endl; // Ta dum!!https://stackoverflow.com/questions/34895284
复制相似问题