Lec 04 Transformations Cont.
Menu of this lecture
3D Transformations
Scale:
Translation:
3D Rotations
Compose from \(R_x, R_y, R_z\)
The rotation part of \(R_y(\theta)\) is different from common rotation matrix, because \(\vec{y}=\vec{z}\times\vec{x}\), which is not the common sequence xyzxyz.
When rotating around x-, y-, and z- axis with angle \(\alpha, \beta, \gamma\) respectively (\(\alpha, \beta, \gamma\) are called Euler angles),
Rodrigues' Rotation Formation
Rotation by angle \(\alpha\) around axis n,
If the axis of rotation does not pass through the origin, first translate the entire system so that the axis passes through the origin, perform the rotation, and then translate the entire system back to its original position.
Quaternions can be used for interpolation between rotation angles.
Viewing transformations
MVP Transformations:
- Model transformations (arrange objects and places)
- View transformations (arrange angles)
- Projection transformations
Define camera
- position: \(\hat{e}\) (points from the origin to the camera)
- look-at / gaze direction: \(\hat{g}\) (points from the camera to the object)
- up direction: \(\hat{t}\)
Usually we transform the camera to the origin, up at Y, look at -Z.
And transform the objects along with the camera.
Transform the camera (MV transformation)
Steps:
- Translate e to origin (\(T_{view}\))
- Rotate g to -Z, t to Y, (g, x, t) to x (\(R_{view}\))
\(T_{view}\):
\(R_{view}\): Consider its inverse rotation (X to (g, x, t), Y to t, Z to -g).
Since \(R_{view}\) is orthoganal,
Projection transformation
Two 3D -> 2D types:
- orthographic projection
- perspective projection
Orthographic projection
Consider a cuboid \([l,r]\times[b,t]\times[f,n]\), map it to the canonical cube \([-1,1]^3\), and drop Z coordinate to project.
Why we just need to drop Z coordinate?
In the "Define camera" part, we define the camera located at the origin, up at Y, look at -Z.
Perspective projection
Illustration:
Steps:
1. Squish the frustum into a cuboid, all points on the near plane remain unchanged, all points on the far plane undergo in-plane contraction, with the center point of the far plane remaining fixed.
2. Do orthographic projection.
Derivation
Squish illustration:
thus,
According to the properties of squishing, consider a point on the near plane and the middle point on the far plane to solve the third row.
- \((x,y,n,1)\to(x,y,n,1)=(nx,ny,n^2,n)\)
\(n^2\) is unrelated to x and y, thus \(A=B=0, Cn+D=n^2\) - \((0,0,f,1)\to(0,0,f,1)=(0,0,f^2,f)\)
\(Cf+D=f^2\)
Solve the equations above:
comment
Both the direction and order of rotation must be reversed.