Professional Documents
Culture Documents
04 Transformations
04 Transformations
Transformations
MIT ECCS 6.837
1
Coordinates and
Transformations
MIT ECCS 6.837
2
Hierarchical modeling
• Many coordinate systems:
• Camera
• Static scene
• car
• driver
• arm
• hand
• ...
3
A Philosophical Point
Where is (0,0,0)?
A Philosophical Point
Where is (0,0,0)?
A Philosophical Point
Did it move?
Observation
Rarely do we use
“absolute” positions
in real life.
Coordinates
• We represent points with tuples of coordinates
such as
• But the tuples are meaningless without a
coordinate system
8
Different objects
• Points
• represent locations
• Vectors
• represent movement, force, displacement from A to B
• Normals
• represent orientation, unit length
• Coordinates
• numerical representation of the above objects
in a given coordinate system
9
Points & vectors are different
• The 0 vector has a fundamental meaning:
no movement, no force
• Why would there be a special 0 point?
+ =?
10
Points & vectors are different
• Moving car
• points describe location of car elements
• vectors describe velocity, distance between pairs of
points
• If I translate the moving car to a different road
• The points (location) change
• The vectors (speed, distance between points) don’t
11
Matrices have two purposes
• (At least for geometry)
• Transform things
• e.g. rotate the car from facing
north to facing east
• Change coordinates
• e.g. given the driver's location in
the coordinate system of the car,
express it in the coordinate
system of the world
12
Goals for today
• How to define coordinate systems
13
Plan
• Vectors
• Points
• Homogenous coordinates
14
Vector space
• Roughly: Set of elements equipped with
addition and scalar multiplication
15
Vector space
• We can use a basis to produce all the vectors in
the space:
• Given n basis vectors
any vector can be written as
here:
16
Linear algebra notation
• can be written as
18
Linear transformation
19
Matrix notation
• Linearity implies
20
Matrix notation
• Linearity implies
• L is determined by
• Algebraic notation:
21
Algebraic notation
• The are also vectors in the same space
• Can be expressed in the same basis:
which gives us
22
Putting everything together
23
Two interpretations
24
So What?
• Many existing fast algorithms for linear algebra
25
Change of basis
• Critical in computer graphics
- world to car to arm to hand coordinate system
- Bezier to B splines and back
• Typical issues:
- Remembering which is M or M-1
- Keeping track of where you are
26
High-level advice
Output Input
Change of basis
• Assume we have two bases and
• And we have the coordinates of in
• Then
• This implies
28
Change of basis
• We have &
• Given the coordinate of in B:
29
Change of basis
• We have &
• Given the coordinate of in B:
• has coordinates in A
• Note how we keep track of the coordinate system
by having the basis on the left
30
Linear Transformations?
•L(p + q) = L(p) + L(q)
•L(ap) = a L(p)
31
Linear Transformations
•L(p + q) = L(p) + L(q)
•L(ap) = a L(p)
Translation
Similitudes is not linear:
Linear
Rigid / Euclidean
f(p) = p+t Scalin
Identit
g
f(ap) = ap+t
Translation ≠ a(p+t)Scaling
y Isotropic
Rotati = aReflection
f(p)
Shea
on
f(p+q) = p+q+t ≠ (p+t)+(q+t) = f(p)r + f(q)
32
Plan
• Vectors
• Points
• Homogenous coordinates
• Normals
33
Points vs. Vectors
• A point is a location
• A vector is a motion between two points
• Adding vectors is meaningful
• going 3km North + 4km East = going 5km North-East
• Adding points is not meaningful
• Boston location + New York location = ?
• Multiplying a point by a scalar?
• The zero vector is meaningful (no movement)
• Zero point ?
34
Affine space
• Points are elements of an affine space
• We denote them with a tilde
35
Algebra notation
• We like matrix-vector expressions
• We want to keep track of the frame
• Cheat a little for elegance; decide that 1 times a
point is the point
37
Affine frames
• A frame is an origin plus a basis B
• We can obtain any point in the space by adding a
vector to the origin
38
Recap
• Vectors can be expressed in a basis
• keep track of basis with left notation
• change basis
• Points can be expressed in a frame
(origin+basis)
• keep track of frame with left notation
• adds a dummy 4th coordinate always 1
39
Affine transformations
• Include all linear transformations
• Applied to the vector basis
• Plus translation
40
Affine matrix
• In 3D a 4 x 4 matrix
Affine transformation
• Applying an affine transform to point
Affine transformation
44
Linear component
46
Translation
47
Full affine expression
• Gives us
to a vector
• Gives us
50
More notation properties
• Vectors are not affected by the translation part
53
Similarity transformation
• Transformation S wrt car frame F
54
How are transforms combined?
Scale then Translate
(5,3)
Scale(2,2) (2,2) Translate(3,1)
(1,1) (3,1)
(0,0) (0,0)
56
Non-commutative Composition
Scale then Translate: p' = T ( S p ) = TS p
1 0 3 2 0 0 2 0 3
TS = 0 1 1 0 2 0 = 0 2 1
0 0 1 0 0 1 0 0 1
57
Plan
• Vectors
• Points
• Homogenous coordinates
• Normals
58
Forward reference and eye
• The fourth coordinate is useful for perspective
projection
• Called homogenous coordinates
59
Homogeneous Coordinates in R 2
where we identify
Encodes points
and directions!
Points at Infinity
Encodes points
and directions!
w=1
w=2
65
Perspective in 2D
• Camera at origin, looking along z, 90 degree
f.o.v., “image plane” at z=1
66
Perspective in 2D
The projected point in
homogeneous
coordinates
(we just added w=1):
67
Perspective in 2D
Projectively
equivalent
68
Perspective in 2D
We’ll just copy z to w,
and get the projected
point after
homogenization!
69
Homogeneous Visualization
• Divide by w to normalize (project)
(0,0,0)
70
Projective Equivalence – Why?
• For affine transformations,
adding w=1 in the end proved to be convenient.
• The real showpiece is perspective.
71
Fun example: Photo tourism
• Application of homogenous coordinates
• Goal: given N photos of a scene
• find where they were taken
• get 3D geometry for points in the scene
72
Step 1: point correspondences
• Extract salient points (corners) from images
• Find the same scene point in other images
• To learn how it’s done, take 6.815
73
Structure from motion
• Given point correspondences
• Unknowns: 3D point location, camera poses
• For each point in each image, write perspective
equations p 4
p1 p3 minimize
p2
f (R, T, P)
p5 p7
p6
Camera 1 Camera 3
R1,t1 Camera 2 R3,t3
R2,t2 74
Eye candy: photo tourism
QuickTime™ and a
MPEG-4 Video decompressor
are needed to see this picture.
75
That’s All for Today
• Further Reading
–Buss, Chapter 2
76