Affine Transformations
Total Page:16
File Type:pdf, Size:1020Kb
A little quick math background • Linear transformations • Matrices – Matrix-vector multiplication 2D Geometric Transformations – Matrix-matrix multiplication • Implicit and explicit geometry CS 465 Lecture 8 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 1 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 2 Implicit representations Explicit representations • Equation to tell whether we are on the curve • Also called parametric • • Equation to map domain into plane • Example: line – – • Example: line • Example: circle – – • Example: circle • Always define boundary of region – – (if f is continuous) • Like tracing out the path of a particle over time • Variable t is the “parameter” Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 3 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 4 Transforming geometry Translation • Move a subset of the plane using a mapping from the • Simplest transformation: plane to itself • Inverse: – • Example of transforming circle • Parametric representation: – • Implicit representation: – – Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 5 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 6 Linear transformations Geometry of 2D linear trans. • Any transformation with the property: • 2x2 matrices have simple geometric interpretations – – uniform scale • Can be represented using matrix multiplication – non-uniform scale – rotation – – shear – reflection • Reading off the matrix Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 7 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 8 Linear transformation gallery Linear transformation gallery • Uniform scale • Nonuniform scale Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 9 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 10 Linear transformation gallery Linear transformation gallery • Rotation • Reflection – can consider it a special case of nonuniform scale Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 11 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 12 Linear transformation gallery Composing transformations • Shear • Want to move an object, then move it some more – • We need to represent S o T – and would like to use the same representation as for S and T • Translation easy – • commutative! Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 13 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 14 Composing transformations Combining linear with translation • Linear transformations also straightforward • Need to use both in single framework – • Can represent arbitrary seq. as – – • only sometimes commutative – – e.g. rotations & uniform scales – e.g. non-uniform scales w/o rotation –e. g. • This will work but is a little awkward Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 15 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 16 Homogeneous coordinates Homogeneous coordinates • A trick for representing the foregoing simply • Represent translation using the extra column • 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 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 17 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 18 Homogeneous coordinates Affine transformations • Composition just works, by 3x3 matrix multiplication • The set of transformations we have been looking at is known as the “affine” transformations – straight lines preserved; parallel lines preserved – ratios of lengths along lines preserved (midpoints preserved) • This is exactly the same as carrying around – but cleaner – and generalizes in useful ways as we’ll see later Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 19 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 20 Affine transformation gallery Affine transformation gallery • Translation • Uniform scale Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 21 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 22 Affine transformation gallery Affine transformation gallery • Nonuniform scale • Rotation Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 23 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 24 Affine transformation gallery Affine transformation gallery • Reflection • Shear – can consider it a special case of nonuniform scale Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 25 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 26 General affine transformations Composite affine transformations • The previous slides showed “canonical” examples of • In general not commutative: order matters! 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 rotate, then translate translate, then rotate Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 27 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 28 Composite affine transformations Composite affine transformations • In general not commutative: order matters! • In general not commutative: order matters! rotate, then translate translate, then rotate rotate, then translate translate, then rotate Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 28 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 28 Composite affine transformations Composite affine transformations • In general not commutative: order matters! • Another example rotate, then translate translate, then rotate scale, then rotate rotate, then scale Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 28 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 29 Composite affine transformations Composite affine transformations • Another example • Another example scale, then rotate rotate, then scale scale, then rotate rotate, then scale Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 29 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 29 Composite affine transformations More math background • Another example • Linear independence and bases • Orthonormal matrices • Coordinate systems – Expressing vectors with respect to bases – Linear transformations as changes of basis scale, then rotate rotate, then scale Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 29 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 30 Rigid motions Composing to change axes • A transform made up of only translation and rotation • Want to rotate about a particular point is a rigid motion or a rigid body transformation – could work out formulas directly… • The linear part is an orthonormal matrix • Know how to rotate about the origin – so translate that point to the origin • Inverse of orthonormal matrix is transpose – so inverse of rigid motion is easy: Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 31 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 32 Composing to change axes Composing to change axes • Want to rotate about a particular point • Want to rotate about a particular point – could work out formulas directly… – could work out formulas directly… • Know how to rotate about the origin • Know how to rotate about the origin – so translate that point to the origin – so translate that point to the origin Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 32 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 32 Composing to change axes Composing to change axes • Want to rotate about a particular point • Want to scale along a particular axis and point – could work out formulas directly… • Know how to scale along the y axis at the origin • Know how to rotate about the origin – so translate to the origin and rotate to align axes – so translate that point to the origin Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 32 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 33 Composing to change axes Composing to change axes • Want to scale along a particular axis and point • Want to scale along a particular axis and point • Know how to scale along the y axis at the origin • Know how to scale along the y axis at the origin – so translate to the origin and rotate to align axes – so translate to the origin and rotate to align axes Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 33 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 33 Composing to change axes Composing to change axes • Want to scale along a particular axis and point • Want to scale along a particular axis and point • Know how to scale along the y axis at the origin • Know how to scale along the y axis at the origin – so translate to the origin and rotate to align axes – so translate to the origin and rotate to align axes Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 33 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 33 Composing to change axes Affine change of coordinates • Want to scale along a particular axis and point • Six degrees of freedom • Know how to scale along the y axis at the origin – so translate to the origin and rotate to align axes or Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 33 Cornell CS465 Fall 2005 • Lecture 8 © 2005 Steve Marschner • 34 Transforming points and vectors Transforming points and vectors • Recall distinction points vs. vectors • Homogeneous coords.