Reputation: 137940
Getting started in the Eigen math library, I'm having trouble with a very simple task: transform a series of vectors using a quaternion. Seems everything I do results in no operator*
found, or mixing an array with a matrix.
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
Upvotes: 4
Views: 2259
Reputation: 2380
Hm... not sure why you use an Array in your example. I guess you want to transform m 3-vectors by rot, right? You could use a 3xm Matrix for this.
How about
using namespace Eigen;
Quaternionf rot = ...;
Matrix<float,3,Dynamic> series = ...;
series = rot.toRotationMatrix() * series;
Upvotes: 5
Reputation: 36059
This might be a very blunt, but effective solution:
for (int vector = 0; vector < series.cols(); ++vector)
series.col(vector) = rot * series.col(vector).matrix();
The point here is that somewhere, someone has to read your code. A simple for
loop is often easiest to understand.
Upvotes: 0