有时候在计算旋转角和旋转矩阵的时候,需要用到旋转轴的方向向量,这个时候就需要对旋转轴向量做归一化。这里记录一下使用c++环境下的eigen库的方法。这样就不用自己去写平方和再做除法了。
代码
#include<iostream>
#include<vector>
#include<Eigen/Dense>
using namespace std;
int main()
{
Eigen::Vector3d a;
a << 1.0, 2.0, 3.0;
cout << a.transpose() << endl;
a.normalize();
cout << a.transpose() << endl;
return 0;
}