Using the rightmost column: Using the rightmost column: Using the rightmost column: Using the rightmost column:
Homogeneous Coordinates
Q: How can we represent translation as a 3x3 matrix? Q: How can we represent translation as a 3x3 matrix?
A: Using the rightmost column: A: Using the rightmost column:
Q: How can we represent translation as a 3x3 matrix? Q: How can we represent translation as a 3x3 matrix?
A: Using the rightmost column: A: Using the rightmost column:
1 1
1
y x
t t
ranslation T
y x
t y
y t
x x
Translation
Example of translation Example of translation
Example of translation Example of translation
1 1
1 1
1
1
y x
y x
t y
t x
y x
t t
y x
t
x
= 2 t
y
= 1
Homogeneous Coordinates Homogeneous Coordinates
Homogeneous Coordinates Homogeneous Coordinates
Homogeneous Coordinates
Add a 3rd coordinate to every 2D point Add a 3rd coordinate to every 2D point
• x, y, w represents a point at location xw, yw
x, y, w represents a point at location xw, yw •
x, y, 0 represents a point at infinity x, y, 0 represents a point at infinity
• 0, 0, 0 is not allowed
0, 0, 0 is not allowed
Add a 3rd coordinate to every 2D point Add a 3rd coordinate to every 2D point
• x, y, w represents a point at location xw, yw
x, y, w represents a point at location xw, yw •
x, y, 0 represents a point at infinity x, y, 0 represents a point at infinity
• 0, 0, 0 is not allowed
0, 0, 0 is not allowed
Convenient coordinate system to
represent many useful transformations
1 2
1 2
2,1,1 or 4,2,2 or 6,3,3
x y
Basic 2D Transformations
Basic 2D transformations as 3x3 matrices Basic 2D transformations as 3x3 matrices
Basic 2D transformations as 3x3 matrices Basic 2D transformations as 3x3 matrices
1 1
cos sin
sin cos
1 y
x y
x
1 1
1 1
1
y x
t t
y x
y x
1 1
1 1
1
y x
sh sh
y x
y x
Translate
Rotate Shear
1 1
1
y x
s s
y x
y x
Scale
Affine Transformations
Affine transformations are combinations of … Affine transformations are combinations of …
• Linear transformations, and
Linear transformations, and •
Translations Translations
Properties of affine transformations: Properties of affine transformations:
• Origin does not necessarily map to origin
Origin does not necessarily map to origin •
Lines map to lines Lines map to lines
• Parallel lines remain parallel
Parallel lines remain parallel •
Ratios are preserved Ratios are preserved
• Closed under composition
Closed under composition
Affine transformations are combinations of … Affine transformations are combinations of …
• Linear transformations, and
Linear transformations, and •
Translations Translations
Properties of affine transformations: Properties of affine transformations:
• Origin does not necessarily map to origin
Origin does not necessarily map to origin •
Lines map to lines Lines map to lines
• Parallel lines remain parallel
Parallel lines remain parallel •
Ratios are preserved Ratios are preserved
• Closed under composition
Closed under composition
w y
x f
e d
c b
a
w y
x
1
Projective Transformations
Projective transformations … Projective transformations …
• Affine transformations, and
Affine transformations, and •
Projective warps Projective warps
Properties of projective transformations: Properties of projective transformations:
• Origin does not necessarily map to origin
Origin does not necessarily map to origin •
Lines map to lines Lines map to lines
• Parallel lines do not necessarily remain parallel
Parallel lines do not necessarily remain parallel •
Ratios are not preserved Ratios are not preserved
• Closed under composition
Closed under composition
Projective transformations … Projective transformations …
• Affine transformations, and
Affine transformations, and •
Projective warps Projective warps
Properties of projective transformations: Properties of projective transformations:
• Origin does not necessarily map to origin
Origin does not necessarily map to origin •
Lines map to lines Lines map to lines
• Parallel lines do not necessarily remain parallel
Parallel lines do not necessarily remain parallel •
Ratios are not preserved Ratios are not preserved
• Closed under composition
Closed under composition
w y
x
i h
g f
e d
c b
a
w y
x
Overview
2D Transformations 2D Transformations
• Basic 2D transformations
Basic 2D transformations
• Matrix representation
Matrix representation
• Matrix composition
Matrix composition
3D Transformations 3D Transformations
• Basic 3D transformations
Basic 3D transformations
• Same as 2D
Same as 2D
2D Transformations 2D Transformations
• Basic 2D transformations
Basic 2D transformations
• Matrix representation
Matrix representation
• Matrix composition
Matrix composition
3D Transformations 3D Transformations
• Basic 3D transformations
Basic 3D transformations
• Same as 2D
Same as 2D
Matrix Composition
Transformations can be combined by Transformations can be combined by
matrix multiplication matrix multiplication
Transformations can be combined by Transformations can be combined by
matrix multiplication matrix multiplication
w y
x sy
sx ty
tx
w y
x
1 1
cos sin
sin cos
1 1
1
p’ = Tt
x
,t
y
R Ss
x
,s
y
p
Matrix Composition
Matrices are a convenient and efficient way to Matrices are a convenient and efficient way to
represent a sequence of transformations represent a sequence of transformations
• General purpose representation
General purpose representation
• Hardware matrix multiply
Hardware matrix multiply
Matrices are a convenient and efficient way to Matrices are a convenient and efficient way to
represent a sequence of transformations represent a sequence of transformations
• General purpose representation
General purpose representation
• Hardware matrix multiply
Hardware matrix multiply
p’ = T R Sp p’ = TRS p
Matrix Composition
Be aware: order of transformations matters Be aware: order of transformations matters
– Matrix multiplication is not commutative
Matrix multiplication is not commutative
Be aware: order of transformations matters Be aware: order of transformations matters
– Matrix multiplication is not commutative
Matrix multiplication is not commutative
p’ = T R S p
“Global” “Local”
Matrix Composition
What if we want to rotate What if we want to rotate
and and
translate? translate?
• Ex:
Ex:
Rotate line segment by 45 degrees about endpoint Rotate line segment by 45 degrees about endpoint
a a
and lengthen and lengthen
What if we want to rotate What if we want to rotate
and and
translate? translate?
• Ex:
Ex:
Rotate line segment by 45 degrees about endpoint Rotate line segment by 45 degrees about endpoint
a a
and lengthen and lengthen
a a
Multiplication Order – Wrong Way
Our line is defined by two endpoints Our line is defined by two endpoints
• Applying a rotation of 45 degrees, R45, affects both points
Applying a rotation of 45 degrees, R45, affects both points •
We could try to translate both endpoints to return endpoint We could try to translate both endpoints to return endpoint
a a
to its to its
original position, but by how much? original position, but by how much?
Our line is defined by two endpoints Our line is defined by two endpoints
• Applying a rotation of 45 degrees, R45, affects both points
Applying a rotation of 45 degrees, R45, affects both points •
We could try to translate both endpoints to return endpoint We could try to translate both endpoints to return endpoint
a a
to its to its
original position, but by how much? original position, but by how much?
Wrong Correct
T-3 R45 T3 R45
a a
a
Multiplication Order - Correct
Isolate endpoint Isolate endpoint
a a
from rotation effects from rotation effects
• First translate line so
First translate line so a
a is at origin: T -3
is at origin: T -3
• Then rotate line 45 degrees: R45
Then rotate line 45 degrees: R45
• Then translate back so
Then translate back so a
a is where it was: T3
is where it was: T3
Isolate endpoint Isolate endpoint
a a
from rotation effects from rotation effects
• First translate line so
First translate line so a
a is at origin: T -3
is at origin: T -3
• Then rotate line 45 degrees: R45
Then rotate line 45 degrees: R45
• Then translate back so
Then translate back so a
a is where it was: T3
is where it was: T3
a
a
a
a
Will this sequence of operations work? Will this sequence of operations work?
Will this sequence of operations work? Will this sequence of operations work?
Matrix Composition
1 1
1 1
3 1
1 45
cos 45
sin 45
sin 45
cos
1 1
3 1
y x
y x
a a
a a
Matrix Composition
After correctly ordering the matrices After correctly ordering the matrices
Multiply matrices together Multiply matrices together
What results is one matrix – What results is one matrix –
store it on stack store it on stack
Multiply this matrix by the vector of each vertex Multiply this matrix by the vector of each vertex
All vertices easily transformed with one matrix All vertices easily transformed with one matrix
multiply multiply
After correctly ordering the matrices After correctly ordering the matrices
Multiply matrices together Multiply matrices together
What results is one matrix – What results is one matrix –
store it on stack store it on stack
Multiply this matrix by the vector of each vertex Multiply this matrix by the vector of each vertex
All vertices easily transformed with one matrix All vertices easily transformed with one matrix
multiply multiply
Overview
2D Transformations 2D Transformations
• Basic 2D transformations
Basic 2D transformations
• Matrix representation
Matrix representation
• Matrix composition
Matrix composition
3D Transformations 3D Transformations
• Basic 3D transformations
Basic 3D transformations
• Same as 2D
Same as 2D
2D Transformations 2D Transformations
• Basic 2D transformations
Basic 2D transformations
• Matrix representation
Matrix representation
• Matrix composition
Matrix composition
3D Transformations 3D Transformations
• Basic 3D transformations
Basic 3D transformations
• Same as 2D
Same as 2D
3D Transformations
Same idea as 2D transformations Same idea as 2D transformations
• Homogeneous coordinates: x,y,z,w
Homogeneous coordinates: x,y,z,w
• 4x4 transformation matrices
4x4 transformation matrices
Same idea as 2D transformations Same idea as 2D transformations
• Homogeneous coordinates: x,y,z,w
Homogeneous coordinates: x,y,z,w
• 4x4 transformation matrices
4x4 transformation matrices
w z
y x
p o
n m
l k
j i
h g
f e
d c
b a
w z
y x
Basic 3D Transformations
w z
y x
w z
y x
1 1
1 1
w z
y x
t t
t
w z
y x
z y
x
1 1
1 1
w z
y x
s s
s
w z
y x
z y
x
1
w z
y x
w z
y x
1 1
1 1
Identity Scale
Translation Mirror about YZ plane
Basic 3D Transformations
w z
y x
w z
y x
1 1
cos sin
sin cos
Rotate around Z axis:
w z
y x
w z
y x
1 cos
sin 1
sin cos
Rotate around Y axis:
w z
y x
w z
y x
1 cos
sin sin
cos 1
Rotate around X axis:
Reverse Rotations
Q: How do you undo a rotation of Q: How do you undo a rotation of