C++ Eigen 库中的变换向量数组

Pot*_*ter 4 c++ eigen

开始使用Eigen数学库时,我在执行一项非常简单的任务时遇到了麻烦:使用四元数转换一系列向量。似乎我所做的一切都没有operator*找到,或者将数组与矩阵混合。

\n\n
Eigen::Quaternionf rot = \xe2\x80\xa6;\nEigen::Array3Xf series = \xe2\x80\xa6;\n\n// expected this to work as matrix() returns a Transformation:\nseries.matrix().colwise() *= rot.matrix();\n\n// expected these to work as it\'s standard notation:\nseries = rot.matrix() * series.matrix().colwise();\nseries = rot.toRotationMatrix() * series.matrix().colwise();\n\n// Also tried adding .homogeneous() as one example used it\xe2\x80\xa6 no dice\n
Run Code Online (Sandbox Code Playgroud)\n

Jak*_*kob 5

嗯...不确定为什么在示例中使用数组。我猜你想通过 rot 变换 m 个 3 向量,对吧?您可以使用 3xm 矩阵来实现此目的。

怎么样

using namespace Eigen;
Quaternionf rot = ...;
Matrix<float,3,Dynamic> series = ...;

series = rot.toRotationMatrix() * series;
Run Code Online (Sandbox Code Playgroud)