04-transformation Cont

70 阅读1分钟

viewing transformation

View transformation:

think about how to take a photo?

  • Finda good place arrange people(model transformation)
  • Find a good "angle" to put the camera(view transformation)
  • Cheese(projection transformation)

how to perform view transformation?

  1. define the camera
  • camera position
  • gaize direction
  • up direction
  1. key observation
  • If the camera and objects move together,the picture will be the same
  1. how to transform the camera?
  • the origin,up at Y,look at -Z
  • transform the object along with the camera
  1. transform the camera by MviewM_view
  • Mview=RviewTviewM_view=R_{view}T_{view}
  • 即先进行平移再旋转

Tview=[a00x010y001z0001]T_{view}={\begin{bmatrix} a & 0 & 0 & -x \\ 0& 1 & 0 & -y \\ 0 & 0 & 1 & -z \\ 0 & 0&0& 1 \end{bmatrix}} 对于矩阵RviewR_view直接写出来较为困难,but它的逆矩阵容易写出来即

Snipaste_2024-02-18_11-42-24.png 对于旋转矩阵来讲它的逆=它的转置

Summary:

  • transform objects together with the camera
  • Until camera's at origin up at Y,look at -Z

Projection transformation:

Snipaste_2024-02-18_11-47-04.png

Orthographic Projection:

A simple way of understanding:

  1. Drop the Z coordinate
  2. Translate and scale the resulting rectangle to[1,1]2[-1,1]^2

Snipaste_2024-02-18_11-55-44.png

Perspective Projection:

  • Most common in Computer Graphics
  • Further objects are smaller
  • Parallel lines not parallel, converge to a point

How to do perspective projection?

  1. “squish to a cuboid ”
  2. Do orthographic projection

Mperspective=MorthographicMperspectiveorthographicM_{perspective}=M_{orthographic}M{perspective{\Rightarrow}{orthographic}}