开始使用Eigen数学库时,我在一个非常简单的任务上遇到了困难:使用四元数转换一系列向量。似乎我所做的一切都导致没有找到operator*
,或者将数组与矩阵混合。
Eigen::Quaternionf rot = …;
Eigen::Array3Xf series = …;
// expected this to work as matrix() returns a Transformation:
series.matrix().colwise() *= rot.matrix();
// expected these to work as it's standard notation:
series = rot.matrix() * series.matrix().colwise();
series = rot.toRotationMatrix() * series.matrix().colwise();
// Also tried adding .homogeneous() as one example used it… no dice
Array
在一些未在示例中显示的向量标量加法中很方便。但是,Array
是错误的,对象实际上是一个矩阵。将其类型设置为矩阵并调用.array()
而不是.matrix()
解决了问题。奇怪的是,从.matrix()
返回的结果没有以相同的方式工作...但无论如何。 - Potatoswatter.toRotationMatrix()
而不是.matrix()
。我认为这里不需要使用数组。我已经编辑了原始答案。 - Jakobseries *= rot;
就足够了... 这似乎是我的代码使用了从Quaternionf
到Matrix3f
的隐式转换。 - Potatoswatter