115 字
1 分钟
Games101 pa0
给定一个点P=(2,1),将该点绕原点先逆时针旋转45◦,再平移(1,2),计算出 变换后点的坐标(要求用齐次坐标进行计算)
#include<cmath>#include<Eigen/Core>#include<Eigen/Dense>#include<iostream>
int main() {
Eigen::Vector3f p(2.0f, 1.0f, 1.0f); Eigen::Matrix3f r;
// 提前计算好浮点数角度 float pi = std::acos(-1); float angle = 45.0f / 180.0f * pi;
r << std::cos(angle), -std::sin(angle), 1.0f, std::sin(angle), std::cos(angle), 2.0f, 0.0f, 0.0f, 1.0f;
Eigen::Vector3f result = r * p;
std::cout << "变换后的结果是:\n" << result << std::endl;
return 0;} Games101 pa0
https://dingfengbo.vercel.app/posts/games101/pa0/