games101笔记 坐标变换

games101 坐标变换

3D 变换

  • \(3D~point = (x, y, z, \textbf{1})^T\)
  • \(3D~vector = (x, y, z, \textbf{0})^T\)

​ 一般地 \((x, y, z, w) (w != 0)\) 是一个3D的点:

\((x/w, y/w, z/w)\)

3D 旋转

  • \(\textbf{Euler angles}\)

    • \(Roll\):面

    • \(Yaw\):颈

    • \(Pitch\):耳

Rodrigues's Rotation Formula

  • 通过 \(\alpha\) 角和 \(n\)

\(\R(n, \alpha) = cos(\alpha)I + (1 - cos(\alpha))nn^T + sin(\alpha)\underbrace{\left[ \begin{matrix} 0 & -n_z & n_y\\ n_z & 0 & -n_x\\-n_y & n_x & 0 \end{matrix} \right]}_{\text{N}}\)

后面的矩阵其实也就是 叉乘 的矩阵的形式

\(I\) 是单位矩阵 \(Identity~Matrix\)

  • 一些默认
    • 起点在原点上
    • 方向是 \(n\) 的方向

​ 如果要绕任意点旋转,可以先将该点平移到原点,旋转后再平移回去

Viewing/Camera transformation

  • 定义相机的位置

    • \(Position~ \vec{e}\)
    • \(look~at/gaze~direction~ \widehat{g}\)
    • \(up~direction~\widehat{t}\)
  • 一些约定俗成的事儿

    • up at \(Y\)
    • look at -\(Z\)
    • origin
  • Mview in math

    \(M_{view} = R_{view}T_{view}\)

    • Translate \(\vec{e}\) to origin

      \(T_{view} = \left[\begin{matrix}1 & 0 & 0 & -x_e \\ 0 & 1 & 0 & -y_e\\0 & 0 & 1 & -z_e \\ 0 & 0 & 0 & 1\end{matrix}\right]\)

    • Rotates \(\widehat{g}\) to -\(Z\)\(\widehat{t}\) to \(Y\)\((\widehat{g} \times \widehat{t})\) to \(X\)

      \(R_{view}^{-1} = \left[\begin{matrix}x_{\widehat{g}\times\widehat{t}} & x_t & x_{-g} & 0\\y_{\widehat{g}\times\widehat{t}} & y_t & y_{-g} & 0\\z_{\widehat{g}\times\widehat{t}} & z_t & z_{-g} & 0\\0 & 0 & 0 & 1\end{matrix}\right]\) \(\Rightarrow\) \(R_{view} = \left[\begin{matrix}x_{\widehat{g}\times\widehat{t}} & y_{\widehat{g}\times\widehat{t}} & z_{\widehat{g}\times\widehat{t}} & 0\\x_t & y_t & z_t & 0 \\x_{-g} & y_{-g} & z_{-g} & 0\\0 & 0 & 0 & 1\end{matrix}\right]\)

posted @ 2021-12-01 18:01  blahhhh  阅读(61)  评论(0)    收藏  举报