没啥好说的……mac直接xcode写了,后面不行再重配环境吧。
代码
main.cpp
#include <cmath>
#include <iostream>
#include <eigen3/Eigen/Core>
int main_pa0(int argc, const char * argv[]) {
Eigen::Vector2d v = {2, 1};
//绕原点逆时针旋转45度
double theta = EIGEN_PI / 4; // 90度旋转
Eigen::Matrix2d rMat;
rMat << cos(theta), -sin(theta), sin(theta), cos(theta);
Eigen::Vector2d rotatedP = rMat * v;
//平移(1,2)
Eigen::Vector2d v_translation={1, 2};
Eigen::Vector2d result = rotatedP + v_translation;
std::cout<< result << std::endl;
return 0;
}
结果
1.70711
4.12132