Lecture 3: Transformations and Viewing. General Idea Object in model coordinates Transform into world coordinates Represent points on object as vectors.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Affine Transformations
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
Computer Graphics Lecture 4 Geometry & Transformations.
1 Computer Graphics Chapter 8 3D Transformations.
Transformations II Week 2, Wed Jan 17
2-D Geometry. The Image Formation Pipeline Outline Vector, matrix basics 2-D point transformations Translation, scaling, rotation, shear Homogeneous.
2D Geometric Transformations
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
Computer Vision : CISC4/689
Computer Graphics (Fall 2008) COMS 4160, Lecture 3: Transformations 1
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
4.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 4 Projection Clipping Viewport Transformation.
Computer Graphics (Fall 2008) COMS 4160, Lecture 4: Transformations 2
Computer Graphics (Fall 2004) COMS 4160, Lecture 3: Transformations 1
Projection Projection - the transformation of points from a coordinate system in n dimensions to a coordinate system in m dimensions where m
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
CS 450: Computer Graphics 2D TRANSFORMATIONS
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
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Viewing and Projections
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.
Transformation & Projection Feng Yu Proseminar Computer Graphics :
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Transformations Jehee Lee Seoul National University.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
2 COEN Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Computer Graphics Bing-Yu Chen National Taiwan University.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 4: Transformations 2
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
CS559: Computer Graphics Lecture 8: 3D Transforms Li Zhang Spring 2008 Most Slides from Stephen Chenney.
University of Texas at Austin CS384G - Computer Graphics Fall 2008 Don Fussell Affine Transformations.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
CS559: Computer Graphics Lecture 8: Warping, Morphing, 3D Transformation Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
1 Chapter 2: Geometric Camera Models Objective: Formulate the geometrical relationships between image and scene measurements Scene: a 3-D function, g(x,y,z)
Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
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
Honours Graphics 2008 Session 2. Today’s focus Vectors, matrices and associated math Transformations and concatenation 3D space.
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.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
4. Affine transformations. Reading Required:  Watt, Section 1.1. Further reading:  Foley, et al, Chapter  David F. Rogers and J. Alan Adams,
Computer Graphics Projections.
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
CSE 167 [Win 17], Lecture 3: Transformations 1 Ravi Ramamoorthi
CSE 167 [Win 17], Lecture 5: Viewing Ravi Ramamoorthi
Geometric Transformations Hearn & Baker Chapter 5
CSCE 441 Computer Graphics 3-D Viewing
Lecture 9: Projection Li Zhang Spring 2008
CENG 477 Introduction to Computer Graphics
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Computer Graphics (Spring 2003)
Viewing (Projections)
Geometrical Transformations
CSCE441: Computer Graphics 2D/3D Transformations
Lecture 8: 3D Transforms Li Zhang Spring 2008
Presentation transcript:

Lecture 3: Transformations and Viewing

General Idea Object in model coordinates Transform into world coordinates Represent points on object as vectors Multiply by matrices

What next? 2D transformations: scale, shear, rotation Composing transformations 3D rotations

(Nonuniform) Scale

Shear

Rotations 2D rotations are simple Can we derive it? x,y

Rotations, contd. Basic properties… Linear Commutative R(X+Y)=R(X)+R(Y)

Outline 2D transformations: rotation, scale, shear Composing transforms 3D rotations Translation: Homogeneous Coordinates Transforming Normals

Composing Transforms Usually we build a complex transformation by composing simple ones (for which we have matrix patterns) E.g. first scale then rotate We see now advantage of matrix formulation: Transformation is performed for many points Complex transformation is in advanced put into a single matrix In general not commutative!! Order matters

E.g. Composing rotations, scales In terms of functions: In terms of matrices: RS is also a matrix RS SR, not commutative

Composing example

Inverting Composite Transforms Say, we want to invert a combination of 3 transforms Option 1: Find composite matrix, invert Option 2: Invert each transform and swap order Obvious from properties of matrices

Outline 2D transformations: rotation, scale, shear Composing transforms 3D rotations Translation: Homogeneous Coordinates Transforming Normals

Orthogonal matrix

Rotations in 3D Rotations about coordinate axes is a simple extension of 2D rotations Again orthogonal matrices

Interpretation 3D Rotations Matrix Rows of matrix are the vectors of new coordinate system (the rotated one) Old coordinate frame: x, y, z versors After transformation: we have new uvw coordinate frame

Geometric Interpretation 3D Rotations Rows of matrix are 3 unit vectors of new coord frame Can construct rotation matrix from 3 orthonormal vectors Effectively, projections of point into new coord frame New coord frame uvw taken to cartesian components xyz Inverse or transpose takes xyz cartesian to uvw

Non-Commutativity Not Commutative (unlike in 2D)!! Rotate by x, then y is not same as y then x Order of applying rotations does matter Follows from matrix multiplication not commutative R1 * R2 is not the same as R2 * R1

Translation

?

Homogeneous Coordinates We need to add a fourth coordinate (w=1). Its quite common way in linear algebra, to get rid off free terms. 4x4 matrices in 3D space - very common in computer graphics w may look like a dummy variable – but may play its role

Representation of Points (4-Vectors) Homogeneous coordinates Divide by 4 th coord (w) to get (inhomogeneous) point Multiplication by w > 0, no effect Assume w 0. For w > 0, normal finite point. For w = 0, point at infinity (used for vectors to stop translation)

What are the Advantages of Homogeneous Coords? Unified framework for translation and other transformations Only 4x4 matrix – easy to concatenate Less problems with perspective viewing No special cases – homogenous formulas

General Translation Matrix

3 basic Rotation Matrices

Combining Translations, Rotations Order matters!! TR is not the same as RT (demo) General form for rigid body transforms We show rotation first, then translation (commonly used to position objects) on next slide. Slide after that works it out the other way

Combining Translations, Rotations First Rotation, then TranslationFirst Translation, then Rotation

Geometry Transformation Podstawy OpenGL Transformations are composed of four elements Viewing transformation – positioning the camera Modeling transformation - moving objects (Viewing and Modeling are complementary) Projection – on the plane Viewport – mapping on the window

Camera analogy Podstawy OpenGL

Camera analogy contd. Podstawy OpenGL

Two ways of making transformation in OpenGL First approach: we operate directly on matrices Second approach: we hide matrix transformations inside functions Which one is better?

Two ways of making transformation in OpenGL Functions typical to old OpenGL. Cancelled in OpenGL 3.0 Transformations and Projections moved to shader programming. Not everyone likes low-level shader programming. Search for new functions…

GLM – OpenGL Mathematics Can be easily found on glm.g-truc.net/, along with other information glm.g-truc.net/ Can be treated as enhancement of GLSL. Is included into unofficial OpenGL SDK

Viewing

Motivation We have seen transforms (between coord systems) But all that is in 3D We still need to make a 2D picture Project 3D to 2D. How do we do this? This lecture is about viewing transformations

Demo (Projection Tutorial) Nate Robbins OpenGL tutors Projection tutorial Old OpenGL Style Demo

What we ve seen so far Transforms (translation, rotation, scale) as 4x4 homogeneous matrices Last row always Last w component always 1 For viewing (perspective), we will use that last row and w component no longer 1 (must divide by it)

Outline Orthographic projection (simpler) Perspective projection, basic idea Derivation of gluPerspective (handout: glFrustum) Brief discussion of nonlinear mapping in z

Projections To lower dimensional space (here 3D -> 2D) Preserve straight lines Trivial example: Drop one coordinate (Orthographic)

Orthographic Projection Characteristic: Parallel lines remain parallel Useful for technical drawings etc. Orthographic Perspective

Example Simply project onto xy plane, drop z coordinate

In general We have a cuboid that we want to map to the normalized or square cube from [-1, +1] in all axes We have parameters of cuboid (l,r ; t,b; n,f) x z y l r t b n f x z Translate y x z y Scale

Orthographic Matrix First center cuboid by translating Then scale into unit cube x z y l r t b n f x z Translate y x z y Scale

Transformation Matrix ScaleTranslation

Caveats Looking down –z, f and n are negative (n > f) OpenGL convention: positive n, f, negate internally x z y l r t b n f x z Translate y x z y Scale

Final Result

Outline Orthographic projection (simpler) Perspective projection, basic idea Derivation of gluPerspective (handout: glFrustum) Brief discussion of nonlinear mapping in z

Perspective Projection Most common computer graphics, art, visual system Further objects are smaller (size, inverse distance) Parallel lines not parallel; converge to single point B A B Center of projection (camera/eye location) A Plane of Projection Slides inspired by Greg Humphreys

Overhead View of Our Screen Looks like weve got some nice similar triangles here? d (0,0,0) (x,y,z)

In Matrices Note negation of z coord (focal plane –d) (Only) last row affected (no longer ) w coord will no longer = 1. Must divide at end

Verify

Outline Orthographic projection (simpler) Perspective projection, basic idea Derivation of gluPerspective (handout: glFrustum) Brief discussion of nonlinear mapping in z

Remember projection tutorial

Viewing Frustum Near plane Far plane

Screen (Projection Plane) Field of view (fovy) width height Aspect ratio = width / height

gluPerspective gluPerspective(fovy, aspect, zNear > 0, zFar > 0) Fovy, aspect control fov in x, y directions zNear, zFar control viewing frustum

In Matrices Simplest form: Aspect ratio taken into account Homogeneous, simpler to multiply through by d Must map z vals based on near, far planes (not yet)