How To Understand The Concept Of Transformation In Ces3 (Computer Graphics)



Similar documents
Affine Transformations

MAT188H1S Lec0101 Burbulla

2D Geometric Transformations

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

Computer Graphics Labs

CS 4204 Computer Graphics

9 MATRICES AND TRANSFORMATIONS

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

Introduction to Matrices for Engineers

Rotation and Inter interpolation Using Quaternion Representation

INTRODUCTION TO RENDERING TECHNIQUES

Geometric Camera Parameters

Geometric Transformations

Realtime 3D Computer Graphics Virtual Reality

Addition and Subtraction of Vectors

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

COMPONENTS OF VECTORS

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

Solving Simultaneous Equations and Matrices

Section 1.1. Introduction to R n

Use order of operations to simplify. Show all steps in the space provided below each problem. INTEGER OPERATIONS

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

Exam 1 Sample Question SOLUTIONS. y = 2x

4BA6 - Topic 4 Dr. Steven Collins. Chap. 5 3D Viewing and Projections

SECTION 7-4 Algebraic Vectors

Section V.2: Magnitudes, Directions, and Components of Vectors

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

Elasticity Theory Basics

Math, Trigonometry and Vectors. Geometry. Trig Definitions. sin(θ) = opp hyp. cos(θ) = adj hyp. tan(θ) = opp adj. Here's a familiar image.

TWO-DIMENSIONAL TRANSFORMATION

w = COI EYE view direction vector u = w ( 010,, ) cross product with y-axis v = w u up vector

Essential Mathematics for Computer Graphics fast

Vector Math Computer Graphics Scott D. Anderson

Connecting Transformational Geometry and Transformations of Functions

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

521493S Computer Graphics. Exercise 2 & course schedule change

Geometry for Computer Graphics

Part I. Basic Maths for Game Design

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

Lecture 3: Coordinate Systems and Transformations

Solutions to Homework Section 3.7 February 18th, 2005

x1 x 2 x 3 y 1 y 2 y 3 x 1 y 2 x 2 y 1 0.

South Carolina College- and Career-Ready (SCCCR) Pre-Calculus

Transformations Worksheet. How many units and in which direction were the x-coordinates of parallelogram ABCD moved? C. D.

Lecture L3 - Vectors, Matrices and Coordinate Transformations

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

ME 115(b): Solution to Homework #1

Lecture 2: Homogeneous Coordinates, Lines and Conics

Biggar High School Mathematics Department. National 5 Learning Intentions & Success Criteria: Assessing My Progress

Section Continued

Solutions to old Exam 1 problems

ISOMETRIES OF R n KEITH CONRAD

Complex Numbers. w = f(z) z. Examples

Rotation Matrices and Homogeneous Transformations

Downloaded from equations. 2.4 The reciprocal function x 1 x

In this this review we turn our attention to the square root function, the function defined by the equation. f(x) = x. (5.1)

Section 1: How will you be tested? This section will give you information about the different types of examination papers that are available.

sin(θ) = opp hyp cos(θ) = adj hyp tan(θ) = opp adj

SECTION 2.2. Distance and Midpoint Formulas; Circles

C3: Functions. Learning objectives

CS 4204 Computer Graphics

Lecture 2: Geometric Image Transformations

Lecture Notes. Fundamentals of Computer Graphics. Prof. Michael Langer School of Computer Science McGill University

Introduction to 2D and 3D Computer Graphics Mastering 2D & 3D Computer Graphics Pipelines

3D Viewing. Chapter 7. Projections. 3D clipping. OpenGL viewing functions and clipping planes

LINEAR ALGEBRA W W L CHEN

Dear Accelerated Pre-Calculus Student:

of surface, , , of triangle, 548 Associative Property of addition, 12, 331 of multiplication, 18, 433

Chapter 8. Lines and Planes. By the end of this chapter, you will

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

Geometric Transformations

Solutions to Practice Problems

Dr. Fritz Wilhelm, DVC,8/30/2004;4:25 PM E:\Excel files\ch 03 Vector calculations.doc Last printed 8/30/2004 4:25:00 PM

GeoGebra. 10 lessons. Gerrit Stols

How To Understand And Solve Algebraic Equations

CS3220 Lecture Notes: QR factorization and orthogonal transformations

COMPLEX STRESS TUTORIAL 3 COMPLEX STRESS AND STRAIN

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

Teacher Page. 1. Reflect a figure with vertices across the x-axis. Find the coordinates of the new image.

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

Review Sheet for Test 1

SAT Subject Math Level 2 Facts & Formulas

13.4 THE CROSS PRODUCT

SAT Subject Math Level 1 Facts & Formulas

Maya 2014 Basic Animation & The Graph Editor

Logo Symmetry Learning Task. Unit 5

Math 241, Exam 1 Information.

Gerrit Stols

Metrics on SO(3) and Inverse Kinematics

ORIENTATIONS. Contents

Figure 1.1 Vector A and Vector F

Mathematics Placement Packet Colorado College Department of Mathematics and Computer Science

Fundamentals of Computer Animation

1 Symmetries of regular polyhedra

Animation (-4, -2, 0 ) + (( 2, 6, -4 ) - (-4, -2, 0 ))*.75 = (-4, -2, 0 ) + ( 6, 8, -4)*.75 = (.5, 4, -3 ).

Systems of Linear Equations: Solving by Substitution

Computer Graphics. Introduction. Computer graphics. What is computer graphics? Yung-Yu Chuang

Unified Lecture # 4 Vectors

5.2 Inverse Functions

Transcription:

CS3 INTRODUCTION TO COMPUTER GRAPHICS Geometric Transformations D and 3D

CS3 INTRODUCTION TO COMPUTER GRAPHICS Grading Plan to be out Wednesdas one week after the due date

CS3 INTRODUCTION TO COMPUTER GRAPHICS How do we use Geometric Transformations? (/) } Objects in a scene are a collection of points } These objects have location, orientation, size } Correspond to transformations: Translation (T), Rotation (R), and Scaling (S) 3

CS3 INTRODUCTION TO COMPUTER GRAPHICS How do we use Geometric Transformations? (/) } A scene has a camera/view point from which the scene is viewed } The camera has some location and some orientation in 3-space } These correspond to Translation and Rotation transformations 4

CS3 INTRODUCTION TO COMPUTER GRAPHICS Linear Transformations (/3) } We represent vectors as bold-italic letters (v) and scalars as italic letters (c) 5

CS3 INTRODUCTION TO COMPUTER GRAPHICS Linear Transformations (/3) } Definition of a linear function f: } f(v+w) = f(v) + f(w) for all v and w in the domain of f } f(cv) = cf(v) for all scalars c and elements v in the domain } Example: f(x) = f(x, x ) := (3x +x, -3x +4x ) } Check linearit f(e ) } f(v+w) = f(v +w, v +w ) e = (3(v +w )+(v +w ), -3(v +w )+4(v +w )) e = (3v +v, -3v +4v ) + (3w +w, -3w +4w ) = f(v) + f(w) } We can check the second propert the same wa f(e ) 6

CS3 INTRODUCTION TO COMPUTER GRAPHICS Is X linear? } Is rotation linear? } Is scaling linear? } Is Translation linear? 7

CS3 INTRODUCTION TO COMPUTER GRAPHICS Linear Transformations (3/3) } Graphical use: transformations of points around the origin (leaves the origin invariant) } These include Scaling and Rotations } Translation is not a linear function (moves the origin) 8

CS3 INTRODUCTION TO COMPUTER GRAPHICS Linear Transformations as Matrices (/) } Linear transformations can be represented as matrices } Let s start with D transformations. These can be represented b x matrices: T = a c b d 9

CS3 INTRODUCTION TO COMPUTER GRAPHICS Linear Transformations as Matrices (/) } A transformation of an arbitrar column vector x = has the form: x x + + = = dx cx bx ax x x d c b a x x T

CS3 INTRODUCTION TO COMPUTER GRAPHICS Scaling in D } Scale x b 3, b (S x = 3, S = ) 3

CS3 INTRODUCTION TO COMPUTER GRAPHICS Scaling in D Side effect: House shifts position relative to origin } Scale x b 3, b (S x = 3, S = ) } v = (original vertex); } v = (new vertex) } v = Sv x ' ' x S= s x s 6 9 3

CS3 INTRODUCTION TO COMPUTER GRAPHICS Rotation in D (/) } Rotate b θ about the origin } Derive R θ b determining how e and e should be transformed: θ } (first column of R θ ) } (second column of R θ ) e = sinθ cosθ R θ = cosθ sinθ sinθ cosθ 3

CS3 INTRODUCTION TO COMPUTER GRAPHICS Rotation in D (/) } Let s tr matrix-vector multiplication } R θ * v = cosθ sinθ sinθ x cosθ = x x cosθ sinθ+ sinθ cosθ = x' ' = v' } } x'= xcosθ sinθ '= xsinθ + cosθ } Other properties of rotation: } Preserves lengths in objects and angles between parts of objects (rigid-bod) } For objects not centered at the origin, an unwanted translation might be introduced (rotation is alwas about the origin) 4

CS3 INTRODUCTION TO COMPUTER GRAPHICS What about translation? } Translation is not a linear transformation (the origin is not invariant) } Therefore, it can t be represented as a x invertible matrix } Question: Is there another solution? } Answer: Yes, v = v + t, where t = dx d } However, using vector addition is not consistent with our method of treating transformations as matrices 5

CS3 INTRODUCTION TO COMPUTER GRAPHICS Homogeneous coordinate } Represent a D point } B a 3D vector x x 6

CS3 INTRODUCTION TO COMPUTER GRAPHICS Homogeneous coordinate } Represent a D point } B a 3D vector x x 7

CS3 INTRODUCTION TO COMPUTER GRAPHICS Back to Translation } Our translation matrix (T) can now be represented b embedding the translation vector in the right column: Dimension of T? } To verif that this is the right matrix, multipl it b our homogenized point: } Coordinates have been translated, and v is still homogeneous 8

CS3 INTRODUCTION TO COMPUTER GRAPHICS //3 Back to Translation } Our translation matrix (T) can now be represented b embedding the translation vector in the right column: } To verif that this is the right matrix, multipl it b our homogenized point: } Coordinates have been translated, and v is still homogeneous = d dx T Tv = v' + + = = d dx x x d dx 9

CS3 INTRODUCTION TO COMPUTER GRAPHICS Transformations Homogenized } Let s homogenize our all matrices! Doesn t affect linearit of scaling and rotation } Our new transformation matrices look like this Transformation Scaling Rotation Translation Matrix s x s } Note: These transformations are called affine transformations cosθ sinθ sinθ cosθ dx d

CS3 INTRODUCTION TO COMPUTER GRAPHICS Examples } Scaling: Scale b 5 in the x direction, 7 in the 5 7 } Rotation: Rotate b 3 o cos(3) sin(3) sin(3) cos(3) } Translation: Translate b -6 in the x direction, +8 in the 6 8 //3

CS3 INTRODUCTION TO COMPUTER GRAPHICS Before we continue! Vectors vs. Points } Up until now, we ve onl used the notion of a point in our D space } We now present a distinction between points and vectors } We used homogeneous coordinates to more convenientl represent translation; hence points are represented as (x,, ) T } A vector can be rotated/scaled, not translated (can think of it as alwas starting at origin), don t use the homogeneous coordinate: (x,, ) T } For now, let s focus on just our points (tpicall vertices) //3

CS3 INTRODUCTION TO COMPUTER GRAPHICS Inverses } How do we find the inverse of a transformation? } Take the inverse of the transformation matrix (thanks to homogenization, the are all invertible!): 3

CS3 INTRODUCTION TO COMPUTER GRAPHICS Composition of Transformations (D) (/) } We now have a number of tools at our disposal; we can combine them! } An object in a scene uses man transformations in sequence. How do we represent this in terms of functions? } Think of a transformation that first translates b (, 3) M, then scales b (.5,.3) M. } Our composition is equivalent to M M v //3 4

CS3 INTRODUCTION TO COMPUTER GRAPHICS Composition of Transformations (D) (/) } Compositions of transformation matrices to form a more complex transformation } For example, TRSv, which scales, rotates, then translates a point: dxcosθ sinθ sx x d sinθ cosθ s } We appl the matrices from right to left. Associativit allows composition. One matrix does S, R, and T. No need to multiple 3 times. } Important: order matters! Matrix multiplication is NOT commutative. } Be sure to check out the Transformation Game at http://www.cs.brown.edu/exploratories/freesoftware/ repositor/edu/brown/cs/exploratories/applets/transformationgame/transformation_game_guide.html } Let s see an example //3 5

CS3 INTRODUCTION TO COMPUTER GRAPHICS Not commutative 6 Translate b x = 6, =, then rotate b 45 o 5 4 3 3 4 5 6 7 8 9 Rotate b 45 o, then translate b x = 6, = Y 6 5 4 3 3 4 5 6 7 8 9 X //3 6

CS3 INTRODUCTION TO COMPUTER GRAPHICS //3 Composition (an example) (D) (/) } Start: Goal: } Important concept: make the problem simpler } Translate object to origin first, scale, rotate, and translate back: } Appl to all vertices = 3 3 3 3 cos9 sin 9 sin 9 cos9 3 3 RST T -Uniform scale 3x -Rotate 9 o -Both around object s center, not the origin 7

CS3 INTRODUCTION TO COMPUTER GRAPHICS Composition (an example) (D) (/) } T - RST } But what if we mixed up the order? Let s tr RT - ST: cos9 sin9 3 3 3 sin9 cos9 3 3 3 } Oops! We scaled properl, but when we rotated the object, it s center was not at the origin, so its position was shifted. Order matters! //3 8

CS3 INTRODUCTION TO COMPUTER GRAPHICS Inverses Revisited } What is the inverse of a sequence of transformations? } (M M M n ) - = M n - M n- - M - } Inverse of a sequence of transformations is the composition of the inverses of each transformation in reverse order (wh?) } Sa we want to do the opposite transformation of the example on slide 7. What will our sequence look like? } (T - RST) - = T - S - R - T } We still translate to the origin first, then translate back at the end! T - S - R - T = 3/ 3 3 / 3 cos9 sin 9 sin 9 cos9 3 3 //3 9

CS3 INTRODUCTION TO COMPUTER GRAPHICS Question } You have an object at (3, 4). } What is the transformation to } Rotate b 3 degrees with respect to the object } Scale b along x and 3 along with respect to the object } Translate b (, -) in the world coordinate frame? //3 3

CS3 INTRODUCTION TO COMPUTER GRAPHICS Question } You have an object at (3, 4). } What is the transformation to } Rotate b 3 degrees with respect to the object } Scale b along x and 3 along with respect to the object } Translate b (, -) in the world coordinate frame? } What is the inverse? //3 3

CS3 INTRODUCTION TO COMPUTER GRAPHICS Aside: Skewing/shearing } Skew an object to the side, like shearing a card deck b displacing each card relative to the previous one } What phsical situations mirror this behavior? } Squares become parallelograms; x-coordinates skew to right, stas the same Y 6 5 4 3 θ π θ = 4 3 4 5 6 7 8 9 Skew θ = tanθ D non-homogeneous X } Notice that the base of the house (at = ) remains horizontal but shifts right. Wh? Skew θ tanθ = D homogeneous //3 3

CS3 INTRODUCTION TO COMPUTER GRAPHICS //3 } Windowing transformation maps contents of a D clip rectangle ( window ) to a rectangle on the screen, e.g., interior canvas of a window manager s window ( viewport ), so also known as a window-to-viewport transformation } Sends rectangle with bounding coordinates (u, v i ), (u, v ) to (x, ), (x, ) } The transformation matrix here is: Aside: Windowing Transformations ) ) /( ( ) ) /( ( ) ) /( ( ) ) /( ( v v v v v v u u u x x u u u x x 33

CS3 INTRODUCTION TO COMPUTER GRAPHICS Aside: Homogeneous Coordinates (/3) } Allow expression of all three D transformations as 3x3 matrices } We start with the point P d on the x plane and appl a mapping to bring it to the w- plane in the hperspace } P d (x,) à P h (wx, w, w), w } The resulting (x, ) coordinates in our new point P h are different from the original (x,), since x = wx, = w } P h (x,, w), w //3 34

CS3 INTRODUCTION TO COMPUTER GRAPHICS Aside: Homogeneous Coordinates (/3) } Once we have this point, we can appl a homogenized version of our transformation matrices (next slides) to get a new point in the hperspace } Finall, we want to obtain the corresponding point in D-space, so perform the inverse of the previous mapping (divide all entries b w) } The vertex v = is now represented as v = x x //3 35

CS3 INTRODUCTION TO COMPUTER GRAPHICS Aside: Homogeneous Coordinates (3/3) } The transformations we use will alwas map points in the hperplane defined b w = to other such points. } In other words, we want our transformations T to map points v = to points v = x' ' } How do we achieve this with the matrices we have alread derived? } For linear transformations (i.e. scaling and rotation), embed the existing matrix in the upper-left of a new 3x3 matrix: x a c b d //3 36

CS3 INTRODUCTION TO COMPUTER GRAPHICS Dimension++ (3D!) } How should we treat geometric transformations in 3D? } Just add one more coordinate/axis! } A point is represented as x z } Homogeneous coordinate is x z //3 37

CS3 INTRODUCTION TO COMPUTER GRAPHICS Transformations in 3D Transformation Matrix Comments Scaling sx s Looks just like the D version. We just added an s z term. Rotation (see next slide) In D, onl one axis of rotation; now there are infinitel man! Must take all into account. See next slide... s z Translation dx d dz Similar to the D version, just with one more entr dz, representing change in the z- direction. //3 38

CS3 INTRODUCTION TO COMPUTER GRAPHICS Rodrigues s Formula } Rotation b angle θ around vector u = [u x u u z ] T } Note: this is an arbitrar unit vector u in xz-space } Here s a not so friendl rotation matrix u u x x cosθ u u z + u x ( cosθ ) ( cosθ ) + u ( cosθ ) u sinθ sinθ } This is called the coordinate form of Rodrigues s formula } Let s tr a different approach z u u x u ( cosθ ) u cosθ u z + u ( cosθ ) ( cosθ ) + u z x sinθ sinθ u u x u u z z ( cosθ ) + u ( cosθ ) u cosθ + u z x sinθ sinθ ( cosθ ) //3 39

CS3 INTRODUCTION TO COMPUTER GRAPHICS Rotating axis b axis } Ever rotation can be represented as the composition of 3 different angles of counterclockwise rotation around 3 axes, namel } x-axis in the z plane b ψ; -axis in the xz plane b θ; z-axis in the x plane b ϕ } Also known as Euler angles, make problem of rotation much easier } R z : rotation around x axis, R x : rotation about axis, R x : rotation about z axis } Note these differ onl in how the 3x3 submatrix is embedded in the homogeneous matrix } You can compose these matrices to form a composite rotation matrix //3 4

CS3 INTRODUCTION TO COMPUTER GRAPHICS Inverses and Composition in 3D! } Inverses are once again parallel to their D versions Transformation Inverse Matrix Scaling Rotation Translation /s x /s /s z cosφ sinφ sinφ cosφ, cosψ sinψ sinψ cosψ dx d dz } Composition works exactl the same wa, cosθ sinθ sinθ cosθ //3 4

CS3 INTRODUCTION TO COMPUTER GRAPHICS //3 Example in 3D! } Let s take some 3D object, sa a cube centered at (,,) } Rotate in object s space b 3 o around x axis, 6 o around, and 9 o around z } Scale in object space b in the x, in the, 3 in the z } Translate b (,,4) in world space } Transformation sequence: TT - S x R x R xz R z T o, where T translates to (,): cos3 sin 3 sin 3 cos3 cos6 sin 6 sin 6 cos6 cos9 sin 9 sin 9 cos9 3 4 T T - S x R x R xz R z T 4

CS3 INTRODUCTION TO COMPUTER GRAPHICS Transformations and the scene graph (/4) } Objects can be complex: Scene Graph ROBOT upper bod lower bod head trunkarm arm stanchion base } 3D scenes are often stored in a directed acclic graph (DAG) called a scene graph } WPF (Windows Presentation Foundation) } Open Scene Graph (used in the Cave) } Sun s Java3D } X3D (VRML was a precursor to X3D) } Tpical scene graph format: } objects (cubes, sphere, cone, polhedra etc.): stored as nodes (default: unit size at origin) } attributes (color, texture map, etc.): stored as separate nodes } Transformations: also nodes //3 43

CS3 INTRODUCTION TO COMPUTER GRAPHICS Transformations and the scene graph (3/4) } Notion of a cumulative transformation matrix that builds as ou move up the tree (CTM), appending higher level transformation matrices to the front of the sequence M M M 3 M 4 } Example: } For object (o), CTM = M M 5 } For o, CTM = M M 3 } For o3, CTM = M M 4 M 5 } For a vertex v in o3, position in world coordinate sstem is CTM v = (M M 4 M 5 ) v object nodes (geometr) transformation nodes group nodes //3 44