lecture05.ppt 1132KB Jun 23 2011 12:09:44 PM
Introduction to
Computer Graphics
CS 445 / 645
Lecture 5
Lecture 5
Transformations
Transformations Lecture 5
Lecture 5
Transformations Transformations
(2)
Modeling Transformations
Specify transformations for objects
Specify transformations for objects
• Allows definitions of objects in own coordinate systemsAllows definitions of objects in own coordinate systems • Allows use of object definition multiple times in a sceneAllows use of object definition multiple times in a scene
–Remember how OpenGL provides a transformation stack Remember how OpenGL provides a transformation stack
because they are so frequently reused
because they are so frequently reused
Chapter 5 from Hearn and Baker
Chapter 5 from Hearn and Baker
Specify transformations for objects Specify transformations for objects
• Allows definitions of objects in own coordinate systemsAllows definitions of objects in own coordinate systems
• Allows use of object definition multiple times in a sceneAllows use of object definition multiple times in a scene
–Remember how OpenGL provides a transformation stack Remember how OpenGL provides a transformation stack
because they are so frequently reused
because they are so frequently reused
Chapter 5 from Hearn and Baker Chapter 5 from Hearn and Baker
(3)
Overview
2D Transformations
2D Transformations
• Basic 2D transformationsBasic 2D transformations • Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations
3D Transformations
• Basic 3D transformationsBasic 3D transformations • Same as 2DSame as 2D
2D Transformations 2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition 3D Transformations 3D Transformations
• Basic 3D transformationsBasic 3D transformations • Same as 2DSame as 2D
(4)
2D Modeling Transformations
Scale Rotate Translate
Scale Translate
x y
World Coordinates Modeling
(5)
2D Modeling Transformations
x y
World Coordinates Modeling
Coordinates
Let’s look at this in detail…
(6)
2D Modeling Transformations
x y
Modeling Coordinates
Initial location at (0, 0) with x- and y-axes aligned
(7)
2D Modeling Transformations
x y
Modeling Coordinates
Scale .3, .3
Rotate -90 Translate 5, 3
(8)
2D Modeling Transformations
x y
Modeling Coordinates
Scale .3, .3
Rotate -90
(9)
2D Modeling Transformations
x y
Modeling Coordinates
Scale .3, .3 Rotate -90
Translate 5, 3
(10)
Scaling
Scaling
Scaling a coordinate means multiplying each of its a coordinate means multiplying each of its components by a scalar
components by a scalar
Uniform scaling
Uniform scaling means this scalar is the same for all means this scalar is the same for all components:
components:
Scaling
Scaling a coordinate means multiplying each of its a coordinate means multiplying each of its components by a scalar
components by a scalar
Uniform scaling
Uniform scaling means this scalar is the same for all means this scalar is the same for all components:
components:
(11)
Non-uniform scaling
Non-uniform scaling: different scalars per component:: different scalars per component:
How can we represent this in matrix form?
How can we represent this in matrix form? Non-uniform scaling
Non-uniform scaling: different scalars per component:: different scalars per component:
How can we represent this in matrix form?
How can we represent this in matrix form?
Scaling
X 2,
(12)
Scaling
Scaling operation:
Scaling operation:
Or, in matrix form:
Or, in matrix form: Scaling operation: Scaling operation:
Or, in matrix form: Or, in matrix form:
by
ax
y
x
'
'
y
x
b
a
y
x
0
0
'
'
(13)
2-D Rotation
(x, y)
(x’, y’)
x’ = x
cos
(
) - y
sin
(
)
y’ = x
sin
(
) + y
cos
(
)
(14)
2-D Rotation
x = r cos ()
y = r sin ()
x’ = r cos ( + )
y’ = r sin ( + )
Trig Identity…
x’ = r cos() cos() – r sin() sin()
y’ = r sin() sin() + r cos() cos()
Substitute…
x’ = x cos() - y sin()
y’ = x sin() + y cos()
(x, y)
(x’, y’)
(15)
2-D Rotation
This is easy to capture in matrix form: This is easy to capture in matrix form:
Even though sin(
Even though sin() and cos() and cos() are nonlinear functions ) are nonlinear functions of
of ,,
• x’ is a linear combination of x and yx’ is a linear combination of x and y • y’ is a linear combination of x and yy’ is a linear combination of x and y
This is easy to capture in matrix form:
This is easy to capture in matrix form:
Even though sin(
Even though sin() and cos() and cos() are nonlinear functions ) are nonlinear functions
of
of ,,
• x’ is a linear combination of x and yx’ is a linear combination of x and y
• y’ is a linear combination of x and yy’ is a linear combination of x and y
y x y
x
cos sin
sin cos
' '
(16)
Basic 2D Transformations
Translation:
Translation:
• x’ = x + tx’ = x + txx • y’ = y + ty’ = y + tyy
Scale:
Scale:
• x’ = x * sx’ = x * sxx • y’ = y * sy’ = y * syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y • y’ = y + hy’ = y + hyy*x*x
Rotation:
Rotation:
• x’ = x*cosx’ = x*cos - y*sin - y*sin
• y’ = x*siny’ = x*sin + y*cos + y*cos
Translation:
Translation:
• x’ = x + tx’ = x + txx
• y’ = y + ty’ = y + tyy
Scale:
Scale:
• x’ = x * sx’ = x * sxx
• y’ = y * sy’ = y * syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y
• y’ = y + hy’ = y + hyy*x*x Rotation:
Rotation:
• x’ = x*cosx’ = x*cos - y*sin - y*sin
• y’ = x*siny’ = x*sin + y*cos + y*cos
Transformations can be combined (with simple algebra)
(17)
Basic 2D Transformations
Translation:
Translation:
• x’ = x + tx’ = x + txx • y’ = y + ty’ = y + tyy
Scale:
Scale:
• x’ = x * sx’ = x * sxx • y’ = y * sy’ = y * syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y • y’ = y + hy’ = y + hyy*x*x
Rotation:
Rotation:
• x’ = x*cosx’ = x*cos - y*sin - y*sin
• y’ = x*siny’ = x*sin + y*cos + y*cos
Translation:
Translation:
• x’ = x + tx’ = x + txx
• y’ = y + ty’ = y + tyy
Scale:
Scale:
• x’ = x * sx’ = x * sxx
• y’ = y * sy’ = y * syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y
• y’ = y + hy’ = y + hyy*x*x Rotation:
Rotation:
• x’ = x*cosx’ = x*cos - y*sin - y*sin
(18)
Basic 2D Transformations
Translation:
Translation:
• x’ = x + tx’ = x + txx • y’ = y + ty’ = y + tyy
Scale:
Scale:
• x’ = x x’ = x * s* sxx • y’ = y y’ = y * s* syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y • y’ = y + hy’ = y + hyy*x*x
Rotation:
Rotation:
• x’ = x*cosx’ = x*cos - y*sin - y*sin
• y’ = x*siny’ = x*sin + y*cos + y*cos
Translation:
Translation:
• x’ = x + tx’ = x + txx
• y’ = y + ty’ = y + tyy
Scale:
Scale:
• x’ = x x’ = x * s* sxx
• y’ = y y’ = y * s* syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y
• y’ = y + hy’ = y + hyy*x*x Rotation:
Rotation:
• x’ = x*cosx’ = x*cos - y*sin - y*sin
• y’ = x*siny’ = x*sin + y*cos + y*cos
x’ = x*sx y’ = y*sy
x’ = x*sx
y’ = y*sy
(x,y)
(19)
Basic 2D Transformations
x’ = (x*sx)*cos - (y*sy)*sin
y’ = (x*sx)*sin + (y*sy)*cos x’ = (x*sx)*cos - (y*sy)*sin
y’ = (x*sx)*sin + (y*sy)*cos
(x’,y’)
Translation:
Translation: • x’ = x + tx’ = x + txx
• y’ = y + ty’ = y + tyy
Scale:
Scale:
• x’ = x * sx’ = x * sxx
• y’ = y * sy’ = y * syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y
• y’ = y + hy’ = y + hyy*x*x
Rotation:
Rotation:
• x’ = x*x’ = x*coscos - y* - y*sinsin
• y’ = x*y’ = x*sinsin + y* + y*coscos
Translation:
Translation:
• x’ = x + tx’ = x + txx
• y’ = y + ty’ = y + tyy Scale:
Scale:
• x’ = x * sx’ = x * sxx
• y’ = y * sy’ = y * syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y
• y’ = y + hy’ = y + hyy*x*x
Rotation:
Rotation:
• x’ = x*x’ = x*coscos - y* - y*sinsin
(20)
Basic 2D Transformations
Translation:
Translation:
• x’ = x x’ = x + t+ txx • y’ = y y’ = y + t+ tyy
Scale:
Scale:
• x’ = x * sx’ = x * sxx • y’ = y * sy’ = y * syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y • y’ = y + hy’ = y + hyy*x*x
Rotation:
Rotation:
• x’ = x*cosx’ = x*cos - y*sin - y*sin
• y’ = x*siny’ = x*sin + y*cos + y*cos
Translation:
Translation:
• x’ = x x’ = x + t+ txx
• y’ = y y’ = y + t+ tyy
Scale:
Scale:
• x’ = x * sx’ = x * sxx
• y’ = y * sy’ = y * syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y
• y’ = y + hy’ = y + hyy*x*x Rotation:
Rotation:
• x’ = x*cosx’ = x*cos - y*sin - y*sin
• y’ = x*siny’ = x*sin + y*cos + y*cos
x’ = ((x*sx)*cos - (y*sy)*sin) + tx
y’ = ((x*sx)*sin + (y*sy)*cos) + ty x’ = ((x*sx)*cos - (y*sy)*sin) + tx
y’ = ((x*sx)*sin + (y*sy)*cos) + ty
(21)
Basic 2D Transformations
Translation:
Translation:
• x’ = x + tx’ = x + txx • y’ = y + ty’ = y + tyy
Scale:
Scale:
• x’ = x * sx’ = x * sxx • y’ = y * sy’ = y * syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y • y’ = y + hy’ = y + hyy*x*x
Rotation:
Rotation:
• x’ = x*cosx’ = x*cos - y*sin - y*sin
• y’ = x*siny’ = x*sin + y*cos + y*cos
Translation:
Translation:
• x’ = x + tx’ = x + txx
• y’ = y + ty’ = y + tyy
Scale:
Scale:
• x’ = x * sx’ = x * sxx
• y’ = y * sy’ = y * syy
Shear:
Shear:
• x’ = x + hx’ = x + hxx*y*y
• y’ = y + hy’ = y + hyy*x*x Rotation:
Rotation:
• x’ = x*cosx’ = x*cos - y*sin - y*sin
• y’ = x*siny’ = x*sin + y*cos + y*cos
x’ = ((x*sx)*cos - (y*sy)*sin) + tx
y’ = ((x*sx)*sin + (y*sy)*cos) + ty x’ = ((x*sx)*cos - (y*sy)*sin) + tx
(22)
Overview
2D Transformations
2D Transformations
• Basic 2D transformationsBasic 2D transformations • Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations
3D Transformations
• Basic 3D transformationsBasic 3D transformations • Same as 2DSame as 2D
2D Transformations 2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition 3D Transformations 3D Transformations
• Basic 3D transformationsBasic 3D transformations • Same as 2DSame as 2D
(23)
Matrix Representation
Represent 2D transformation by a matrix
Represent 2D transformation by a matrix
Multiply matrix by column vector
Multiply matrix by column vector
apply transformation to point apply transformation to pointRepresent 2D transformation by a matrix Represent 2D transformation by a matrix
Multiply matrix by column vector Multiply matrix by column vector
apply transformation to point apply transformation to point
y x d
c b a
y x
' '
d
c b
a
dy cx
y
by ax
x
' '
(24)
Matrix Representation
Transformations combined by multiplication
Transformations combined by multiplication Transformations combined by multiplication Transformations combined by multiplication
y x l
k
j i
h g
f e
d c b a
y x
' '
Matrices are a convenient and efficient way to represent a sequence of transformations!
(25)
2x2 Matrices
What types of transformations can be
What types of transformations can be
represented with a 2x2 matrix?
represented with a 2x2 matrix?
What types of transformations can be What types of transformations can be
represented with a 2x2 matrix? represented with a 2x2 matrix?
2D Identity? y y x x ' ' y x y x 1 0 0 1 ' '
2D Scale around (0,0)?
y s y x s x y x * ' * ' y x s s y x y x 0 0 ' '
(26)
2x2 Matrices
What types of transformations can be
What types of transformations can be
represented with a 2x2 matrix?
represented with a 2x2 matrix?
What types of transformations can be What types of transformations can be
represented with a 2x2 matrix? represented with a 2x2 matrix?
2D Rotate around (0,0)?
y x
y x y
x
* cos
* sin
' cos * sin * ' y x y x cos sin sin cos ' ' 2D Shear? y x sh y y sh x x y x * ' * ' y x sh sh y x y x 1 1 ' '
(27)
2x2 Matrices
What types of transformations can be
What types of transformations can be
represented with a 2x2 matrix?
represented with a 2x2 matrix?
What types of transformations can be What types of transformations can be
represented with a 2x2 matrix? represented with a 2x2 matrix?
2D Mirror about Y axis?
y y x x ' ' y x y x 1 01 0 '
'
2D Mirror over (0,0)?
y y x x ' ' y x y x 1 01 0 '
(28)
2x2 Matrices
What types of transformations can be
What types of transformations can be
represented with a 2x2 matrix?
represented with a 2x2 matrix?
What types of transformations can be What types of transformations can be
represented with a 2x2 matrix? represented with a 2x2 matrix?
2D Translation? y
x
t y
y
t x
x
' '
Only linear 2D transformations
can be represented with a 2x2 matrix NO!
(29)
Linear Transformations
Linear transformations are combinations of …
Linear transformations are combinations of … • Scale,Scale,
• Rotation,Rotation, • Shear, andShear, and
• MirrorMirror
Properties of linear transformations:
Properties of linear transformations: • Satisfies:Satisfies:
• Origin maps to originOrigin maps to origin
• Lines map to linesLines map to lines
• Parallel lines remain parallelParallel lines remain parallel • Ratios are preservedRatios are preserved
• Closed under compositionClosed under composition
Linear transformations are combinations of …
Linear transformations are combinations of …
• Scale,Scale,
• Rotation,Rotation,
• Shear, andShear, and
• MirrorMirror
Properties of linear transformations:
Properties of linear transformations:
• Satisfies:Satisfies:
• Origin maps to originOrigin maps to origin
• Lines map to linesLines map to lines
• Parallel lines remain parallelParallel lines remain parallel
• Ratios are preservedRatios are preserved
• Closed under compositionClosed under composition
) (
) (
)
(s1p1 s2p2 s1T p1 s2T p2
T
y x d
c
b a
y x ' '
(30)
Homogeneous Coordinates
Q: How can we represent translation as a 3x3 matrix?
Q: How can we represent translation as a 3x3 matrix? Q: How can we represent translation as a 3x3 matrix? Q: How can we represent translation as a 3x3 matrix?
y x
t y
y
t x
x
' '
(31)
Homogeneous Coordinates
Homogeneous coordinates
Homogeneous coordinates
• represent coordinates in 2 represent coordinates in 2
dimensions with a 3-vector
dimensions with a 3-vector
Homogeneous coordinates
Homogeneous coordinates
• represent coordinates in 2 represent coordinates in 2
dimensions with a 3-vector
dimensions with a 3-vector
1
coords s
homogeneou
y
x
y
x
Homogeneous coordinates seem unintuitive, but they Homogeneous coordinates seem unintuitive, but they
make graphics operations
make graphics operations muchmuch easier easier
Homogeneous coordinates seem unintuitive, but they
Homogeneous coordinates seem unintuitive, but they
make graphics operations
(32)
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 0
0
1 0
0 1
y x
t t ranslation
T
y x
t y
y
t x
x
' '
(33)
Translation
Example of translation
Example of translation
Example of translation
Example of translation
1 1 1 0 0 1 0 0 1 1 ' ' y x y x t y t x y x t t y x
tx = 2 ty = 1
Homogeneous Coordinates
Homogeneous Coordinates Homogeneous Coordinates
(34)
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 (x/w, y/w)(x, y, w) represents a point at location (x/w, y/w) • (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 (x/w, y/w)(x, y, w) represents a point at location (x/w, y/w)
• (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
(35)
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 0 0 0 cos sin 0 sin cos 1 ' ' y x y x 1 1 0 0 1 0 0 1 1 ' ' y x t t y x y x 1 1 0 0 0 1 0 1 1 ' ' y x sh sh y x y x Translate Rotate Shear 1 1 0 0 0 0 0 0 1 ' ' y x s s y x y x Scale
(36)
Affine Transformations
Affine transformations are combinations of …
Affine transformations are combinations of …
• Linear transformations, andLinear transformations, and • TranslationsTranslations
Properties of affine transformations:
Properties of affine transformations:
• Origin does not necessarily map to originOrigin does not necessarily map to origin • Lines map to linesLines map to lines
• Parallel lines remain parallelParallel lines remain parallel • Ratios are preservedRatios are preserved
• Closed under compositionClosed under composition
Affine transformations are combinations of …
Affine transformations are combinations of … • Linear transformations, andLinear transformations, and
• TranslationsTranslations
Properties of affine transformations:
Properties of affine transformations: • Origin does not necessarily map to originOrigin does not necessarily map to origin
• Lines map to linesLines map to lines
• Parallel lines remain parallelParallel lines remain parallel
• Ratios are preservedRatios are preserved
• Closed under compositionClosed under composition
w y x f
e
da b c w
y x
1 0
0 '
(37)
Projective Transformations
Projective transformations …
Projective transformations …
• Affine transformations, andAffine transformations, and • Projective warpsProjective warps
Properties of projective transformations:
Properties of projective transformations:
• Origin does not necessarily map to originOrigin does not necessarily map to origin • Lines map to linesLines map to lines
• Parallel lines do not necessarily remain parallelParallel lines do not necessarily remain parallel • Ratios are not preservedRatios are not preserved
• Closed under compositionClosed under composition
Projective transformations …
Projective transformations … • Affine transformations, andAffine transformations, and
• Projective warpsProjective warps
Properties of projective transformations:
Properties of projective transformations: • Origin does not necessarily map to originOrigin does not necessarily map to origin
• Lines map to linesLines map to lines
• Parallel lines do not necessarily remain parallelParallel lines do not necessarily remain parallel
• Ratios are not preservedRatios are not preserved
• Closed under compositionClosed under composition
w y x i
h g
f e
da b c w
y x ' ' '
(38)
Overview
2D Transformations
2D Transformations
• Basic 2D transformationsBasic 2D transformations • Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations
3D Transformations
• Basic 3D transformationsBasic 3D transformations • Same as 2DSame as 2D
2D Transformations 2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition 3D Transformations 3D Transformations
• Basic 3D transformationsBasic 3D transformations • Same as 2DSame as 2D
(39)
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 tytx w y x 1 0 0 0 0 0 0 1
0
0 cos 0
sin sin 0
cos 1 0 0 1 0 0 1 ' ' '
(40)
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 representationGeneral purpose representation • Hardware matrix multiplyHardware 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 representationGeneral purpose representation
• Hardware matrix multiplyHardware matrix multiply
p
’ = (T * (R * (S*
p
) ) )
(41)
Matrix Composition
Be aware: order of transformations matters
Be aware: order of transformations matters
–Matrix multiplication is not commutativeMatrix multiplication is not commutative
Be aware: order of transformations matters Be aware: order of transformations matters
–Matrix multiplication is not commutativeMatrix multiplication is not commutative
p
’ = T * R * S *
p
(42)
Matrix Composition
What if we want to rotate
What if we want to rotate andand translate? translate?
• Ex: Ex: Rotate line segment by 45 degrees about endpoint Rotate line segment by 45 degrees about endpoint aa and lengthen
and lengthen
What if we want to rotate
What if we want to rotate andand translate? translate?
• Ex: Ex: Rotate line segment by 45 degrees about endpoint Rotate line segment by 45 degrees about endpoint aa and lengthen
and lengthen
(43)
Multiplication Order – Wrong Way
Our line is defined by two endpoints
Our line is defined by two endpoints
• Applying a rotation of 45 degrees, R(45), affects both pointsApplying a rotation of 45 degrees, R(45), affects both points
• We could try to translate both endpoints to return endpoint We could try to translate both endpoints to return endpoint aa 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, R(45), affects both pointsApplying a rotation of 45 degrees, R(45), affects both points
• We could try to translate both endpoints to return endpoint We could try to translate both endpoints to return endpoint aa to its to its original position, but by how much?
original position, but by how much?
Wrong Correct
T(-3) R(45) T(3)
R(45)
(44)
Multiplication Order - Correct
Isolate endpoint
Isolate endpoint aa from rotation effects from rotation effects
• First translate line so First translate line so aa is at origin: T (-3) is at origin: T (-3)
• Then rotate line 45 degrees: R(45)Then rotate line 45 degrees: R(45)
• Then translate back so Then translate back so aa is where it was: T(3) is where it was: T(3)
Isolate endpoint
Isolate endpoint aa from rotation effects from rotation effects • First translate line so First translate line so aa is at origin: T (-3) is at origin: T (-3)
• Then rotate line 45 degrees: R(45)Then rotate line 45 degrees: R(45)
• Then translate back so Then translate back so aa is where it was: T(3) is where it was: T(3)
a
a
a
(45)
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 0 0 0 1 0 3 0 1 1 0 0 0 ) 45 cos( ) 45 sin( 0 ) 45 sin( ) 45 cos( 1 0 0 0 1 0 3 0 1 y x y x a a a a(46)
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
(47)
Overview
2D Transformations
2D Transformations
• Basic 2D transformationsBasic 2D transformations • Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations
3D Transformations
• Basic 3D transformationsBasic 3D transformations • Same as 2DSame as 2D
2D Transformations
2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition 3D Transformations 3D Transformations
• Basic 3D transformationsBasic 3D transformations • Same as 2DSame as 2D
(48)
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 matrices4x4 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 matrices4x4 transformation matrices
wz y x p
o n
mi j k l
h g
f
e b c d
a wz
y x ' '' '
(49)
Basic 3D Transformations
wz y x wz y x 1 0 00 0 1 0
0 1 0 0
0 0 0 0
1 '' ' w z y x t t t w z y x z y x 1 0 0 0 1 0 0 0 1 0 0 0 1 ' ' ' w z y x s s s w z y x z y x 1 0 0 0 0 0 0 0 0 0 0 0 0 ' ' ' wz y x wz y x 1 0 0
0 0 1 0
0 1 0 0
01 0 0 0 '
' '
Identity Scale
(50)
Basic 3D Transformations
wz y x wz y x 1 0 00 0 1 0
0 cos 0 0 sin sin 0 0 cos
' ' ' Rotate around Z axis:
w z y x w z y x 1 0 0 0 0 cos 0 sin 0 0 1 0 0 sin 0 cos ' ' ' Rotate around Y axis:
wz y x wz y x 1 0 0
0 sin cos 0 0 cos sin 0
0 0 0 0
1 '
' ' Rotate around X axis:
(51)
Reverse Rotations
Q: How do you undo a rotation of
Q: How do you undo a rotation of R(R()?)? A: Apply the inverse of the rotation… R
A: Apply the inverse of the rotation… R-1-1(() = R(-) = R(-) )
How to construct R-1(
How to construct R-1() = R(-) = R(-))
• Inside the rotation matrix: cos(Inside the rotation matrix: cos() = cos(-) = cos(-))
– The cosine elements of the inverse rotation matrix are unchangedThe cosine elements of the inverse rotation matrix are unchanged
• The sign of the sine elements will flipThe sign of the sine elements will flip
Therefore… R
Therefore… R-1-1(() = R(-) = R(-) = R) = RTT(())
Q: How do you undo a rotation of
Q: How do you undo a rotation of R(R()?)? A: Apply the inverse of the rotation… R
A: Apply the inverse of the rotation… R-1-1(() = R(-) = R(-) )
How to construct R-1(
How to construct R-1() = R(-) = R(-))
• Inside the rotation matrix: cos(Inside the rotation matrix: cos() = cos(-) = cos(-))
– The cosine elements of the inverse rotation matrix are unchangedThe cosine elements of the inverse rotation matrix are unchanged
• The sign of the sine elements will flipThe sign of the sine elements will flip
Therefore… R
(52)
Summary
Coordinate systems
Coordinate systems
• World vs. modeling coordinatesWorld vs. modeling coordinates
2-D and 3-D transformations
2-D and 3-D transformations
• Trigonometry and geometryTrigonometry and geometry • Matrix representationsMatrix representations
• Linear vs. affine transformationsLinear vs. affine transformations
Matrix operations
Matrix operations
• Matrix compositionMatrix composition
Coordinate systems
Coordinate systems
• World vs. modeling coordinatesWorld vs. modeling coordinates
2-D and 3-D transformations
2-D and 3-D transformations • Trigonometry and geometryTrigonometry and geometry
• Matrix representationsMatrix representations
• Linear vs. affine transformationsLinear vs. affine transformations
Matrix operations
Matrix operations • Matrix compositionMatrix composition
(1)
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
(2)
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
i
j
k
l
h
g
f
e
b
c
d
a
w
z
y
x
'
'
'
'
(3)
Basic 3D Transformations
wz y x wz y x 1 0 00 0 1 0
0 1 0 0
0 0 0 0
1 '' ' w z y x t t t w z y x z y x 1 0 0 0 1 0 0 0 1 0 0 0 1 ' ' ' w z y x s s s w z y x z y x 1 0 0 0 0 0 0 0 0 0 0 0 0 ' ' ' wz y x wz y x 1 0 0
0 0 1 0
0 1 0 0
01 0 0 0 '
' '
Identity
Scale
(4)
Basic 3D Transformations
wz y x wz y x 1 0 00 0 1 0
0 cos 0 0
sin sin 0 0
cos '
' '
Rotate around Z axis:
w z y x w z y x 1 0 0 0 0 cos 0 sin 0 0 1 0 0 sin 0 cos ' ' '
Rotate around Y axis:
wz y x wz y x 1 0 0
0 sin cos 0
0 cos sin 0
0 0 0 0
1 '
' '
(5)
Reverse Rotations
Q: How do you undo a rotation of
Q: How do you undo a rotation of
R(
R(
)?
)?
A: Apply the inverse of the rotation… R
A: Apply the inverse of the rotation… R
-1-1(
(
) = R(-
) = R(-
)
)
How to construct R-1(
How to construct R-1(
) = R(-
) = R(-
)
)
• Inside the rotation matrix: cos(Inside the rotation matrix: cos() = cos(-) = cos(-))
– The cosine elements of the inverse rotation matrix are unchangedThe cosine elements of the inverse rotation matrix are unchanged • The sign of the sine elements will flipThe sign of the sine elements will flip
Therefore… R
Therefore… R
-1-1(
(
) = R(-
) = R(-
) = R
) = R
TT(
(
)
)
Q: How do you undo a rotation of
Q: How do you undo a rotation of
R(
R(
)?
)?
A: Apply the inverse of the rotation… R
A: Apply the inverse of the rotation… R
-1-1(
(
) = R(-
) = R(-
)
)
How to construct R-1(
How to construct R-1(
) = R(-
) = R(-
)
)
• Inside the rotation matrix: cos(Inside the rotation matrix: cos() = cos(-) = cos(-))
– The cosine elements of the inverse rotation matrix are unchangedThe cosine elements of the inverse rotation matrix are unchanged
• The sign of the sine elements will flipThe sign of the sine elements will flip
Therefore… R
(6)
Summary
Coordinate systems
Coordinate systems
• World vs. modeling coordinatesWorld vs. modeling coordinates
2-D and 3-D transformations
2-D and 3-D transformations
• Trigonometry and geometryTrigonometry and geometry • Matrix representationsMatrix representations
• Linear vs. affine transformationsLinear vs. affine transformations
Matrix operations
Matrix operations
• Matrix compositionMatrix composition
Coordinate systems
Coordinate systems
• World vs. modeling coordinatesWorld vs. modeling coordinates
2-D and 3-D transformations
2-D and 3-D transformations
• Trigonometry and geometryTrigonometry and geometry• Matrix representationsMatrix representations
• Linear vs. affine transformationsLinear vs. affine transformations