數學庫入門,我遇到了一個非常簡單的任務:使用四元數轉換一系列矢量。看起來我所做的一切都沒有找到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