栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

【Games101-0】

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【Games101-0】

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

Games101-0
  • 作业描述
  • 一、题解
  • 二、C++
  • 笔记


作业描述

给定一个点P=(2,1), 将该点绕原点先逆时针旋转45◦,再平移(1,2), 计算出变换后点的坐标(要求用齐次坐标进行计算)


$$$$

一、题解

公式
( x ′ y ′ 1 ) = ( cos ⁡ θ − sin ⁡ θ 1 sin ⁡ θ cos ⁡ θ 2 0 0 1 ) ⋅ ( 2 1 1 ) left(begin{matrix}x' \ y' \ 1 end{matrix}right)=left(begin{matrix}cos{theta} & -sin{theta} & 1 \ sin{theta} & cos{theta} & 2 \0 & 0 & 1end{matrix}right) cdot left(begin{matrix}2 \ 1 \ 1 end{matrix}right) ⎝⎛​x′y′1​⎠⎞​=⎝⎛​cosθsinθ0​−sinθcosθ0​121​⎠⎞​⋅⎝⎛​211​⎠⎞​
其中 θ = 4 5 ∘ {theta}=45^circ θ=45∘角。

二、C++
#include 
#include "Eigen/Core"
#include "Eigen/Dense"
#include 

using namespace std;

int main()
{
    Eigen::Vector3f point(2.0, 1.0, 1.0);       // 定义向量
    Eigen::Matrix3f transform1, transtorm3;     //定义矩阵
    float r = sqrt(2) / 2;                      // cos45 sin45 都是sqrt(2)/2
    transform1 << r, -r, 1.0, r, r, 2.0, 0.0, 0.0, 1.0;
    Eigen::Vector3f pointCur = transform1 * point;
    cout << pointCur;
    
    return 0;
}


笔记

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/982943.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号