Convert vector array to C ++ Eigen library

Getting started in the Eigen math library, I am having problems with a very simple task: convert a series of vectors using quaternions. It seems that everything I do leads to the absence of operator* or mixing the array with the 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 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 
+4
source share
2 answers

Hm ... not sure why you are using Array in your example. I think you want to turn m 3-vectors into rot, right? You can use a 3xm matrix for this.

What about

 using namespace Eigen; Quaternionf rot = ...; Matrix<float,3,Dynamic> series = ...; series = rot.toRotationMatrix() * series; 
+3
source

This can be a very dumb but effective solution:

 for (int vector = 0; vector < series.cols(); ++vector) series.col(vector) = rot * series.col(vector).matrix(); 

The fact is that somewhere someone has to read your code. A simple for loop is often easier to understand.

0
source

All Articles