Affine Transformations. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell



Similar documents
Vector Notation: AB represents the vector from point A to point B on a graph. The vector can be computed by B A.

Geometric Transformation CS 211A

Section Continued

Lecture L3 - Vectors, Matrices and Coordinate Transformations

TWO-DIMENSIONAL TRANSFORMATION

Unified Lecture # 4 Vectors

Adding vectors We can do arithmetic with vectors. We ll start with vector addition and related operations. Suppose you have two vectors

1 Determinants and the Solvability of Linear Systems

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

Figure 1.1 Vector A and Vector F

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

Vector Math Computer Graphics Scott D. Anderson

Chapter 17. Orthogonal Matrices and Symmetries of Space

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

Linear Equations in Linear Algebra

Lecture 3: Coordinate Systems and Transformations

x = + x 2 + x

Orthogonal Projections

Question 2: How do you solve a matrix equation using the matrix inverse?

13 MATH FACTS a = The elements of a vector have a graphical interpretation, which is particularly easy to see in two or three dimensions.

MATH 304 Linear Algebra Lecture 18: Rank and nullity of a matrix.

Solutions to Math 51 First Exam January 29, 2015

MATH2210 Notebook 1 Fall Semester 2016/ MATH2210 Notebook Solving Systems of Linear Equations... 3

2D Geometrical Transformations. Foley & Van Dam, Chapter 5

Lecture 1: Systems of Linear Equations

LS.6 Solution Matrices

by the matrix A results in a vector which is a reflection of the given

Lecture 2 Matrix Operations

2D Geometric Transformations

Math 215 HW #6 Solutions

Rotation Matrices and Homogeneous Transformations

8 Square matrices continued: Determinants

4.5 Linear Dependence and Linear Independence

521493S Computer Graphics. Exercise 2 & course schedule change

Chapter 19. General Matrices. An n m matrix is an array. a 11 a 12 a 1m a 21 a 22 a 2m A = a n1 a n2 a nm. The matrix A has n row vectors

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

Summary: Transformations. Lecture 14 Parameter Estimation Readings T&V Sec Parameter Estimation: Fitting Geometric Models

Notes on Orthogonal and Symmetric Matrices MENU, Winter 2013

[1] Diagonal factorization

Geometric Transformations

Given a point cloud, polygon, or sampled parametric curve, we can use transformations for several purposes:

ab = c a If the coefficients a,b and c are real then either α and β are real or α and β are complex conjugates

Computational Geometry Lab: FEM BASIS FUNCTIONS FOR A TETRAHEDRON

Review Jeopardy. Blue vs. Orange. Review Jeopardy

B4 Computational Geometry

Linearly Independent Sets and Linearly Dependent Sets

CS 4204 Computer Graphics

5. Orthogonal matrices

28 CHAPTER 1. VECTORS AND THE GEOMETRY OF SPACE. v x. u y v z u z v y u y u z. v y v z

Solving Simultaneous Equations and Matrices

Geometric description of the cross product of the vectors u and v. The cross product of two vectors is a vector! u x v is perpendicular to u and v

Systems of Linear Equations

Linear Algebra Notes for Marsden and Tromba Vector Calculus

MATH1231 Algebra, 2015 Chapter 7: Linear maps

Name: Section Registered In:

THREE DIMENSIONAL GEOMETRY

The aerodynamic center

Essential Mathematics for Computer Graphics fast

These axioms must hold for all vectors ū, v, and w in V and all scalars c and d.

3D Tranformations. CS 4620 Lecture 6. Cornell CS4620 Fall 2013 Lecture Steve Marschner (with previous instructors James/Bala)

Affine Transformations

13.4 THE CROSS PRODUCT


Introduction to Matrices for Engineers

Geometry for Computer Graphics

discuss how to describe points, lines and planes in 3 space.

DERIVATIVES AS MATRICES; CHAIN RULE

Content. Chapter 4 Functions Basic concepts on real functions 62. Credits 11

Physics 235 Chapter 1. Chapter 1 Matrices, Vectors, and Vector Calculus

MATH 304 Linear Algebra Lecture 9: Subspaces of vector spaces (continued). Span. Spanning set.

2x + y = 3. Since the second equation is precisely the same as the first equation, it is enough to find x and y satisfying the system

with functions, expressions and equations which follow in units 3 and 4.

Lectures notes on orthogonal matrices (with exercises) Linear Algebra II - Spring 2004 by D. Klain

Module 3: Correlation and Covariance

9 MATRICES AND TRANSFORMATIONS

2-View Geometry. Mark Fiala Ryerson University

Geometric Camera Parameters

Elasticity Theory Basics

MAT 200, Midterm Exam Solution. a. (5 points) Compute the determinant of the matrix A =

Section 5.3. Section 5.3. u m ] l jj. = l jj u j + + l mj u m. v j = [ u 1 u j. l mj

5 Homogeneous systems

PYTHAGOREAN TRIPLES KEITH CONRAD

1 Introduction to Matrices

Linear Algebra: Vectors

8.1. Cramer s Rule for Solving Simultaneous Linear Equations. Introduction. Prerequisites. Learning Outcomes. Learning Style

Section 12.6: Directional Derivatives and the Gradient Vector

Math 312 Homework 1 Solutions

α = u v. In other words, Orthogonal Projection

3. INNER PRODUCT SPACES

Exam 1 Sample Question SOLUTIONS. y = 2x

Structural Axial, Shear and Bending Moments

FURTHER VECTORS (MEI)

Methods for Finding Bases

Problem Set 5 Due: In class Thursday, Oct. 18 Late papers will be accepted until 1:00 PM Friday.

A =

Multi-variable Calculus and Optimization

Linear Algebra Notes

Force on Moving Charges in a Magnetic Field

Computer Graphics Labs

Lecture 3: Finding integer solutions to systems of linear equations

Transcription:

Affine Transformations University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Logistics Required reading: Watt, Section 1.1. Further reading: Foley, et al, Chapter 5.1-5.5. David F. Rogers and J. Alan Adams, Mathematical Elements for Computer Graphics, 2 nd Ed., McGraw- Hill, New York, 1990, Chapter 2. Logistics: HW 1 handed out Monday Project 1 due on Monday, artifact on following Monday. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 2

Geometric transformations Geometric transformations will map points in one space to points in another: x,y,z) = fx,y,z). These transformations can be very simple, such as scaling each coordinate, or complex, such as nonlinear twists and bends. Well focus on transformations that can be represented easily with matrix operations. Well start in 2D... University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 3

Representation We can represent a point, p = x,y), in the plane as a column vector x y as a row vector x y [ ] University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 4

Representation, cont. We can represent a 2-D transformation M by a matrix M = a b c d If p is a column vector, M goes on the left: If p is a row vector, M T goes on the right: We will use column vectors. p = Mp x y = a b c d x y p = pm T [ x y ] = x y [ ] a c University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 5 b d

Two-dimensional transformations Heres all you get with a 2 x 2 transformation matrix M: x y = a b c d x y So: x = ax + by y = cx + dy We will develop some intimacy with the elements a, b, c, d University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 6

Identity Suppose we choose a=d=1, b=c=0: Gives the identity matrix: 1 0 0 1 Doesnt move the points at all University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 7

Scaling Suppose b=c=0, but let a and d take on any positive value: Gives a scaling matrix: a 0 0 d Provides differential non-uniform) scaling in x and y: 2 0 0 2 x = ax y = dy 1 2 0 0 2 University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 8

Reflection Suppose b=c=0, but let either a or d go negative. Examples: 1 0 0 1 1 0 0 1 University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 9

Shear Now leave a=d=1 and experiment with b The matrix gives: 1 b 0 1 x = x + by y = y 1 1 0 1 University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 10

Effect on unit square Lets see how a general 2 x 2 transformation M affects the unit square: a c b p q r s d [ ] = [ p q r s ] a b 0 1 1 0 = 0 a a + b b c d 0 0 1 1 0 c c + d d University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 11

Effect on unit square, cont. Observe: Origin invariant under M M can be determined just by knowing how the corners 1,0) and 0,1) are mapped a and d give x- and y-scaling b and c give x- and y-shearing University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 12

Rotation From our observations of the effect on the unit square, it should be easy to write down a matrix for rotation about the origin : 1 cos)) 0 sin)) 0 *sin)) 1 cos)) Thus M R = R) = cos) sin) sin) ) cos) University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 13

Linear transformations The unit square observations also tell us the 2x2 matrix transformation implies that we are representing a point in a new coordinate system: p = Mp = a b c d x y [ ] x y = u v where u=[a c] T and v=[b d] T are vectors that define a new basis for a linear space. The transformation to this new basis a.k.a., change of basis) is a linear transformation. = x ) u + y ) v University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 14

Limitations of the 2 x 2 matrix A 2 x 2 linear transformation matrix allows Scaling Rotation Reflection Shearing Q: What important operation does that leave out? University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 15

Affine transformations In order to incorporate the idea that both the basis and the origin can change, we augment the linear space u, v with an origin t. Note that while u and v are basis vectors, the origin t is a point. We call u, v, and t basis and origin) a frame for an affine space. Then, we can represent a change of frame as: p = x u + y v + t This change of frame is also known as an affine transformation. How do we write an affine transformation with matrices? University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 16

Homogeneous Coordinates To represent transformations among affine frames, we can loft the problem up into 3-space, adding a third component to every point: p = Mp a b t x x = c d t y y 0 0 1 1 = [ u v t] x y 1 = x ) u + y ) v +1) t Note that [a c 0] T and [b d 0] T represent vectors and [t x t y 1] T, [x y 1] T and [x y 1] T represent points. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 17

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 18 Homogeneous coordinates This allows us to perform translation as well as the linear transformations as a matrix operation: p = M T p x y 1 = 1 0 t x 0 1 t y 0 0 1 x y 1 x = x + t x y = y + t y 1 0 1 0 1 1 2 0 0 1

Rotation about arbitrary points Until now, we have only considered rotation about the origin. With homogeneous coordinates, you can specify a rotation, R q, about any point q = [q x q y 1] T with a matrix: 1. Translate q to origin 2. Rotate 3. Translate back Line up the matrices for these step in right to left order and multiply. Note: Transformation order is important!! University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 19

Points and vectors From now on, we can represent points as have an additional coordinate of w=1. Vectors have an additional coordinate of w=0. Thus, a change of origin has no effect on vectors. Q: What happens if we multiply a matrix by a vector? These representations reflect some of the rules of affine operations on points and vectors: vector + vector vector vector point point point + vector point + point One useful combination of affine operations is: pt) = p 0 + tv Q: What does this describe? University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 20

Barycentric coordinates A set of points can be used to create an affine frame. Consider a triangle ABC and a point p: A p C B We can form a frame with an origin C and the vectors from C to the other vertices: u = A C v = B C t = C We can then write P in this coordinate frame p = u + v + t The coordinates α, β, γ) are called the barycentric coordinates of p relative to A, B, and C. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 21

Computing barycentric coordinates For the triangle example we can compute the barycentric coordinates of P: Cramer s rule gives the solution: A x B x C x p x * * * A + B + C = A y B y C y * * = p y * 1 1 1 )* )* 1 )* p x B x C x A x p x C x A x B x p x = p y B y C y 1 1 1 A x B x C x = A y p y C y 1 1 1 A x B x C x = A y B y p y 1 1 1 A x B x C x A y B y C y 1 1 1 A y B y C y 1 1 1 A y B y C y 1 1 1 Computing the determinant of the denominator gives: B x C y B y C x + A y C x A x C y + A x B y A y B x University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 22

Cross products Consider the cross-product of two vectors, u and v. What is the geometric interpretation of this cross-product? A cross-product can be computed as: u v = i j k u x u y u z v x v y v z = u y v z u z v y )i + u z v x u x v z )j + u x v y u y v x )k u y v z u z v y ) = u z v x u x v z ) u x v y u y v x ) What happens when u and v lie in the x-y plane? What is the area of the triangle they span? University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 23

Barycentric coords from area ratios Now, let s rearrange the equation from two slides ago: The determinant is then just the z-component of B-A) C-A), which is two times the area of triangle ABC! Thus, we find: B x C y B y C x + A y C x A x C y + A x B y A y B x = B x A x )C y A y ) B y A y )C x A x ) = SAreapBC) SAreaABC) = SAreaApC) SAreaABC) = SAreaABp) SAreaABC) Where SAreaRST) is the signed area of a triangle, which can be computed with cross-products. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 24

Affine and convex combinations Note that we seem to have added points together, which we said was illegal, but as long as they have coefficients that sum to one, it s ok. We call this an affine combination. More generally is a proper affine combination if: n i= 1! = 1 i p = 1 p 1 +K+ n p n Note that if the α i s are all positive, the result is more specifically called a convex combination. Q: Why is it called a convex combination? University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 25

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 26 Basic 3-D transformations: scaling Some of the 3-D transformations are just like the 2-D ones. For example, scaling: x y z 1 = s x 0 0 0 0 s y 0 0 0 0 s z 0 0 0 0 1 x y z 1

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 27 Translation in 3D x y z 1 = 1 0 0 t x 0 1 0 t y 0 0 1 t z 0 0 0 1 x y z 1

Rotation in 3D Rotation now has more possibilities in 3D: 1 0 0 0 ) 0 cos) sin) 0 R x ) = ) 0 sin) cos) 0) ) 0 0 0 1 cos) 0 sin) 0 ) 0 1 0 0 R y ) = ) sin) 0 cos) 0) ) 0 0 0 1 cos) sin) 0 0 ) sin) cos) 0 0 R z ) = ) 0 0 1 0) ) 0 0 0 1 R z R y R x Use right hand rule University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 28

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 29 Shearing in 3D Shearing is also more complicated. Here is one example: We call this a shear with respect to the x-z plane. x y z 1 = 1 b 0 0 0 1 0 0 0 0 1 0 0 0 0 1 x y z 1

Preservation of affine combinations A transformation F is an affine transformation if it preserves affine combinations: where the p i are points, and: F 1 p 1 +K+ n p n ) = 1 Fp 1 ) +K+ n Fp n ) n i= 1 = 1 Clearly, the matrix form of F has this property. One special example is a matrix that drops a dimension. For example: This transformation, known as an orthographic projection, is an affine transformation. We ll use this fact later! x x 1 0 0 0 y = 0 1 0 0 y z 1 0 0 0 1 1 i University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 30

Properties of affine transformations Here are some useful properties of affine transformations: Lines map to lines Parallel lines remain parallel Midpoints map to midpoints in fact, ratios are always preserved) ratio = pq qr = s t = p q q r University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 31

Summary What to take away from this lecture: All the names in boldface. How points and transformations are represented. What all the elements of a 2 x 2 transformation matrix do and how these generalize to 3 x 3 transformations. What homogeneous coordinates are and how they work for affine transformations. How to concatenate transformations. The rules for combining points and vectors The mathematical properties of affine transformations. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 32

Next class: Shading Topics we ll cover: - How does light interact with surfaces? - What approximations do we use to model this interaction in computer graphics? Read: Watt, sections 6.2 6.3 Optional Reading: Watt, chapter 7. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 33