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.
(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θ.
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.
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.
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).
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With