CSCI 461: Computer Graphics
Middlebury College, Fall 2023
Lecture 04: Scenes
We have always been looking down the z-axis!
By the end of today's lecture, you will be able to:
-
set up a camera to look in more general directions,
-
use
homogeneous coordinates to represent all our 3d
transformations with a 4x4 matrix,
-
compound rotations, scalings and translations of objects in your
scene into a model matrix,
-
transform the normal vector of objects in your scene using a
normal matrix.
Pointing the camera at some point to "look at."
What is the ray direction then?
How should we place a model in the scene?
How should we place a model in the scene?
How should we place a model in the scene?
How should we place a model in the scene?
How do we animate and/or interact with our model?
Transformations! We'll look at scaling, rotations and
translations.
Scaling transformation stretches points in each dimension.
Scaling transformation stretches points in each dimension (can be
non-uniform).
Rotation matrix rotates vectors by an angle about some axis.
Rotations about the x, y and z-axes.
$$ \mathbf{R}_{\theta,x} = \left[ \begin{array}{ccc} 1 & 0 & 0 \\ 0
& \cos\theta & -\sin\theta \\ 0 & \sin\theta & \phantom{-}\cos\theta
\end{array}\right]$$ $$\mathbf{R}_{\theta,y} = \left[
\begin{array}{ccc} \phantom{-}\cos\theta & 0 & \sin\theta \\ 0 & 1 &
0 \\ -\sin\theta & 0 & \cos\theta \end{array} \right] $$
$$\mathbf{R}_{\theta,z} = \left[ \begin{array}{ccc} \cos\theta &
-\sin\theta & 0 \\ \sin\theta & \phantom{-}\cos\theta & 0 \\ 0 & 0 &
1 \end{array} \right]$$
How to represent a translation (shift) with a matrix?
Homogeneous coordinates is a trick to combine everything into a
single matrix.
Main idea: introduce new coordinate equal to 1 for points.
Combining transformations: read from right-to-left!
Exercise 1: Transform the top-right corner (dot) of the square.
$$\mathrm{Using:}\quad \mathbf{S} = \left[ \begin{array}{ccc} s & 0
& 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{array} \right], \quad \mathbf{R}
= \left[ \begin{array}{ccc} \phantom{-} \cos\theta & \sin\theta & 0
\\ -\sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{array} \right],
\quad \mathbf{T} = \left[ \begin{array}{ccc} 1 & 0 & -p_x \\ 0 & 1 &
-p_y \\ 0 & 0 & 1 \end{array} \right]. $$
Exercise 1 solution: $\mathbf{M} = \mathbf{T}^{-1}\mathbf{R}^{-1}
\mathbf{S}\mathbf{R}\mathbf{T}$.
Transform normals using the inverse-transpose of your
transformation.
Summary
- Transform ray direction using change-of-basis $\mathbf{B}$,
- Read transformations from right-to-left.
-
Transform normals using inverse-transpose of transformation.