Download slides

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Cartesian coordinate system wikipedia , lookup

Möbius transformation wikipedia , lookup

Line (geometry) wikipedia , lookup

Affine connection wikipedia , lookup

Lorentz transformation wikipedia , lookup

Transcript
Object-order vs. Image-order
• Object-order
for each triangle t {
CS4620/5620: Pipeline and Transformations
find pixels covered by t
c(x,y) = shaded result
Professor: Kavita Bala
Cornell CS4620 Fall 2011 •!Lecture 3
}
• Hardware pipeline
© 2011 Kavita Bala •
(with previous instructors James/Marschner)
1
• Image-order
for each pixel p=(x,y) {
intersect ray through p with scene
c(x,y) = shade (visible point)
}
• Ray tracers
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala •
(with previous instructors James/Marschner)
Math review
Geometry of 2D linear trans.
• Read:
• 2x2 matrices have simple geometric interpretations
– Chapter 2: Miscellaneous Math
– Chapter 5: Linear Algebra
2
– uniform scale
– non-uniform scale
– reflection
– shear
– rotation
• Vectors and points
• Vector operations
– addition
– scalar product
• More products
– dot product
– cross product
• Bases and orthogonality
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala •
(with previous instructors James/Marschner)
3
Cornell CS4620 Fall 2011 •!Lecture 3
Linear transformation gallery
Linear transformation gallery
• Nonuniform scale
• Shear
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala •
(with previous instructors James/Marschner)
5
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala •
4
© 2011 Kavita Bala •
6
(with previous instructors James/Marschner)
(with previous instructors James/Marschner)
Linear transformation gallery
Linear transformations
• Rotation
• One way to define a transformation is by matrix
multiplication:
!
• Such transformations are linear, which is to say:
– (and in fact all linear transformations can be written this way)
• Is translation linear?
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala •
(with previous instructors James/Marschner)
7
Cornell CS4620 Fall 2011 •!Lecture 3
Composing transformations
Composing transformations
• Want to move an object, then move it some more
• Linear transformations also straightforward
–!
© 2011 Kavita Bala •
(with previous instructors James/Marschner)
8
–!
• We need to represent S o T (“S compose T”)
– and would like to use the same representation as for S and T
• Translation easy
• Transforming first by MT then by MS is the same as
transforming by MSMT
–!
– only sometimes commutative
• e.g. rotations & uniform scales
• e.g. non-uniform scales w/o rotation
– Note MSMT, or S o T, is T first, then S
• Translation by uT then by uS is translation by uT + uS
– commutative!
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala •
(with previous instructors James/Marschner)
9
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 10
(with previous instructors James/Marschner)
Combining linear with translation
Homogeneous coordinates
• Need to use both in single framework
• Can represent arbitrary seq. as
• A trick for representing the foregoing more elegantly
• Extra component w for vectors, extra row/column for
matrices
–!
– for affine, can always keep w = 1
–!
• Represent linear transformations with dummy extra row
and column
–!
– e. g.
• Transforming by MT and uT, then by MS and uS, is the same
as transforming by MSMT and uS + MSuT
– This will work but is a little awkward
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 11
(with previous instructors James/Marschner)
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 12
(with previous instructors James/Marschner)
Homogeneous coordinates
Homogeneous coordinates
• Represent translation using the extra column
• Composition just works, by 3x3 matrix multiplication
• What kind of transform is this?
• This is exactly the same as carrying around M and u
Cornell CS4620 Fall 2011 •!Lecture 3
– but cleaner
– and generalizes in useful ways as we’ll see later
© 2011 Kavita Bala • 13
(with previous instructors James/Marschner)
Cornell CS4620 Fall 2011 •!Lecture 3
Affine transformations
Affine transformation gallery
• The set of transformations we are interested in is known
as the “affine” transformations
• Translation
© 2011 Kavita Bala • 14
(with previous instructors James/Marschner)
– straight lines preserved; parallel lines preserved
– ratios of lengths along lines preserved (midpoints preserved)
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 15
(with previous instructors James/Marschner)
Cornell CS4620 Fall 2011 •!Lecture 3
Affine transformation gallery
Affine transformation gallery
• Uniform scale
• Nonuniform scale
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 17
(with previous instructors James/Marschner)
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 16
(with previous instructors James/Marschner)
© 2011 Kavita Bala • 18
(with previous instructors James/Marschner)
Affine transformation gallery
Affine transformation gallery
• Reflection
• Shear
– can consider it a special case
of nonuniform scale
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 19
(with previous instructors James/Marschner)
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 20
(with previous instructors James/Marschner)
Affine transformation gallery
General affine transformations
• Rotation
• The previous slides showed “canonical” examples of the
types of affine transformations
• Generally, transformations contain elements of multiple
types
– often define them as products of canonical transforms
– sometimes work with their properties more directly
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 21
(with previous instructors James/Marschner)
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 22
(with previous instructors James/Marschner)
Composite affine transformations
Composite affine transformations
• In general not commutative: order matters!
• Another example
rotate, then translate
Cornell CS4620 Fall 2011 •!Lecture 3
translate, then rotate
© 2011 Kavita Bala • 23
(with previous instructors James/Marschner)
scale, then rotate
Cornell CS4620 Fall 2011 •!Lecture 3
rotate, then scale
© 2011 Kavita Bala • 24
(with previous instructors James/Marschner)
Rigid motions
Transforming points and vectors
• A transform made up of only translation and rotation is a
rigid motion or a rigid body transformation
• The linear part is an orthonormal matrix
• Recall distinction between points vs. vectors
– vectors are just offsets (differences between points)
– points have a location
• represented by vector offset from a fixed origin
• Points and vectors transform differently
– points respond to translation; vectors do not
• Inverse of orthonormal matrix is transpose
– so inverse of rigid motion is easy:
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 25
(with previous instructors James/Marschner)
Transforming points and vectors
• Homogeneous coords. let us exclude translation
– just put 0 rather than 1 in the last place
– and note that subtracting two points cancels the extra
coordinate, resulting in a vector!
• Preview: projective transformations
– what’s really going on with this last coordinate?
– think of R2 embedded in R3: all affine xfs. preserve z=1 plane
– could have other transforms; project back to z=1
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 27
(with previous instructors James/Marschner)
Cornell CS4620 Fall 2011 •!Lecture 3
© 2011 Kavita Bala • 26
(with previous instructors James/Marschner)