将旋转应用于特征::仿射3f

Apply rotation to Eigen::Affine3f

本文关键字:仿射 3f 特征 旋转 应用于      更新时间:2023-10-16

我正在使用Eigen::Affine3f来表示相机矩阵。(我已经弄清楚了如何从初始"lookAt"和"up"向量设置视图矩阵/Affine3f

现在,我想支持更改相机的方向。简单的问题:将旋转应用于此Affine3f的最佳方法是什么,即俯仰,偏航,滚动?

使用内置功能非常简单。您可以使用 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!!