数学库入门,我遇到了一个非常简单的任务:使用四元数转换一系列矢量。看起来我所做的一切都没有找到operator*
的结果,或者将数组与矩阵混合在一起。在C++特征库中转换矢量数组
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()'而不是'.matrix()'修复了这个问题。奇怪的是,'.matrix()'返回的结果并不一样,但是无论如何。 – Potatoswatter 2012-08-06 04:03:26
我刚刚意识到我打算使用'.toRotationMatrix()'而不是'.matrix()'。我不认为这里需要数组。我编辑了原始答案。 – Jakob 2012-08-13 15:01:57
我认为'series * = rot;'就足够了......看起来我的代码使用从'Quaternionf'到'Matrix3f'的隐式转换。 – Potatoswatter 2012-08-14 03:03:32