Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D...
Transcript of Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D...
![Page 1: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/1.jpg)
Computergrafik
Matthias Zwicker
Universität Bern
Herbst 2016
![Page 2: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/2.jpg)
Today
Transformations & matrices
• Introduction
• Matrices
• Homogeneous coordinates
• Affine transformations
• Concatenating transformations
• Change of coordinates
• Common coordinate systems
2
![Page 3: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/3.jpg)
Introduction• Goal: Freely position rigid objects in 3D space
• What are the degrees of freedom to position a rigid object?
• How to express mathematically?
3
![Page 4: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/4.jpg)
Today
Transformations & matrices
• Introduction
• Matrices
• Homogeneous coordinates
• Affine transformations
• Concatenating transformations
• Change of coordinates
• Common coordinate systems
4
![Page 5: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/5.jpg)
Matrices
• Matrix algebra to implement geometric
transformations
– Position 3D objects in space
– Specify location, orientation
5
![Page 6: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/6.jpg)
MatricesAbstract point of view
• Mathematical objects with set of operations
– Addition, subtraction, multiplication, multiplicative inverse, etc.
• Similar to integers, real numbers, etc.
But
• Properties of operations are different
– E.g., multiplication is not commutative
• Represent different intuitive concepts
– Scalar numbers represent distances
– Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc.
6
![Page 7: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/7.jpg)
Matrices
Practical point of view
• Rectangular array of numbers
• Square matrix if
• In graphics often
7
![Page 8: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/8.jpg)
Matrix addition
8
![Page 9: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/9.jpg)
Multiplication with scalar
9
![Page 10: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/10.jpg)
Matrix multiplication
10
![Page 11: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/11.jpg)
Matrix multiplication
11
![Page 12: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/12.jpg)
Matrix multiplication
12
![Page 13: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/13.jpg)
Matrix multiplication
13
![Page 14: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/14.jpg)
Matrix multiplication
Special case: matrix-vector multiplication
14
![Page 15: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/15.jpg)
Linearity
• Distributive law holds
i.e., matrix multiplication is linearhttp://en.wikipedia.org/wiki/Linear_map
• But multiplication is not commutative,
in general
15
![Page 16: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/16.jpg)
Identity matrix
16
![Page 17: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/17.jpg)
Matrix inverse
Definition
If a square matrix is non-singular, there
exists a unique inverse such that
• Note
• Computation
– Gaussian elimination, Cramer’s rule
– Review in your linear algebra book, or quick summaryhttp://www.maths.surrey.ac.uk/explore/emmaspages/option1.html
17
![Page 18: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/18.jpg)
Java vs. OpenGL matrices• OpenGL (underlying 3D graphics API used in
the Java code, more later)http://en.wikipedia.org/wiki/OpenGL
– Matrix elements stored in array of floats float M[16];
– “Column major” ordering
• Java base code
– “Row major” indexing
– Conversion fromJava to OpenGLconvention hiddensomewhere in basecode!
18
![Page 19: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/19.jpg)
Today
Transformations & matrices
• Introduction
• Matrices
• Homogeneous coordinates
• Affine transformations
• Concatenating transformations
• Change of coordinates
• Common coordinate systems
19
![Page 20: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/20.jpg)
Vectors & coordinate systems
• Vectors defined by orientation, length
• Describe using three basis vectors
20
![Page 21: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/21.jpg)
Points in 3D
• How do we represent 3D points?
• Are three basis vectors enough to define
the location of a point?
21
![Page 22: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/22.jpg)
Points in 3D
• Describe using three basis vectors and
reference point, origin
22
![Page 23: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/23.jpg)
Vectors vs. points• Vectors
• Points
• Representation of vectors and points using 4th coordinate
is called homogeneous coordinates
23
![Page 24: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/24.jpg)
Homogeneous coordinates
• Represent an affine spacehttp://en.wikipedia.org/wiki/Affine_space
• Intuitive definition
– Affine spaces consist of a vector space and a
set of points
– There is a subtraction operation that takes
two points and returns a vector
– Axiom I: for any point a and vector v, there
exists point b, such that (b-a) = v
– Axiom II: for any points a, b, c we have
(b-a)+(c-b) = c-a
24
![Page 25: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/25.jpg)
Affine space
Vector space,http://en.wikipedia.org/wiki/Vector_space
• [xyz] coordinates
• represents vectors
Affine spacehttp://en.wikipedia.org/wiki/Affine_space
• [xyz1], [xyz0]
homogeneous
coordinates
• distinguishes points
and vectors
25
![Page 26: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/26.jpg)
Homogeneous coordinates
• Subtraction of two points yields a vector
• Using homogeneous coordinates
26
![Page 27: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/27.jpg)
Today
Transformations & matrices
• Introduction
• Matrices
• Homogeneous coordinates
• Affine transformations
• Concatenating transformations
• Change of coordinates
• Common coordinate systems
27
![Page 28: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/28.jpg)
Affine transformations• Transformation, or mapping: function that
maps each 3D point to a new 3D point„f: R3 -> R3“
• Affine transformations: class of transformations to position 3D objects in space
• Affine transformations include
– Rigid transformations• Rotation
• Translation
– Non-rigid transformations• Scaling
• Shearing
28
![Page 29: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/29.jpg)
Affine transformations
• Definition: mappings that preserve
colinearity and ratios of distanceshttp://en.wikipedia.org/wiki/Affine_transformation
– Straight lines are preserved
– Parallel lines are preseverd
• Linear transformations + translation
• Nice: All desired transformations
(translation, rotation) implemented using
homogeneous coordinates and matrix-
vector multiplication
29
![Page 30: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/30.jpg)
TranslationPoint Vector
30
![Page 31: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/31.jpg)
Matrix formulationPoint Vector
31
![Page 32: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/32.jpg)
Matrix formulation
• Inverse translation
• Verify that
32
![Page 33: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/33.jpg)
Note
• What happens when you translate a
vector?
33
![Page 34: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/34.jpg)
Rotation
First: rotating a vector in 2D
• Convention: positive angle rotates
counterclockwise
• Express using rotation matrix
34
![Page 35: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/35.jpg)
Rotating a vector in 2D
35
![Page 36: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/36.jpg)
Rotating a vector in 2D
36
![Page 37: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/37.jpg)
Rotating a vector in 2D
37
![Page 38: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/38.jpg)
Rotation in 3D
Rotation around z-axis
• z-coordinate does not change
• What is the matrix for ?
v0 =Rz(µ)v
38
![Page 39: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/39.jpg)
Other coordinate axes• Same matrix to rotate points and vectors
• Points are rotated around origin
39
![Page 40: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/40.jpg)
Rotation in 3D
• Concatenate rotations around x,y,z axes to
obtain rotation around arbitrary axes
through origin
• are called Euler angleshttp://en.wikipedia.org/wiki/Euler_angles
• Disadvantage: result depends on order!
40
Gimbalhttps://en.wikipedia.org/wiki/Gimbal
![Page 41: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/41.jpg)
Rotation around arbitrary axis
• Still: origin does not change
• Counterclockwise rotation
• Angle , unit axis
•
• Intuitive derivation seehttp://mathworld.wolfram.com/RotationFormula.html
41
![Page 42: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/42.jpg)
Summary• Different ways to describe rotations
mathematically
– Sequence of rotations around three axes (Euler angles)
– Rotation around arbitrary angles (axis-angle representation)
– Other options exist (quaternions, etc.)
• Rotations preserve
– Angles
– Lengths
– Handedness of coordinate system
• Rigid transforms
– Rotations and translations
43
![Page 43: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/43.jpg)
Rotation matrices
• Orthonormal
– Rows, columns are unit length and orthogonal
• Inverse of rotation matrix?
44
![Page 44: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/44.jpg)
Rotation matrices
• Orthonormal
– Rows, columns are unit length and orthogonal
• Inverse of rotation matrix?
– Its transpose
45
![Page 45: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/45.jpg)
Rotations
• Given a rotation matrix
• How do we obtain ?
46
![Page 46: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/46.jpg)
Rotations
• Given a rotation matrix
• How do we obtain ?
47
![Page 47: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/47.jpg)
Rotations
• Given a rotation matrix
• How do we obtain ?
• How do we obtain …?
48
![Page 48: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/48.jpg)
Rotations
• Given a rotation matrix
• How do we obtain ?
• How do we obtain …?
49
![Page 49: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/49.jpg)
Scaling
• Origin does not change
50
![Page 50: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/50.jpg)
Scaling
• Inverse scaling?
51
![Page 51: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/51.jpg)
Scaling
• Inverse scaling?
52
![Page 52: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/52.jpg)
Shear
• Pure shear if only one parameter is non-zero
• Cartoon-like effects
53
![Page 53: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/53.jpg)
Summary affine transformations
• Linear transformations (rotation, scale,
shear, reflection) + translation
Vector space,http://en.wikipedia.org/wiki/Vector_space
• vectors as [xyz]
coordinates
• represents vectors
• linear transformations
Affine spacehttp://en.wikipedia.org/wiki/Affine_space
• points and vectors
as [xyz1], [xyz0]
homogeneous
coordinates
• distinguishes points
and vectors
• linear trafos. and
translation
54
![Page 54: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/54.jpg)
Summary affine transformations
• Implemented using 4x4 matrices,
homogeneous coordinates
– Last row of 4x4 matrix is always [0 0 0 1]
• Any such matrix represents an affine
transformation in 3D
• Factorization into scale, shear, rotation,
etc. is always possible, but non-trivial
– Polar decompositionhttp://en.wikipedia.org/wiki/Polar_decomposition
55
![Page 55: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/55.jpg)
Today
Transformations & matrices
• Introduction
• Matrices
• Homogeneous coordinates
• Affine transformations
• Concatenating transformations
• Change of coordinates
• Common coordinate systems
56
![Page 56: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/56.jpg)
Concatenating transformations
• Build “chains” of transformations
• Apply followed by followed by
• Overall transformation
is an affine transformation
57
![Page 57: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/57.jpg)
Concatenating transformations
• Result depends on order because matrix
multiplication not commutative
• Thought experiment
– Translation followed by rotation vs. rotation
followed by translation
58
![Page 58: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/58.jpg)
Rotating with pivot
Rotation around
originRotation with
pivot
59
![Page 59: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/59.jpg)
1. Translation 2. Rotation 3. Translation
Rotating with pivot
60
![Page 60: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/60.jpg)
Rotating with pivot
1. Translation 2. Rotation 3. Translation
61
![Page 61: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/61.jpg)
Concatenating transformations
• Arbitrary sequence of transformations
• Note: associativity
T=M3.multiply(M2); Mtotal=T.multiply(M1)
T=M2.multiply(M1); Mtotal=M3.multiply(T)
62
![Page 62: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/62.jpg)
Today
Transformations & matrices
• Introduction
• Matrices
• Homogeneous coordinates
• Affine transformations
• Concatenating transformations
• Change of coordinates
• Common coordinate systems
63
![Page 63: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/63.jpg)
Change of coordinates
New uvwq
coordinate system
Goal: Find coordinates of with respect to
new uvwq coordinate system
64
![Page 64: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/64.jpg)
Change of coordinates
Coordinates of xyzo frame w.r.t. uvwq frame
65
![Page 65: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/65.jpg)
Change of coordinates
Same point p in 3D, expressed in new uvwq frame
66
![Page 66: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/66.jpg)
Change of coordinates
67
![Page 67: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/67.jpg)
Change of coordinates• Given coordinates
of basis xyzo with respect to new frame uvwq
• Coordinates of any point with respect to
new frame uvwq are
• Matrix contains old basis vectors (x,y,z,o) in new
coordinates (u,v,w,q)68
![Page 68: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/68.jpg)
Change of coordinates
Inverse transformation
• Given point w.r.t. frame
• Want coordinates w.r.t. frame
69
![Page 69: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/69.jpg)
Today
Transformations & matrices
• Introduction
• Matrices
• Homogeneous coordinates
• Affine transformations
• Concatenating transformations
• Change of coordinates
• Common coordinate systems
70
![Page 70: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/70.jpg)
Common coordinate systems• Camera, world, and object coordinates
• Matrices for change of coordinates C, M
World coordinates
Object
coordinates
Camera
coordinates
![Page 71: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/71.jpg)
Object coordinates
• Coordinates the object is defined with
• Often origin is in middle, base, or corner
of object
• No right answer, whatever was convenient
for the creator of the object
World coordinates
Object
coordinates
Camera
coordinates
72
![Page 72: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/72.jpg)
World coordinates
• “World space”
• Common reference frame for all objects in
the scene
• Chosen for convenience, no right answer
– If there is a ground plane, usually x-y is
horizontal and z points up
World coordinates
Object
coordinates
Camera
coordinates
73
![Page 73: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/73.jpg)
World coordinates
• Transformation from object to world space
is different for each object
• Defines placement of object in scene
• Given by “model matrix” (model-to-world
transform)
World coordinates
Object
coordinates
Camera
coordinates
74
![Page 74: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/74.jpg)
Camera coordinate system• “Camera space”
• Origin defines center of projection of camera
• Common convention in 3D graphics
– x-y plane is parallel to image plane
– z-axis is perpendicular to image plane
World coordinates
Object
coordinates
Camera
coordinates
75
![Page 75: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/75.jpg)
Camera coordinate system
• “Camera matrix” defines transformation
from camera to world coordinates
– Placement of camera in world
• Transformation from object to camera
coordinates
World coordinates
Object
coordinates
Camera
coordinates
76
![Page 76: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/76.jpg)
Camera matrix
• Construct from center of projection , look
at , up-vector (given in world coords.)
World coordinates
Camera
coordinates
77
![Page 77: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/77.jpg)
Camera matrix
World coordinates
Camera
coordinates
• Construct from center of projection , look
at , up-vector (given in world coords.)
78
![Page 78: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/78.jpg)
Camera matrix
• z-axis
• x-axis
• y-axis
79
![Page 79: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/79.jpg)
Camera matrix
• z-axis
• x-axis
• y-axis
80
![Page 80: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/80.jpg)
Camera matrix
• Camera to world transformation
• Think about: What does it mean to
compute
81
![Page 81: Computergrafik - cs.umd.edu · –Matrices can represent coordinate systems, rigid motions, in 3D and higher dimensions, etc. 6. Matrices ... •Transformation, or mapping: function](https://reader033.fdocuments.us/reader033/viewer/2022050119/5f4fa6283de5e577a16e8d15/html5/thumbnails/81.jpg)
Coming upProject 1
• Due Thursday Oct. 6
• Everybody: turn-in via Ilias before Thursday 10:00
• Turn-in
– In person
– Sign up for a time slot on Ilias
Next lecture
• From 3D to 2D: projections
82