SLIDE 2
What did we talk about last time? Lines and planes Trigonometry Transforms
SLIDE 3
SLIDE 4
SLIDE 5
SLIDE 6
SLIDE 7 A transform is an operation that changes points, vectors, or
colors
We can use them to position and animate objects, lights, and
cameras
A linear transform is one that holds over vector addition and
scalar multiplication
- Rotation
- Scaling
- Can be represented by a 3 x 3 matrix
SLIDE 8 Adding a vector after a linear transform makes an affine
transform
Affine transforms can be stored in a 4 x 4 matrix using
homogeneous notation
Affine transforms:
- Translation
- Rotation
- Scaling
- Reflection
- Shearing
SLIDE 9
Notation Name Characteristics T(t) Translation matrix Moves a point (affine) R Rotation matrix Rotates points (orthogonal and affine) S(s) Scaling matrix Scales along x, y, and z axes according to s (affine) Hij(s) Shear matrix Shears component i by factor s with respect to component j E(h,p,r) Euler transform Orients by Euler angles head (yaw), pitch, and roll (orthogonal and affine) Po(s) Orthographic projection Parallel projects onto a plane or volume (affine) Pp(s) Perspective projection Project with perspective onto a plane or a volume slerp(q,r,t) Slerp transform Interpolates quaternions q and r with parameter t
SLIDE 10 Move a point from one place to another by vector t = (tx, ty, tz) We can represent this with translation matrix T = = 1 1 1 1 ) , , ( ) (
z y x z y x
t t t t t t T t T
SLIDE 11
Rotation, like translation, is a rigid-body transform (points
don't change distance from each other and handedness doesn't change)
An orientation matrix is used to define up and forward
(usually for a camera)
We often express rotation in terms of 3 separate x, y, and z
rotation matrices
SLIDE 12 − = 1 cos sin sin cos 1 ) ( φ φ φ φ φ
x
R − = 1 cos sin 1 sin cos ) ( φ φ φ φ φ
y
R − = 1 1 cos sin sin cos ) ( φ φ φ φ φ
z
R
SLIDE 13 Usually all the rotations are multiplied together before
translations
But if you want to rotate around a point
- Translate so that that point lies at the origin
- Perform rotations
- Translate back
SLIDE 14 Scaling is easy and can be done for all axes at the same time
with matrix S
If sx = sy = sz, the scaling is called uniform or isotropic and
nonuniform or anisotropic otherwise
= 1 ) (
z y x
s s s s S
SLIDE 15 A shearing transform distorts one dimension in terms of
another with parameter s
Thus, there are six shearing matrices Hxy(s), Hxz(s), Hyx(s),
Hyz(s), Hzx(s), and Hzy(s)
Here's an example of Hxz(s):
= 1 1 1 1 ) ( s s
xz
H
SLIDE 16
To make Hij(s), start with the identity matrix and put s in row i,
column j
See how the only the affected dimension changes
SLIDE 17 Because matrix multiplications are not commutative, order of
transforms matters
Still, parts (or the entirety) of the transform can be
precomputed and stored as a single matrix
In math world, matrices are applied from right to left, thus
TRSp scales point p, rotates it, then translates it
In the MonoGame world, it's the opposite!
SLIDE 18 This example from the book shows how the same sets of
transforms, applied in different orders, can have different
SLIDE 19 A rigid-body transform preserves lengths, angles, and
handedness
We can write any rigid-body transform X as a rotation matrix
R multiplied by translation matrix T(t) = = 1 ) (
22 21 20 12 11 10 02 01 00 z y x
t r r r t r r r t r r r R t T X
SLIDE 20 Because R is orthogonal, its inverse is its
transpose
Because of the nature of a translation, its inverse
is just its negative
Thus, the inverse of X is
- X-1 = (T(t)R)-1 = R-1T(t)-1 = RTT(-t)
SLIDE 21
SLIDE 22
SLIDE 23 The matrix used to transform points will not always work on surface
normals
Rotation is fine
- Uniform scaling can stretch the normal (which should be unit)
- Non-uniform scaling distorts the normal
Transforming by the transpose of the adjoint always gives the correct
answer
In practice, the transpose of the inverse is usually used
SLIDE 24 Because of the singular value theorem, we can write any square, real-
valued matrix M with positive determinant as:
- M = R1SR2
- where R1 and R2 are rotation matrices and S is a scaling matrix
(M-1)T
= ((R1SR2)-1)T = (R2
= (R1
= R1S-1 R2
Rotations are fine for the normals, but non-uniform scaling will distort
them
The transpose of the inverse distorts the scale in the opposite direction
SLIDE 25
- 1. With homogeneous notation, translations do not affect normals
at all
- 2. If only using rotations, you can use the regular world transform
for normals
- 3. If using rotations and uniform scaling, you can use the world
transform for normals
- However, you'll need to normalize your normals so they are unit
- 4. If using rotations and non-uniform scaling, use the transpose of
the inverse or the transpose of the adjoint
- They only differ by a factor of the determinant, and you'll have to
normalize your normals anyway
SLIDE 26
SLIDE 27
Euler angles Quaternions Vertex blending Morphing Projections
SLIDE 28
Keep reading Chapter 4 Project 1 due Friday Assignment 2 due next Friday