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



Similar documents
TWO-DIMENSIONAL TRANSFORMATION

CS 4204 Computer Graphics

2D Geometric Transformations

Rotation Matrices and Homogeneous Transformations

Lecture 3: Coordinate Systems and Transformations

9.4. The Scalar Product. Introduction. Prerequisites. Learning Style. Learning Outcomes

Computer Graphics Lecture Notes

Cross product and determinants (Sect. 12.4) Two main ways to introduce the cross product

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

Essential Mathematics for Computer Graphics fast

Geometric Transformations

Linear Algebra Notes for Marsden and Tromba Vector Calculus

Computer Graphics Labs

Vector Math Computer Graphics Scott D. Anderson

Geometry of Vectors. 1 Cartesian Coordinates. Carlo Tomasi

Geometric Transformation CS 211A

Affine Transformations

Lecture L3 - Vectors, Matrices and Coordinate Transformations

Solving Simultaneous Equations and Matrices

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

Chapter 17. Orthogonal Matrices and Symmetries of Space

GCE Mathematics (6360) Further Pure unit 4 (MFP4) Textbook

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

Orthogonal Projections

11.1. Objectives. Component Form of a Vector. Component Form of a Vector. Component Form of a Vector. Vectors and the Geometry of Space

Dot product and vector projections (Sect. 12.3) There are two main ways to introduce the dot product

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

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

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

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

v w is orthogonal to both v and w. the three vectors v, w and v w form a right-handed set of vectors.

Linear algebra and the geometry of quadratic equations. Similarity transformations and orthogonal matrices

Geometric Camera Parameters

Section V.3: Dot Product

THREE DIMENSIONAL GEOMETRY

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Advanced Computer Science. Friday 18 th January 2008.

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

Using row reduction to calculate the inverse and the determinant of a square matrix

The Matrix Elements of a 3 3 Orthogonal Matrix Revisited

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

Section 9.1 Vectors in Two Dimensions

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

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.

Geometry for Computer Graphics

Unified Lecture # 4 Vectors

1 Introduction to Matrices

Chapter 6. Linear Transformation. 6.1 Intro. to Linear Transformation

Aston University. School of Engineering & Applied Science

Vector Algebra II: Scalar and Vector Products

9 MATRICES AND TRANSFORMATIONS

Excel supplement: Chapter 7 Matrix and vector algebra

Notes on Orthogonal and Symmetric Matrices MENU, Winter 2013

Au = = = 3u. Aw = = = 2w. so the action of A on u and w is very easy to picture: it simply amounts to a stretching by 3 and 2, respectively.

Geometric Transformations

AP Physics - Vector Algrebra Tutorial

Lecture 2: Homogeneous Coordinates, Lines and Conics

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

CMSC 425: Lecture 13 Animation for Games: Basics Tuesday, Mar 26, 2013

Georgia Department of Education Kathy Cox, State Superintendent of Schools 7/19/2005 All Rights Reserved 1

CS3220 Lecture Notes: QR factorization and orthogonal transformations

Lecture 2 Matrix Operations

[1] Diagonal factorization

Linear Algebra: Vectors

Similarity and Diagonalization. Similar Matrices

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

B4 Computational Geometry

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

Section 1.1. Introduction to R n

The Force Table Introduction: Theory:

v 1 v 3 u v = (( 1)4 (3)2, [1(4) ( 2)2], 1(3) ( 2)( 1)) = ( 10, 8, 1) (d) u (v w) = (u w)v (u v)w (Relationship between dot and cross product)

Name: Section Registered In:

8 Square matrices continued: Determinants

The elements used in commercial codes can be classified in two basic categories:

α = u v. In other words, Orthogonal Projection

Least-Squares Intersection of Lines

Projective Geometry: A Short Introduction. Lecture Notes Edmond Boyer

Interactive Computer Graphics

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

A vector is a directed line segment used to represent a vector quantity.

Review A: Vector Analysis

Parametric Equations and the Parabola (Extension 1)

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

Human-like Arm Motion Generation for Humanoid Robots Using Motion Capture Database

LS.6 Solution Matrices

Rotation about an arbitrary axis and reflection through an arbitrary plane

Lecture 7. Matthew T. Mason. Mechanics of Manipulation. Lecture 7. Representing Rotation. Kinematic representation: goals, overview

Math 115A HW4 Solutions University of California, Los Angeles. 5 2i 6 + 4i. (5 2i)7i (6 + 4i)( 3 + i) = 35i + 14 ( 22 6i) = i.

Linear Programming. March 14, 2014

Big Ideas in Mathematics

One advantage of this algebraic approach is that we can write down


Vector has a magnitude and a direction. Scalar has a magnitude

m i: is the mass of each particle

MODERN APPLICATIONS OF PYTHAGORAS S THEOREM

PYTHAGOREAN TRIPLES KEITH CONRAD

Algebra 2 Chapter 1 Vocabulary. identity - A statement that equates two equivalent expressions.

Vector and Matrix Norms

Vector Algebra CHAPTER 13. Ü13.1. Basic Concepts

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

Inner Product Spaces

Transcription:

3 3.1 2D Given a point cloud, polygon, or sampled parametric curve, we can use transformations for several purposes: 1. Change coordinate frames (world, window, viewport, device, etc). 2. Compose objects of simple parts with local scale/position/orientation of one part defined with regard to other parts. For example, for articulated objects. 3. Use deformation to create new shapes. 4. Useful for animation. There are three basic classes of transformations: 1. Rigid body - Preserves distance and angles. Examples: translation and rotation. 2. Conformal - Preserves angles. Examples: translation, rotation, and uniform scaling. 3. Affine - Preserves parallelism. Lines remain lines. Examples: translation, rotation, scaling, shear, and reflection. Examples of transformations: Translation by vector t: p 1 = p 0 + t. [ cos(θ) sin(θ) Rotation counterclockwise by θ: p 1 = sin(θ) cos(θ) Copyright c 2005 David Fleet and Aaron Hertzmann 10

Uniform scaling by scalar a: p 1 = [ a 0 0 a Nonuniform scaling by a and b: p 1 = [ a 0 0 b Shear by scalar h: p 1 = [ 1 h 0 1 Reflection about the y-axis: p 1 = [ 1 0 0 1 3.2 Affine An affine transformation takes a point p to q according to q = F( p) = A p + t, a linear transformation followed by a translation. You should understand the following proofs. Copyright c 2005 David Fleet and Aaron Hertzmann 11

The inverse of an affine transformation is also affine, assuming it exists. Proof: Let q = A p + t and assume A 1 exists, i.e. det(a) 0. Then A p = q t, so p = A 1 q A 1 t. This can be rewritten as p = B q + d, where B = A 1 and d = A 1 t. Note: The inverse of a 2D linear transformation is [ 1 [ a b A 1 1 = = c d ad bc d b c a. Lines and parallelism are preserved under affine transformations. Proof: To prove lines are preserved, we must show that q(λ) = F( l(λ)) is a line, where F( p) = A p + t and l(λ) = p 0 + λ d. q(λ) = A l(λ) + t = A( p 0 + λ d) + t = (A p 0 + t) + λa d This is a parametric form of a line through A p 0 + t with direction A d. Given a closed region, the area under an affine transformation A p + t is scaled by det(a). Note: Rotations and translations have det(a) = 1. [ a 0 Scaling A = has det(a) = ab. 0 b Singularities have det(a) = 0. Example: [ 1 0 The matrix A = maps all points to the x-axis, so the area of any closed 0 0 region will become zero. We have det(a) = 0, which verifies that any closed region s area will be scaled by zero. Copyright c 2005 David Fleet and Aaron Hertzmann 12

A composition of affine transformations is still affine. Proof: Let F 1 ( p) = A 1 p + t 1 and F 2 ( p) = A 2 p + t 2. Then, F( p) = F 2 (F 1 ( p)) = A 2 (A 1 p + t 1 ) + t 2 = A 2 A 1 p + (A 2 t 1 + t 2 ). Letting A = A 2 A 1 and t = A 2 t 1 + t 2, we have F( p) = A p + t, and this is an affine transformation. 3.3 Homogeneous Coordinates Homogeneous coordinates are another way to represent points to simplify the way in which we express affine transformations. Normally, bookkeeping would become tedious when affine transformations of the form A p + t are composed. With homogeneous coordinates, affine transformations become matrices, and composition of transformations is as simple as matrix multiplication. In future sections of the course we exploit this in much more powerful ways. With homogeneous coordinates, a point p is augmented with a 1, to form ˆp = All points (α p,α) represent the same point p for real α 0. Given ˆp in homogeneous coordinates, to get p, we divide ˆp by its last component and discard the last component. Example: The homogeneous points (2, 4, 2) and (1, 2, 1) both represent the Cartesian point (1, 2). It s the orientation of ˆp that matters, not its length. [ p 1. Many transformations become linear in homogeneous coordinates, including affine transformations: [ [ [ [ qx a b px tx = + q y c d p y t y [ p a b x tx = p c d t y y 1 = [ A t ˆp Copyright c 2005 David Fleet and Aaron Hertzmann 13

To produce ˆq rather than q, we can add a row to the matrix: [ a b t A t x ˆq = 0 T ˆp = c d t y 1 0 0 1 This is linear! Bookkeeping becomes simple under composition. Example: F [ 3 (F 2 (F 1 ( p))), where F i ( p) = A i ( p) + t i becomes M 3 M 2 M 1 p, where M i = Ai t i 0 T. 1 ˆp. With homogeneous coordinates, the following properties of affine transformations become apparent: Affine transformations are associative. For affine transformations F 1, F 2, and F 3, Affine transformations are not commutative. For affine transformations F 1 and F 2, (F 3 F 2 ) F 1 = F 3 (F 2 F 1 ). F 2 F 1 F 1 F 2. 3.4 Uses and Abuses of Homogeneous Coordinates Homogeneous coordinates provide a different representation for Cartesian coordinates, and cannot be treated in quite the same way. For example, consider the midpoint between two points p 1 = (1, 1) and p 2 = (5, 5). The midpoint is ( p 1 + p 2 )/2 = (3, 3). We can represent these points in homogeneous coordinates as ˆp 1 = (1, 1, 1) and ˆp 2 = (5, 5, 1). Directly applying the same computation as above gives the same resulting point: (3, 3, 1). However, we can also represent these points as ˆp 1 = (2, 2, 2) and ˆp 2 = (5, 5, 1). We then have (ˆp 1 + ˆp 2)/2 = (7/2, 7/2, 3/2), which cooresponds to the Cartesian point (7/3, 7/3). This is a different point, and illustrates that we cannot blindly apply geometric operations to homogeneous coordinates. The simplest solution is to always convert homogeneous coordinates to Cartesian coordinates. That said, there are several important operations that can be performed correctly in terms of homogeneous coordinates, as follows. Copyright c 2005 David Fleet and Aaron Hertzmann 14

Affine transformations. An important case in the previous section is applying an affine transformation to a point in homogeneous coordinates: q = F( p) = A p + t (1) ˆq = ˆp = (x,y, 1) T (2) It is easy to see that this operation is correct, since rescaling ˆp does not change the result: which is the same geometric point as ˆq = (x,y, 1) T Â(αˆp) = α(âˆp) = αˆq = (αx,αy,α) T (3) Vectors. We can represent a vector v = (x, y) in homogeneous coordinates by setting the last element of the vector to be zero: ˆv = (x,y, 0). However, when adding a vector to a point, the point must have the third component be 1. ˆq = ˆp + ˆv (4) (x,y, 1) T = (x p,y p, 1) + (x,y, 0) (5) The result is clearly incorrect if the third component of the vector is not 0. Aside: Homogeneous coordinates are a representation of points in projective geometry. 3.5 Hierarchical It is often convenient to model objects as hierarchically connected parts. For example, a robot arm might be made up of an upper arm, forearm, palm, and fingers. Rotating at the shoulder on the upper arm would affect all of the rest of the arm, but rotating the forearm at the elbow would affect the palm and fingers, but not the upper arm. A reasonable hierarchy, then, would have the upper arm at the root, with the forearm as its only child, which in turn connects only to the palm, and the palm would be the parent to all of the fingers. Each part in the hierarchy can be modeled in its own local coordinates, independent of the other parts. For a robot, a simple square might be used to model each of the upper arm, forearm, and so on. Rigid body transformations are then applied to each part relative to its parent to achieve the proper alignment and pose of the object. For example, the fingers are positioned to be in the appropriate places in the palm coordinates, the fingers and palm together are positioned in forearm coordinates, and the process continues up the hierarchy. Then a transformation applied to upper arm coordinates is also applied to all parts down the hierarchy. Copyright c 2005 David Fleet and Aaron Hertzmann 15

3.6 in OpenGL OpenGL manages two 4 4 transformation matrices: the modelview matrix, and the projection matrix. Whenever you specify geometry (using glvertex), the vertices are transformed by the current modelview matrix and then the current projection matrix. Hence, you don t have to perform these transformations yourself. You can modify the entries of these matrices at any time. OpenGL provides several utilities for modifying these matrices. The modelview matrix is normally used to represent geometric transformations of objects; the projection matrix is normally used to store the camera transformation. For now, we ll focus just on the modelview matrix, and discuss the camera transformation later. To modify the current matrix, first specify which matrix is going to be manipulated: use glmatrixmode(gl MODE to modify the modelview matrix. The modelview matrix can then be initialized to the identity with glloadidentity(). The matrix can be manipulated by directly filling its values, multiplying it by an arbitrary matrix, or using the functions OpenGL provides to multiply the matrix by specific transformation matrices (glrotate, gltranslate, and glscale). Note that these transformations right-multiply the current matrix; this can be confusing since it means that you specify transformations in the reverse of the obvious order. Exercise: why does OpenGL right-multiply the current matrix? OpenGL provides a stacks to assist with hierarchical transformations. There is one stack for the modelview matrix and one for the projection matrix. OpenGL provides routines for pushing and popping matrices on the stack. The following example draws an upper arm and forearm with shoulder and elbow joints. The current modelview matrix is pushed onto the stack and popped at the end of the rendering, so, for example, another arm could be rendered without the transformations from rendering this arm affecting its modelview matrix. Since each OpenGL transformation is applied by multiplying a matrix on the right-hand side of the modelview matrix, the transformations occur in reverse order. Here, the upper arm is translated so that its shoulder position is at the origin, then it is rotated, and finally it is translated so that the shoulder is in its appropriate world-space position. Similarly, the forearm is translated to rotate about its elbow position, then it is translated so that the elbow matches its position in upper arm coordinates. glpushmatrix(); gltranslatef(worldshoulderx, worldshouldery, 0.0f); drawshoulderjoint(); glrotatef(shoulderrotation, 0.0f, 0.0f, 1.0f); gltranslatef(-upperarmshoulderx, -upperarmshouldery, 0.0f); drawupperarmshape(); gltranslatef(upperarmelbowx, upperarmelbowy, 0.0f); Copyright c 2005 David Fleet and Aaron Hertzmann 16

drawelbowjoint(); glrotatef(elbowrotation, 0.0f, 0.0f, 1.0f); gltranslatef(-forearmelbowx, -forearmelbowy, 0.0f); drawforearmshape(); glpopmatrix(); Copyright c 2005 David Fleet and Aaron Hertzmann 17