Transformations Aaron Bloomfield CS 445: Introduction to Graphics

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Lecture 3: Transformations and Viewing. General Idea Object in model coordinates Transform into world coordinates Represent points on object as vectors.
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.
Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.
Three Dimensional Modeling Transformations
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
MAE152 Computer Graphicsfor Scientists and Engineers Revision of Matrices Relevance to Graphics.
Transformations II Week 2, Wed Jan 17
Geometry (Many slides adapted from Octavia Camps and Amitabh Varshney)
2D Geometric Transformations
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
Welcome to CSc 830 Advanced Computer Graphics
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Computer Graphics (Fall 2008) COMS 4160, Lecture 3: Transformations 1
Computer Graphics (Fall 2004) COMS 4160, Lecture 3: Transformations 1
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
CS 450: Computer Graphics 2D TRANSFORMATIONS
An Introduction to Robot Kinematics
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 2: Review of Basic Math
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1
Mathematical Fundamentals
HCT.
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
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.
Mathematical Foundations Sections A-1 to A-5 Some of the material in these slides may have been adapted from university of Virginia, MIT and Åbo Akademi.
CS 445 / 645 Introduction to Computer Graphics Lecture 3 Mathematical Primitives Introduction to Transformations Lecture 3 Mathematical Primitives Introduction.
Lecture Notes: Computer Graphics.
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
The Rendering Pipeline CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
CS559: Computer Graphics Lecture 8: 3D Transforms Li Zhang Spring 2008 Most Slides from Stephen Chenney.
Geometric Transformations
Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
David Luebke1/10/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
January 19, y X Z Translations Objects are usually defined relative to their own coordinate system. We can translate points in space to new positions.
3-D Geometric Transformations
3-D Transformational Geometry CS418 Computer Graphics John C. Hart.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Transformations: Projection CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Affine Geometry.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 3: Transformations 1
Computer Graphics Matrices
3D Coordinate Systems o3D computer graphics involves the additional dimension of depth, allowing more realistic representations of 3D objects in the real.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Graphics Lecture 2: Slide 1 Lecture 2 Transformations for animation.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Composite 3D Transformations. Example of Composite 3D Transformations Try to transform the line segments P 1 P 2 and P 1 P 3 from their start position.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Week 5 - Monday.  What did we talk about last time?  Lines and planes  Trigonometry  Transforms  Affine transforms  Rotation  Scaling  Shearing.
David Luebke3/11/2016 CS 551 / 645: Introductory Computer Graphics Geometric transforms: perspective projection Color.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
CS 325 Introduction to Computer Graphics 02 / 19 / 2010 Instructor: Michael Eckmann.
4. Affine transformations. Reading Required:  Watt, Section 1.1. Further reading:  Foley, et al, Chapter  David F. Rogers and J. Alan Adams,
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
CSE 167 [Win 17], Lecture 3: Transformations 1 Ravi Ramamoorthi
Computer Graphics Transformations.
Introduction to Computer Graphics CS 445 / 645
Lecture 03: Linear Algebra
CSCE441: Computer Graphics 2D/3D Transformations
Presentation transcript:

Transformations Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)

Graphics coordinate systems X is red Y is green Z is blue

Graphics coordinate systems If you are on the +z axis, and +y is up, then +x is to the right Math fields have +x going to the left

Outline Scaling Rotations Composing Rotations Homogeneous Coordinates Translations Projections

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

Outline Scaling Rotations Composing Rotations Homogeneous Coordinates Translations Projections

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

2-D Rotation This is easy to capture in matrix form: 3-D is more complicated Need to specify an axis of rotation Simple cases: rotation about X, Y, Z axes

Rotation example: airplane

3-D Rotation What does the 3-D rotation matrix look like for a rotation about the Z-axis? Build it coordinate-by-coordinate 2-D rotation from last slide:

3-D Rotation What does the 3-D rotation matrix look like for a rotation about the Y-axis? Build it coordinate-by-coordinate

3-D Rotation What does the 3-D rotation matrix look like for a rotation about the X-axis? Build it coordinate-by-coordinate

Rotations about the axes

3-D Rotation General rotations in 3-D require rotating about an arbitrary axis of rotation Deriving the rotation matrix for such a rotation directly is a good exercise in linear algebra Another approach: express general rotation as composition of canonical rotations Rotations about X, Y, Z

Outline Scaling Rotations Composing Rotations Homogeneous Coordinates Translations Projections

Composing Canonical Rotations Goal: rotate about arbitrary vector A by  Idea: we know how to rotate about X,Y,Z So, rotate about Y by  until A lies in the YZ plane Then rotate about X by  until A coincides with +Z Then rotate about Z by  Then reverse the rotation about X (by -) Then reverse the rotation about Y (by -) Show video…

Composing Canonical Rotations First: rotating about Y by  until A lies in YZ Draw it… How exactly do we calculate ? Project A onto XZ plane Find angle  to X:  = -(90° - ) =  - 90 ° Second: rotating about X by  until A lies on Z How do we calculate ?

3-D Rotation Matrices So an arbitrary rotation about A composites several canonical rotations together We can express each rotation as a matrix Compositing transforms == multiplying matrices Thus we can express the final rotation as the product of canonical rotation matrices Thus we can express the final rotation with a single matrix!

Compositing Matrices So we have the following matrices: p: The point to be rotated about A by  Ry : Rotate about Y by  Rx  : Rotate about X by  Rz : Rotate about Z by  Rx  -1: Undo rotation about X by  Ry-1 : Undo rotation about Y by  In what order should we multiply them?

Compositing Matrices Remember: the transformations, in order, are written from right to left In other words, the first matrix to affect the vector goes next to the vector, the second next to the first, etc. This is the rule with column vectors (OpenGL); row vectors would be the opposite So in our case: p’ = Ry-1 Rx  -1 Rz Rx  Ry p

Rotation Matrices Notice these two matrices: Rx  : Rotate about X by  Rx  -1: Undo rotation about X by  How can we calculate Rx  -1? Obvious answer: calculate Rx (-) Clever answer: exploit fact that rotation matrices are orthonormal What is an orthonormal matrix? What property are we talking about?

Rotation Matrices Rotation matrix is orthogonal Columns/rows linearly independent Columns/rows sum to 1 The inverse of an orthogonal matrix is just its transpose:

Rotation Matrix for Any Axis Given glRotated (angle, x, y, z) Let c = cos(angle) Let s = sin(angle) And normalize the vector so that ||(x,y,z|| == 1 The produced matrix to rotate something by angle degrees around the axis (x,y,z) is:

Outline Scaling Rotations Composing Rotations Homogeneous Coordinates Translations Projections

Translations For convenience we usually describe objects in relation to their own coordinate system We can translate or move points to a new position by adding offsets to their coordinates: Note that this translates all points uniformly

Translation Matrices? We can composite scale matrices just as we did rotation matrices But how to represent translation as a matrix? Answer: with homogeneous coordinates

Homogeneous Coordinates Homogeneous coordinates: represent coordinates in 3 dimensions with a 4-vector [x, y, z, 0]T represents a point at infinity (use for vectors) [0, 0, 0]T is not allowed Note that typically w = 1 in object coordinates

Homogeneous Coordinates Homogeneous coordinates seem unintuitive, but they make graphics operations much easier Our transformation matrices are now 4x4:

Homogeneous Coordinates Homogeneous coordinates seem unintuitive, but they make graphics operations much easier Our transformation matrices are now 4x4:

Homogeneous Coordinates Homogeneous coordinates seem unintuitive, but they make graphics operations much easier Our transformation matrices are now 4x4:

Homogeneous Coordinates Homogeneous coordinates seem unintuitive, but they make graphics operations much easier Our transformation matrices are now 4x4: Performing a scale:

More On Homogeneous Coords What effect does the following matrix have? Conceptually, the fourth coordinate w is a bit like a scale factor

More On Homogeneous Coords Intuitively: The w coordinate of a homogeneous point is typically 1 Decreasing w makes the point “bigger”, meaning further from the origin Homogeneous points with w = 0 are thus “points at infinity”, meaning infinitely far away in some direction. (What direction?) To help illustrate this, imagine subtracting two homogeneous points

Outline Scaling Rotations Composing Rotations Homogeneous Coordinates Translations Projections

Homogeneous Coordinates How can we represent translation as a 4x4 matrix? A: Using the rightmost column: Performing a translation:

Translation Matrices Now that we can represent translation as a matrix, we can composite it with other transformations Ex: rotate 90° about X, then 10 units down Z:

Translation Matrices Now that we can represent translation as a matrix, we can composite it with other transformations Ex: rotate 90° about X, then 10 units down Z:

Translation Matrices Now that we can represent translation as a matrix, we can composite it with other transformations Ex: rotate 90° about X, then 10 units down Z:

Translation Matrices Now that we can represent translation as a matrix, we can composite it with other transformations Ex: rotate 90° about X, then 10 units down Z:

Transformation Commutativity Is matrix multiplication, in general, commutative? Does AB = BA? What about rotation, scaling, and translation matrices? Does RxRy = RyRx? Does RAS = SRA ? Does RAT = TRA ?

Outline Scaling Rotations Composing Rotations Homogeneous Coordinates Translations Projections

Perspective Projection In the real world, objects exhibit perspective foreshortening: distant objects appear smaller The basic situation:

Perspective Projection When we do 3-D graphics, we think of the screen as a 2-D window onto the 3-D world The view plane How tall should this bunny be?

Perspective Projection The geometry of the situation is that of similar triangles. View from above: What is x? P (x, y, z) X Z View plane d (0,0,0) x’ = ?

Perspective Projection Desired result for a point [x, y, z, 1]T projected onto the view plane: What could a matrix look like to do this?

A Perspective Projection Matrix Answer:

A Perspective Projection Matrix Example: Or, in 3-D coordinates:

A Perspective Projection Matrix OpenGL’s gluPerspective() command generates a slightly more complicated matrix: Can you figure out what this matrix does?

Projection Matrices Now that we can express perspective foreshortening as a matrix, we can composite it onto our other matrices with the usual matrix multiplication End result: can create a single matrix encapsulating modeling, viewing, and projection transforms Though you will recall that in practice OpenGL separates the modelview from projection matrix (why?)