Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotation matrix in Eigen

Tags:

eigen

Can I use the Eigen library to get the rotation matrix which rotates vector A to vector B? I have been searching for a while, but cannot find related api.

like image 281
LittleSweet Avatar asked Feb 23 '13 17:02

LittleSweet


People also ask

How do you find the eigenvalue of a rotation matrix?

(b) Find the eigenvalues of the matrix A.The eigenvalues of A are roots of the characteristic polynomial p(t). p(t)=t2−(2cosθ)t+1=0. t=2cosθ±√(2cosθ)2−42=cosθ±√cos2θ−1=cosθ±√−sin2θ=cosθ±isinθ=e±iθ.

What do the eigenvalues of a rotation matrix represent?

The eigenvector of the rotation matrix corresponding to eigenvalue 1 is the axis of rotation. The remaining eigenvalues are complex conjugates of each other and so are the corresponding eigenvectors. The two complex eigenvectors can be manipulated to determine a plane perpendicular to the first real eigen vector.

Do rotation matrices have eigenvectors?

Every rotation matrix must have this eigenvalue, the other two eigenvalues being complex conjugates of each other. It follows that a general rotation matrix in three dimensions has, up to a multiplicative constant, only one real eigenvector.

Does a rotation have eigenvalues?

When an operation does nothing except scale a vector by a constant factor, that vector is called an eigenvector of the operation. In “normal” linear algebra, without complex numbers, rotations have no eigenvectors (not counting 0° and 180° rotations).


1 Answers

You first have to construct a quaternion and then convert it to a matrix, for instance:

#include <Eigen/Geometry>
using namespace Eigen;

int main() {
  Vector3f A, B;
  Matrix3f R;
  R = Quaternionf().setFromTwoVectors(A,B);
}
like image 83
ggael Avatar answered Nov 03 '22 09:11

ggael