GAMES101笔记02:Transformation(变换)+ 作业0

目录

一、Linear Transforms(线性变换)

① Scale Matrix(缩放矩阵)

②Reflection Matrix(反射矩阵)

③Shear Matrix(剪切矩阵)

④Rotation Matrix(旋转矩阵)

​编辑

二、Homogenous Coordinates(齐次坐标)

三、Affine Transformations(仿射变换)

①2D Transformations(二维变换)

②Inverse Transform(逆变换)

③Composing Transforms(合成变换)

④3D Transformations(三维变换)

四、作业0


一、Linear Transforms(线性变换)

① Scale Matrix(缩放矩阵)

②Reflection Matrix(反射矩阵)

③Shear Matrix(剪切矩阵)

④Rotation Matrix(旋转矩阵)

旋转矩阵的逆矩阵就是它的转置矩阵,就是说旋转矩阵是正交矩阵(R^(-1) = R^(T))

二、Homogenous Coordinates(齐次坐标)

三、Affine Transformations(仿射变换)

平移变换不是线性变换,引入仿射变换是为了能用矩阵表示平移变换。

仿射变换中的顺序是先进行线性变换再进行平移(如果有的话)。

①2D Transformations(二维变换)

②Inverse Transform(逆变换)

③Composing Transforms(合成变换)

④3D Transformations(三维变换)

四、作业0

写的代码:

#include<cmath>
#include<eigen3/Eigen/Core>
#include<eigen3/Eigen/Dense>
#include<iostream>

int main(){

    // Basic Example of cpp
    std::cout << "Example of cpp \n";
    float a = 1.0, b = 2.0;
    std::cout << a << std::endl;
    std::cout << a/b ;
    std::cout << std::sqrt(b) << std::endl;
    std::cout << std::acos(-1) << std::endl;
    std::cout << std::sin(30.0/180.0*acos(-1)) << std::endl;

    // Example of vector
    std::cout << "Example of vector \n";
    // vector definition
    Eigen::Vector3f v(1.0f,2.0f,3.0f);
    Eigen::Vector3f w(1.0f,0.0f,0.0f);
    // vector output
    std::cout << "Example of output \n";
    std::cout << v << std::endl;
    // vector add
    std::cout << "Example of add \n";
    std::cout << v + w << std::endl;
    // vector scalar multiply
    std::cout << "Example of scalar multiply \n";
    std::cout << v * 3.0f << std::endl;
    std::cout << 2.0f * v << std::endl;

    // Example of matrix
    std::cout << "Example of matrix \n";
    // matrix definition
    Eigen::Matrix3f i,j;
    i << 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0;
    j << 2.0, 3.0, 1.0, 4.0, 6.0, 5.0, 9.0, 7.0, 8.0;
    // matrix output
    std::cout << "Example of output \n";
    std::cout << i << std::endl;
    // matrix add i + j
    // matrix scalar multiply i * 2.0
    // matrix multiply i * j
    // matrix multiply vector i * v

    double A = 45.0/180.0*acos(-1);
    Eigen::Matrix3f M;
    M << cos(A), -sin(A), 1,
         sin(A), cos(A),  2,
         0,      0,       1;      

    Eigen::Vector3f P(2.0f,1.0f,1.0f);
    P = M * P;
    std::cout << P << std::endl;

    return 0;
}

参考:

GAMES101作业环境搭建,面相和我一样的初学者。_哔哩哔哩_bilibili

【Games 101】 作业0 小白向作业思路推导_哔哩哔哩_bilibili

GAMES101作业0 - 抚琴思伯牙 - 博客园 (cnblogs.com)

GAMES101 作业0 图形学 - HelloWorld开发者社区

GAMES101作业解答-作业0 - levelly - 博客园 (cnblogs.com)

特征:矩阵和向量算术 (eigen.tuxfamily.org)

虚拟机复制代码到主机的方法:

virtualbox实现和主机之间复制粘贴(通过共享文件夹实现)_virtualbox怎么复制主机文件-CSDN博客

  • 9
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

m0_69987707

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值