Introduction to Computer Graphics CS 445 / 645

Slides:



Advertisements
Similar presentations
CS 691 Computational Photography Instructor: Gianfranco Doretto Image Warping.
Advertisements

Computer Graphics Lecture 4 Geometry & Transformations.
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
Geometric Transformations
Transformations II Week 2, Wed Jan 17
Image Warping : Computational Photography Alexei Efros, CMU, Fall 2006 Some slides from Steve Seitz
Graphics-1 Gentle Introduction to Computer Graphics (2) Based on: –David Brogan’s “Introduction to Computer Graphics” Course Slides, University of Virginia.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
Image Warping : Computational Photography Alexei Efros, CMU, Fall 2008 Some slides from Steve Seitz
Image Warping : Computational Photography Alexei Efros, CMU, Fall 2005 Some slides from Steve Seitz
Course Website: Computer Graphics 3: 2D Transformations.
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)
Geometric Transformation-2D
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
Image Warping Computational Photography Derek Hoiem, University of Illinois 09/27/11 Many slides from Alyosha Efros + Steve Seitz Photo by Sean Carroll.
CS 450: Computer Graphics 2D TRANSFORMATIONS
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
Image Warping (Szeliski 3.6.1) cs129: Computational Photography James Hays, Brown, Fall 2012 Slides from Alexei Efros and Steve Seitz
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Transformations Dr. Amy Zhang.
Multimedia Programming 06: Image Warping Departments of Digital Contents Sang Il Park.
Warping CSE 590 Computational Photography Tamara Berg.
Graphics Graphics Korea University cgvr.korea.ac.kr 2D Geometric Transformations 고려대학교 컴퓨터 그래픽스 연구실.
Lecture Notes: Computer Graphics.
ICS201 Lecture 12 : Gentle Introduction to Computer Graphics II King Fahd University of Petroleum & Minerals College of Computer Science & Engineering.
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Multimedia Programming 07: Image Warping Keyframe Animation Departments of Digital Contents Sang Il Park.
Recap from Monday DCT and JPEG Point Processing Histogram Normalization Questions: JPEG compression levels Gamma correction.
Image Warping Many slides from Alyosha Efros + Steve Seitz + Derek oeim Photo by Sean Carroll.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Image Warping 2D Geometric Transformations
CSCE 441 Computer Graphics: 2D Transformations
Modeling Transformation
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
Transformations University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner.
Computer Graphics Lecture 15 Fasih ur Rehman. Last Class Combining Transformations Affine versus Rigid body Transformations Homogenous Transformations.
2D Geometry - points and polygons
Computer Graphics 2D Transformations
Geometric Transformations
Transformations Objectives
3. Transformation
Geometric Transformations Hearn & Baker Chapter 5
2D Geometric Transformations
Computer Graphics Transformations.
2D Transformations with Matrices
Review: Transformations
Computer Graphics Lecture 18 3-D Transformations-II Taqdees A
3D Geometric Transformations
Computational Photography Derek Hoiem, University of Illinois
Computer Graphics Transformations.
2D Transformations y y x x y x.
Homogeneous Coordinates (Projective Space)
Image Warping (Szeliski Sec 2.1.2)
Image Warping (Szeliski Sec 2.1.2)
Computer Graphics Transformations
Image Warping : Computational Photography
COMP 175: Computer Graphics February 9, 2016
Recap from Friday Image Completion Synthesis Order Graph Cut Scene Completion.
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Transformations 3 University of British Columbia
Image Warping : Computational Photography
Image Warping (Szeliski Sec 2.1.2)
Geometric Objects and Transformations (II)
Rendering – Matrix Transformations and the Graphics Pipeline
Transformations 2 University of British Columbia
TWO DIMENSIONAL TRANSFORMATION
Computational Photography Derek Hoiem, University of Illinois
Presentation transcript:

Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations M.C. Escher – Smaller and Smaller (1956)

Modeling Transformations Specify transformations for objects Allows definitions of objects in own coordinate systems Allows use of object definition multiple times in a scene Remember how OpenGL provides a transformation stack because they are so frequently reused Chapter 5 from Hearn and Baker H&B Figure 109

Overview 2D Transformations 3D Transformations Basic 2D transformations Matrix representation Matrix composition 3D Transformations Basic 3D transformations Same as 2D

2D Modeling Transformations Coordinates Scale Translate y x Scale Rotate Translate World Coordinates

2D Modeling Transformations Coordinates y x Let’s look at this in detail… World Coordinates

2D Modeling Transformations Coordinates y x Initial location at (0, 0) with x- and y-axes aligned

2D Modeling Transformations Coordinates y x Scale .3, .3 Rotate -90 Translate 5, 3

2D Modeling Transformations Coordinates y x Scale .3, .3 Rotate -90 Translate 5, 3

2D Modeling Transformations Coordinates y x Scale .3, .3 Rotate -90 Translate 5, 3 World Coordinates

Scaling Scaling a coordinate means multiplying each of its components by a scalar Uniform scaling means this scalar is the same for all components:  2

Scaling Non-uniform scaling: different scalars per component: How can we represent this in matrix form? X  2, Y  0.5

Scaling Scaling operation: Or, in matrix form: scaling matrix

 (x’, y’) (x, y) 2-D Rotation x’ = x cos() - y sin() y’ = x sin() + y cos()

 (x’, y’) (x, y) 2-D Rotation f x = r cos (f) y = r sin (f) Trig Identity… x’ = r cos(f) cos() – r sin(f) sin() y’ = r sin(f) sin() + r cos(f) cos() Substitute… x’ = x cos() - y sin() y’ = x sin() + y cos()  (x, y) (x’, y’) f

2-D Rotation This is easy to capture in matrix form: Even though sin(q) and cos(q) are nonlinear functions of q, x’ is a linear combination of x and y y’ is a linear combination of x and y

Basic 2D Transformations Translation: x’ = x + tx y’ = y + ty Scale: x’ = x * sx y’ = y * sy Shear: x’ = x + hx*y y’ = y + hy*x Rotation: x’ = x*cosQ - y*sinQ y’ = x*sinQ + y*cosQ Transformations can be combined (with simple algebra)

Basic 2D Transformations Translation: x’ = x + tx y’ = y + ty Scale: x’ = x * sx y’ = y * sy Shear: x’ = x + hx*y y’ = y + hy*x Rotation: x’ = x*cosQ - y*sinQ y’ = x*sinQ + y*cosQ

Basic 2D Transformations Translation: x’ = x + tx y’ = y + ty Scale: x’ = x * sx y’ = y * sy Shear: x’ = x + hx*y y’ = y + hy*x Rotation: x’ = x*cosQ - y*sinQ y’ = x*sinQ + y*cosQ (x,y) (x’,y’) x’ = x*sx y’ = y*sy

Basic 2D Transformations Translation: x’ = x + tx y’ = y + ty Scale: x’ = x * sx y’ = y * sy Shear: x’ = x + hx*y y’ = y + hy*x Rotation: x’ = x*cosQ - y*sinQ y’ = x*sinQ + y*cosQ (x’,y’) x’ = (x*sx)*cosQ - (y*sy)*sinQ y’ = (x*sx)*sinQ + (y*sy)*cosQ

Basic 2D Transformations Translation: x’ = x + tx y’ = y + ty Scale: x’ = x * sx y’ = y * sy Shear: x’ = x + hx*y y’ = y + hy*x Rotation: x’ = x*cosQ - y*sinQ y’ = x*sinQ + y*cosQ (x’,y’) x’ = ((x*sx)*cosQ - (y*sy)*sinQ) + tx y’ = ((x*sx)*sinQ + (y*sy)*cosQ) + ty

Basic 2D Transformations Translation: x’ = x + tx y’ = y + ty Scale: x’ = x * sx y’ = y * sy Shear: x’ = x + hx*y y’ = y + hy*x Rotation: x’ = x*cosQ - y*sinQ y’ = x*sinQ + y*cosQ x’ = ((x*sx)*cosQ - (y*sy)*sinQ) + tx y’ = ((x*sx)*sinQ + (y*sy)*cosQ) + ty

Overview 2D Transformations 3D Transformations Basic 2D transformations Matrix representation Matrix composition 3D Transformations Basic 3D transformations Same as 2D

Matrix Representation Represent 2D transformation by a matrix Multiply matrix by column vector  apply transformation to point

Matrix Representation Transformations combined by multiplication Matrices are a convenient and efficient way to represent a sequence of transformations!

2x2 Matrices What types of transformations can be represented with a 2x2 matrix? 2D Identity? 2D Scale around (0,0)?

2x2 Matrices What types of transformations can be represented with a 2x2 matrix? 2D Rotate around (0,0)? 2D Shear?

2x2 Matrices What types of transformations can be represented with a 2x2 matrix? 2D Mirror about Y axis? 2D Mirror over (0,0)?

2x2 Matrices What types of transformations can be represented with a 2x2 matrix? 2D Translation? NO! Only linear 2D transformations can be represented with a 2x2 matrix

Linear Transformations Linear transformations are combinations of … Scale, Rotation, Shear, and Mirror Properties of linear transformations: Satisfies: Origin maps to origin Lines map to lines Parallel lines remain parallel Ratios are preserved Closed under composition

Homogeneous Coordinates Q: How can we represent translation as a 3x3 matrix?

Homogeneous Coordinates represent coordinates in 2 dimensions with a 3-vector Homogeneous coordinates seem unintuitive, but they make graphics operations much easier

Homogeneous Coordinates Q: How can we represent translation as a 3x3 matrix? A: Using the rightmost column:

Translation Homogeneous Coordinates Example of translation  tx = 2 ty = 1

Homogeneous Coordinates Add a 3rd coordinate to every 2D point (x, y, w) represents a point at location (x/w, y/w) (x, y, 0) represents a point at infinity (0, 0, 0) is not allowed 1 2 (2,1,1) or (4,2,2) or (6,3,3) x y Convenient coordinate system to represent many useful transformations

Basic 2D Transformations Basic 2D transformations as 3x3 matrices Translate Scale Rotate Shear

Affine Transformations Affine transformations are combinations of … Linear transformations, and Translations Properties of affine transformations: Origin does not necessarily map to origin Lines map to lines Parallel lines remain parallel Ratios are preserved Closed under composition

Projective Transformations Affine transformations, and Projective warps Properties of projective transformations: Origin does not necessarily map to origin Lines map to lines Parallel lines do not necessarily remain parallel Ratios are not preserved Closed under composition

Overview 2D Transformations 3D Transformations Basic 2D transformations Matrix representation Matrix composition 3D Transformations Basic 3D transformations Same as 2D

Matrix Composition Transformations can be combined by matrix multiplication p’ = T(tx,ty) R(Q) S(sx,sy) p

Matrix Composition p’ = (T * (R * (S*p) ) ) p’ = (T*R*S) * p Matrices are a convenient and efficient way to represent a sequence of transformations General purpose representation Hardware matrix multiply p’ = (T * (R * (S*p) ) ) p’ = (T*R*S) * p

Matrix Composition p’ = T * R * S * p Be aware: order of transformations matters Matrix multiplication is not commutative p’ = T * R * S * p “Global” “Local”

Matrix Composition What if we want to rotate and translate? Ex: Rotate line segment by 45 degrees about endpoint a and lengthen a a

Multiplication Order – Wrong Way Our line is defined by two endpoints Applying a rotation of 45 degrees, R(45), affects both points We could try to translate both endpoints to return endpoint a to its original position, but by how much? a a a Wrong Correct T(-3) R(45) T(3) R(45)

Multiplication Order - Correct Isolate endpoint a from rotation effects First translate line so a is at origin: T (-3) Then rotate line 45 degrees: R(45) Then translate back so a is where it was: T(3) a a a a

Matrix Composition Will this sequence of operations work?

Matrix Composition After correctly ordering the matrices Multiply matrices together What results is one matrix – store it (on stack)! Multiply this matrix by the vector of each vertex All vertices easily transformed with one matrix multiply

Overview 2D Transformations 3D Transformations Basic 2D transformations Matrix representation Matrix composition 3D Transformations Basic 3D transformations Same as 2D

3D Transformations Same idea as 2D transformations Homogeneous coordinates: (x,y,z,w) 4x4 transformation matrices

Basic 3D Transformations Identity Scale Translation Mirror about Y/Z plane

Basic 3D Transformations Rotate around Z axis: Rotate around Y axis: Rotate around X axis:

Reverse Rotations Q: How do you undo a rotation of q, R(q)? A: Apply the inverse of the rotation… R-1(q) = R(-q) How to construct R-1(q) = R(-q) Inside the rotation matrix: cos(q) = cos(-q) The cosine elements of the inverse rotation matrix are unchanged The sign of the sine elements will flip Therefore… R-1(q) = R(-q) = RT(q)

Summary Coordinate systems 2-D and 3-D transformations World vs. modeling coordinates 2-D and 3-D transformations Trigonometry and geometry Matrix representations Linear vs. affine transformations Matrix operations Matrix composition