introduction to computer graphics cs 445 / 645 lecture 5 transformations transformations m.c. escher...
TRANSCRIPT
![Page 1: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/1.jpg)
Introduction to Computer GraphicsCS 445 / 645
Lecture 5Lecture 5
TransformationsTransformations
Lecture 5Lecture 5
TransformationsTransformationsM.C. Escher – Smaller and Smaller (1956)
![Page 2: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/2.jpg)
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 Remember how OpenGL provides a transformation stack because they are so frequently reusedstack because they are so frequently reused
Chapter 5 from Hearn and BakerChapter 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 Remember how OpenGL provides a transformation stack because they are so frequently reusedstack because they are so frequently reused
Chapter 5 from Hearn and BakerChapter 5 from Hearn and Baker
H&B Figure 109
![Page 3: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/3.jpg)
Overview
2D Transformations2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations3D Transformations
• Basic 3D transformationsBasic 3D transformations
• Same as 2DSame as 2D
2D Transformations2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations3D Transformations
• Basic 3D transformationsBasic 3D transformations
• Same as 2DSame as 2D
![Page 4: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/4.jpg)
2D Modeling Transformations
ScaleRotate
Translate
ScaleTranslate
x
y
World Coordinates
ModelingCoordinates
![Page 5: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/5.jpg)
2D Modeling Transformations
x
y
World Coordinates
ModelingCoordinates
Let’s lookat this indetail…
![Page 6: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/6.jpg)
2D Modeling Transformations
x
y
ModelingCoordinates
Initial locationat (0, 0) withx- and y-axesaligned
![Page 7: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/7.jpg)
2D Modeling Transformations
x
y
ModelingCoordinates
Scale .3, .3Rotate -90
Translate 5, 3
![Page 8: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/8.jpg)
2D Modeling Transformations
x
y
ModelingCoordinates
Scale .3, .3Rotate -90
Translate 5, 3
![Page 9: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/9.jpg)
2D Modeling Transformations
x
y
ModelingCoordinates
Scale .3, .3Rotate -90
Translate 5, 3
World Coordinates
![Page 10: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/10.jpg)
Scaling
ScalingScaling a coordinate means multiplying each of its a coordinate means multiplying each of its components by a scalarcomponents by a scalar
Uniform scalingUniform scaling means this scalar is the same for all means this scalar is the same for all components:components:
ScalingScaling a coordinate means multiplying each of its a coordinate means multiplying each of its components by a scalarcomponents by a scalar
Uniform scalingUniform scaling means this scalar is the same for all means this scalar is the same for all components:components:
2
![Page 11: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/11.jpg)
Non-uniform scalingNon-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 scalingNon-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,Y 0.5
![Page 12: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/12.jpg)
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
'
'
scaling matrix
![Page 13: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/13.jpg)
2-D Rotation
(x, y)
(x’, y’)
x’ = x cos() - y sin()y’ = x sin() + y cos()
![Page 14: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/14.jpg)
2-D Rotationx = 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’)
![Page 15: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/15.jpg)
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
cossin
sincos
'
'
![Page 16: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/16.jpg)
Basic 2D TransformationsTranslation: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)
![Page 17: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/17.jpg)
Basic 2D TransformationsTranslation: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
![Page 18: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/18.jpg)
Basic 2D TransformationsTranslation: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)
(x’,y’)
![Page 19: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/19.jpg)
Basic 2D Transformations
x’ = (x*sx)*cos - (y*sy)*siny’ = (x*sx)*sin + (y*sy)*cosx’ = (x*sx)*cos - (y*sy)*siny’ = (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
• y’ = x*y’ = x*sinsin + y* + y*coscos
![Page 20: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/20.jpg)
Basic 2D TransformationsTranslation: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
(x’,y’)
![Page 21: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/21.jpg)
Basic 2D TransformationsTranslation: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
y’ = ((x*sx)*sin + (y*sy)*cos) + ty
![Page 22: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/22.jpg)
Overview
2D Transformations2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations3D Transformations
• Basic 3D transformationsBasic 3D transformations
• Same as 2DSame as 2D
2D Transformations2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations3D Transformations
• Basic 3D transformationsBasic 3D transformations
• Same as 2DSame as 2D
![Page 23: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/23.jpg)
Matrix Representation
Represent 2D transformation by a matrixRepresent 2D transformation by a matrix
Multiply matrix by column vectorMultiply matrix by column vector apply transformation to point apply transformation to point
Represent 2D transformation by a matrixRepresent 2D transformation by a matrix
Multiply matrix by column vectorMultiply matrix by column vector apply transformation to point apply transformation to point
yx
dcba
yx''
dcba
dycxy
byaxx
'
'
![Page 24: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/24.jpg)
Matrix Representation
Transformations combined by multiplicationTransformations combined by multiplicationTransformations combined by multiplicationTransformations combined by multiplication
yx
lkji
hgfe
dcba
yx''
Matrices are a convenient and efficient way to represent a sequence of transformations!
![Page 25: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/25.jpg)
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?
yyxx
''
yx
yx
1001
''
2D Scale around (0,0)?
ysy
xsx
y
x
*'
*'
y
x
s
s
y
x
y
x
0
0
'
'
![Page 26: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/26.jpg)
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)?
yxyyxx
*cos*sin'*sin*cos'
y
x
y
x
cossin
sincos
'
'
2D Shear?
yxshy
yshxx
y
x
*'
*'
y
x
sh
sh
y
x
y
x
1
1
'
'
![Page 27: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/27.jpg)
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?
yyxx
''
yx
yx
1001
''
2D Mirror over (0,0)?
yyxx
''
yx
yx
1001
''
![Page 28: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/28.jpg)
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
tyy
txx
'
'
Only linear 2D transformations can be represented with a 2x2 matrix
NO!
![Page 29: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/29.jpg)
Linear TransformationsLinear 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
)()()( 22112211 pppp TsTsssT
y
x
dc
ba
y
x
'
'
![Page 30: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/30.jpg)
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
tyy
txx
'
'
![Page 31: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/31.jpg)
Homogeneous Coordinates
Homogeneous coordinatesHomogeneous coordinates
• represent coordinates in 2 represent coordinates in 2 dimensions with a 3-vectordimensions with a 3-vector
Homogeneous coordinatesHomogeneous coordinates
• represent coordinates in 2 represent coordinates in 2 dimensions with a 3-vectordimensions with a 3-vector
1
coords shomogeneou 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 make graphics operations muchmuch easier easier
![Page 32: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/32.jpg)
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:
100
10
01
y
x
t
t
ranslationT
y
x
tyy
txx
'
'
![Page 33: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/33.jpg)
Translation
Example of translationExample of translation
Example of translationExample of translation
11100
10
01
1
'
'
y
x
y
x
ty
tx
y
x
t
t
y
x
tx = 2ty = 1
Homogeneous CoordinatesHomogeneous CoordinatesHomogeneous CoordinatesHomogeneous Coordinates
![Page 34: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/34.jpg)
Homogeneous Coordinates
Add a 3rd coordinate to every 2D pointAdd 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 pointAdd 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
![Page 35: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/35.jpg)
Basic 2D Transformations
Basic 2D transformations as 3x3 matricesBasic 2D transformations as 3x3 matricesBasic 2D transformations as 3x3 matricesBasic 2D transformations as 3x3 matrices
1100
0cossin
0sincos
1
'
'
y
x
y
x
1100
10
01
1
'
'
y
x
t
t
y
x
y
x
1100
01
01
1
'
'
y
x
sh
sh
y
x
y
x
Translate
Rotate Shear
1100
00
00
1
'
'
y
x
s
s
y
x
y
x
Scale
![Page 36: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/36.jpg)
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
wyx
fedcba
wyx
100''
![Page 37: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/37.jpg)
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
wyx
ihgfedcba
wyx
'''
![Page 38: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/38.jpg)
Overview
2D Transformations2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations3D Transformations
• Basic 3D transformationsBasic 3D transformations
• Same as 2DSame as 2D
2D Transformations2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations3D Transformations
• Basic 3D transformationsBasic 3D transformations
• Same as 2DSame as 2D
![Page 39: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/39.jpg)
Matrix Composition
Transformations can be combined by Transformations can be combined by matrix multiplicationmatrix multiplication
Transformations can be combined by Transformations can be combined by matrix multiplicationmatrix multiplication
wyx
sysx
tytx
wyx
1000000
1000cossin0sincos
1001001
'''
p’ = T(tx,ty) R() S(sx,sy) p
![Page 40: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/40.jpg)
Matrix Composition
Matrices are a convenient and efficient way to Matrices are a convenient and efficient way to
represent a sequence of transformationsrepresent 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 transformationsrepresent a sequence of transformations
• General purpose representationGeneral purpose representation
• Hardware matrix multiplyHardware matrix multiply
p’ = (T * (R * (S*p) ) )p’ = (T*R*S) * p
![Page 41: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/41.jpg)
Matrix Composition
Be aware: order of transformations mattersBe aware: order of transformations matters
– Matrix multiplication is not commutativeMatrix multiplication is not commutative
Be aware: order of transformations mattersBe aware: order of transformations matters
– Matrix multiplication is not commutativeMatrix multiplication is not commutative
p’ = T * R * S * p
“Global” “Local”
![Page 42: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/42.jpg)
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
a a
![Page 43: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/43.jpg)
Multiplication Order – Wrong Way
Our line is defined by two endpointsOur 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 endpointsOur 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 CorrectT(-3) R(45) T(3)R(45)
aa
a
![Page 44: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/44.jpg)
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
a
![Page 45: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/45.jpg)
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
'
'
1100
010
301
100
0)45cos()45sin(
0)45sin()45cos(
100
010
301
y
x
y
x
a
a
a
a
![Page 46: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/46.jpg)
Matrix Composition
After correctly ordering the matricesAfter correctly ordering the matrices
Multiply matrices togetherMultiply 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 vertexMultiply this matrix by the vector of each vertex
All vertices easily transformed with one matrix All vertices easily transformed with one matrix multiplymultiply
After correctly ordering the matricesAfter correctly ordering the matrices
Multiply matrices togetherMultiply 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 vertexMultiply this matrix by the vector of each vertex
All vertices easily transformed with one matrix All vertices easily transformed with one matrix multiplymultiply
![Page 47: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/47.jpg)
Overview
2D Transformations2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations3D Transformations
• Basic 3D transformationsBasic 3D transformations
• Same as 2DSame as 2D
2D Transformations2D Transformations
• Basic 2D transformationsBasic 2D transformations
• Matrix representationMatrix representation
• Matrix compositionMatrix composition
3D Transformations3D Transformations
• Basic 3D transformationsBasic 3D transformations
• Same as 2DSame as 2D
![Page 48: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/48.jpg)
3D Transformations
Same idea as 2D transformationsSame 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 transformationsSame idea as 2D transformations
• Homogeneous coordinates: (x,y,z,w) Homogeneous coordinates: (x,y,z,w)
• 4x4 transformation matrices4x4 transformation matrices
wzyx
ponmlkjihgfedcba
wzyx
''''
![Page 49: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/49.jpg)
Basic 3D Transformations
wzyx
wzyx
1000010000100001
'''
w
z
y
x
t
t
t
w
z
y
x
z
y
x
1000
100
010
001
'
'
'
w
z
y
x
s
s
s
w
z
y
x
z
y
x
1000
000
000
000
'
'
'
wzyx
wzyx
1000010000100001
'''
Identity Scale
Translation Mirror about Y/Z plane
![Page 50: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/50.jpg)
Basic 3D Transformations
wzyx
wzyx
1000010000cossin00sincos
'''
Rotate around Z axis:
w
z
y
x
w
z
y
x
1000
0cos0sin
0010
0sin0cos
'
'
'
Rotate around Y axis:
wzyx
wzyx
10000cossin00sincos00001
'''
Rotate around X axis:
![Page 51: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/51.jpg)
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… RA: 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… RTherefore… 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… RA: 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… RTherefore… R-1-1(() = R(-) = R(-) = R) = RTT(())
![Page 52: Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)](https://reader036.vdocuments.net/reader036/viewer/2022062407/56649d925503460f94a78db9/html5/thumbnails/52.jpg)
Summary
Coordinate systemsCoordinate systems
• World vs. modeling coordinatesWorld vs. modeling coordinates
2-D and 3-D transformations2-D and 3-D transformations
• Trigonometry and geometryTrigonometry and geometry
• Matrix representationsMatrix representations
• Linear vs. affine transformationsLinear vs. affine transformations
Matrix operationsMatrix operations
• Matrix compositionMatrix composition
Coordinate systemsCoordinate systems
• World vs. modeling coordinatesWorld vs. modeling coordinates
2-D and 3-D transformations2-D and 3-D transformations
• Trigonometry and geometryTrigonometry and geometry
• Matrix representationsMatrix representations
• Linear vs. affine transformationsLinear vs. affine transformations
Matrix operationsMatrix operations
• Matrix compositionMatrix composition