Eigen::MatrixXd的操作
#include <Eigen/Dense>
/****** Definition and Assign ******/
// Way 01
Eigen::MatrixXd m;
// Way 02
MatrixXd m(2,2);
m(0,0) = 3;
m(1,0) = 2.5;
m(0,1) = -1;
// Way 03
MatrixXd m(2,2);
m<< 1, 2, 3, 4;
/****** Get Values ******/
// Way 01: Get Element
cout<<m(1,1)<<endl;
// Way 02: Get elements of i-th row and column
cout<<m.row(i)<<endl<<m.col(i)<<endl;
/* Invert */
A.inverse();
/* Transpose */
A.transpose();
/* Merge */
M<<m1,m2;
/* Transformation */
Eigen::Affine3f tf = Eigen::Affine3f::Identity();
tf.translation()<<0,0,0;
tf.rotate(Eigen::AngleAxisf(alpha, Eigen::Vector3f::UnitZ()));
Eigen::Vector3f val(orientations_[i].x,orientations_[i].y,orientations_[i].z);
cout<<(tf*val).transpose()<<endl;
Eigen::Vector3d的操作
#include <Eigen/Dense>
Eigen::Vector3d a(1.0,2.0,3.0);
在CMake中需要在CMakeLists.txt文件中加入如下
include_directories("/usr/include/eigen3")