现代计算机图形学Games101笔记

Reaepita Lv2

变换

2D变换

缩放

image-20230801134529937
$$



$$

切变

image-20230801134826638
$$



$$

旋转

image-20230801140824895
$$
R_{\theta}


$$

齐次坐标

考虑到使用二维矩阵进行平移操作并不是线性变换,故考虑使用齐次坐标系。

  • Scale

  • Rotation

  • Translation

3D变换

齐次坐标

点:

向量:

旋转向量与欧拉角

  • 在三维坐标系中:


xxxxxxxxxx Point get_nearest_point_on_segment(Point a,Line a1){ Point b=a1.s,c=a1.e; double t=dot(a-b,c-b)/dot(c-b,c-b); if(dcmp(t)!=-1&&dcmp(1-t)!=-1)return Vector(b.x+(c.x-b.x)*t,b.y+(c.y-b.y)*t); if(dist(a,b)<dist(a,c))return b; return c;}cpp

可以表示以任意旋转后的向量

视图变换

  • Position:
  • look-at/gaze direction:
  • up direction:

image-20230801212420549

相机默认的向上方向为 。永远朝着 方向看,永远在原点上。

任意点相机移回原点

  • 先平移

  • 再旋转

    实际上, 是正交矩阵所以 是由 求出的。

投影变换

  • 正交投影

    image-20230803104631665

要将任意的立方体变成标准立方体

先平移再缩放

image-20230803105018289

  • 透视投影

image-20230803104705500

首先将视锥体压扁成立方体

再做正交变换

  • Title: 现代计算机图形学Games101笔记
  • Author: Reaepita
  • Created at: 2022-09-09 19:47:59
  • Updated at: 2023-08-06 16:06:16
  • Link: https://harrybh.github.io/2022/09/09/现代计算图形学Game101笔记/
  • License: This work is licensed under CC BY-NC-SA 4.0.
 Comments
On this page
现代计算机图形学Games101笔记