3D Viewing Episode 2

Similar documents
3D Viewing Episode 2

Transformation Pipeline

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

Lecture 4. Viewing, Projection and Viewport Transformations

GEOMETRIC TRANSFORMATIONS AND VIEWING

COMP3421. Vector geometry, Clipping

Graphics pipeline and transformations. Composition of transformations

The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes

Computer Viewing Computer Graphics I, Fall 2008

Transforms 1 Christian Miller CS Fall 2011

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

Viewing with Computers (OpenGL)

CS354 Computer Graphics Viewing and Modeling

CS230 : Computer Graphics Lecture 6: Viewing Transformations. Tamar Shinar Computer Science & Engineering UC Riverside

CS 4204 Computer Graphics

Computer Viewing. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Overview. By end of the week:

3.1 Viewing and Projection

COMP Computer Graphics and Image Processing. 5: Viewing 1: The camera. In part 1 of our study of Viewing, we ll look at ˆʹ U ˆ ʹ F ˆʹ S

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CS 432 Interactive Computer Graphics

Affine Transformations in 3D

3D Viewing. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Fachhochschule Regensburg, Germany, February 15, 2017

CSE328 Fundamentals of Computer Graphics

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

Describe the Orthographic and Perspective projections. How do we combine together transform matrices?

Mouse Ray Picking Explained

Viewing and Projection

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Overview. Viewing and perspectives. Planar Geometric Projections. Classical Viewing. Classical views Computer viewing Perspective normalization

3D Graphics for Game Programming (J. Han) Chapter II Vertex Processing

Transforms. COMP 575/770 Spring 2013

Computer Graphics. Chapter 7 2D Geometric Transformations

Basic Elements. Geometry is the study of the relationships among objects in an n-dimensional space

3D Viewing. CS 4620 Lecture 8

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

7. 3D Viewing. Projection: why is projection necessary? CS Dept, Univ of Kentucky

3D Viewing. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

COMP3421. Introduction to 3D Graphics

CSC 470 Computer Graphics

CS380: Computer Graphics Viewing Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

Computer Viewing. Prof. George Wolberg Dept. of Computer Science City College of New York

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

For each question, indicate whether the statement is true or false by circling T or F, respectively.

Viewing Transformation

3D Viewing. With acknowledge to: Ed Angel. Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Chap 3 Viewing Pipeline Reading: Angel s Interactive Computer Graphics, Sixth ed. Sections 4.1~4.7

One or more objects A viewer with a projection surface Projectors that go from the object(s) to the projection surface

Viewing and Projection

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

Projection Matrix Tricks. Eric Lengyel

Rasterization Overview

COMP3421. Introduction to 3D Graphics

Announcements. Submitting Programs Upload source and executable(s) (Windows or Mac) to digital dropbox on Blackboard

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

Classical and Computer Viewing. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

COMS 4160: Problems on Transformations and OpenGL

INTRODUCTION TO COMPUTER GRAPHICS. It looks like a matrix Sort of. Viewing III. Projection in Practice. Bin Sheng 10/11/ / 52

Overview of Projections: From a 3D world to a 2D screen.

CGT520 Transformations

Viewing and Projection

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting

Perspective Mappings. Contents

CT5510: Computer Graphics. Transformation BOCHANG MOON

CS 130 Final. Fall 2015

THE VIEWING TRANSFORMATION

Linear and Affine Transformations Coordinate Systems

COMP 175 COMPUTER GRAPHICS. Lecture 07: Scene Graph. COMP 175: Computer Graphics March 10, Remco Chang 07 Scene Graph

CS 591B Lecture 9: The OpenGL Rendering Pipeline

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

3D Viewing. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 9

Fall CSCI 420: Computer Graphics. 2.2 Transformations. Hao Li.

OpenGL Transformations

Prof. Feng Liu. Fall /19/2016

COMP Computer Graphics and Image Processing. a6: Projections. In part 2 of our study of Viewing, we ll look at. COMP27112 Toby Howard

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

Perspective transformations

Exercise Max. Points Total 90

Visualisation Pipeline : The Virtual Camera

Advanced Computer Graphics (CS & SE )

Object Representation Affine Transforms. Polygonal Representation. Polygonal Representation. Polygonal Representation of Objects

COMP3421. Introduction to 3D Graphics

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics I. Guoying Zhao 1 / 52

Computer Graphics with OpenGL ES (J. Han) Chapter IV Spaces and Transforms

Answers. Chapter 2. 1) Give the coordinates of the following points:

Mathematics 308 Geometry. Chapter 9. Drawing three dimensional objects

Ray Tracer I: Ray Casting Due date: 12:00pm December 3, 2001

Select, Move, Rotate and Scale

Midterm Exam Fundamentals of Computer Graphics (COMP 557) Thurs. Feb. 19, 2015 Professor Michael Langer

Lecture 4: 3D viewing and projections

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Computer graphics 2: Graduate seminar in computational aesthetics

Projection: Mapping 3-D to 2-D. Orthographic Projection. The Canonical Camera Configuration. Perspective Projection

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

Lecture 8 Ray tracing Part 1: Basic concept Yong-Jin Liu.

Transcription:

3D Viewing Episode 2 1 Positioning and Orienting the Camera Recall that our projection calculations, whether orthographic or frustum/perspective, were made with the camera at (0, 0, 0) looking down the z axis. The camera is also vertically oriented i.e., up is the vector 0, 1, 0. But we want the camera to be anywhere, looking anywhere; how is this done? Recall that transforming an object is equivalent to transforming its axes in the opposite manner: e.g. moving an object centered on the origin to the right by 10 units is visually identical to moving the origin (and its axes) to the left by 10 units. Suppose that we would like to position our camera at some point P the center of projection (COP). The camera is looking toward Q the look-at or eye point and is oriented according to the up vector, which indicates what is vertical relative to the camera. Figure 1 illustrates this setup. 2 Deriving the Transformation The idea here is to derive the transformation such that 1, 0, 0 x e, 0, 1, 0 y e, and 0, 0, 1 z e. x e, y e, and z e are vectors, so they can be broken down in terms of their components as x ex, x ey, x ez, y ex, y ey, y ez, and z ex, z ey, z ez. Thus, the matrix that transforms the standard cartesian axes into axes relative to the camera is: x ey y ey z ey 0 x ez y ez z ez 0 (1) 1

y e < 0, 1, 0 > up Q P x e proj (up, z e ) z e < 1, 0, 0 > < 0, 0, 1 > Figure 1: Setting up the camera in terms of a center of projection P looking toward the point Q with some up vector. 2

So what are x e, y e, and z e anyway? derived from our look-at arguments: Easier than it seems they can actually be z e = U P Q (2) y e = U up proj( up, ze) (3) x e = y e z e (4) Note how, since z e and y e have been normalized into unit vectors, then x e is automatically a unit vector. The matrix in (1) only rotates the coordinate system it is still centered on the origin. Thus, we need to translate the axes to P (note how matrix composition reads from right to left): 1 0 0 P x 0 1 0 P y 0 0 1 P z x ey y ey z ey 0 x ez y ez z ez 0 (5) Remember that (5) is the transformation that converts the axes to match the desired axes for the camera. However, we want the transform that converts the objects in 3D space according to the camera. Thus, what we really want is the inverse of (5) e.g. an object that is at the origin would have coordinates ( P x, P y, P z ) from the perspective of a camera that is located at world coordinates (P x, P y, P z ). Instead of multiplying out the matrices and then inverting after, we use the matrix multiplication identity (AB) 1 = B 1 A 1. So what are the inverses of these matrices? The inverse of the translation matrix is straightforward: we translate by ( P x, P y, P z ) instead of (P x, P y, P z ): 1 0 0 P x 0 1 0 P y 0 0 1 P z (6) The axis orientation matrix is also easy to state, but a little trickier to explain; it is the matrix s transpose (A T ): (7) Now, to see why this is the case, think about the characteristics of x e, y e, and z e. If you look at the product of the axis orientation matrix and its transpose, we get: 3

x ey y ey z ey 0 x ez y ez z ez 0 = x e x e x e y e x e z e 0 y e x e y e y e y e z e 0 z e x e z e y e z e z e 0 (8) x e, y e, and z e are all unit vectors see (4), (3), and (2) and so x e x e, y e y e, and z e z e are all equal to one. Further, x e, y e, and z e are mutually perpendicular to each other and thus the dot product of any two of these vectors is equal to zero. If you substitute those values into the product, note that you get the identity matrix and thus, A 1 = A T for the axis orientation matrix! To wrap it all up, we now have our final lookat matrix: 1 0 0 P x 0 1 0 P y 0 0 1 P z (9) All that s left is to multiply the matrices, yielding: x ex x ey x ez (P x e ) y ex y ey y ez (P y e ) z ex z ey z ez (P z e ) (10) This is what glulookat() multiplies to the current matrix, of course substituting the x e, y e, and z e with their derivations in (4), (3), and (2), respectively. And yes, this transform is affine! 3 Putting Them Together Did you notice that this matrix is applied to the world, and not during projection? This is why the OpenGL code sequence for setting up the camera is: glmatrixmode(gl_modelview); glloadidentity(); glulookat(px, py, pz, qx, qy, qz, 0.0, 1.0, 0.0); /* Rest of scene goes here. */ If you put everything together, every vertex in OpenGL thus goes through these matrices on its journey from the 3D world to the screen or window: [ viewport matrix ] [ projection matrix ] [ modelview matrix ] (11) 4

Note how we keep these three matrices distinct instead of multiplying them together. One reason is to maintain the ability to manipulate them separately for example, if the window size changes, only the viewport and projection matrices will change, but not the modelview matrix (or at least it shouldn t). Another reason is further rendering algorithms such as hidden surface removal and clipping these steps are best done at the gaps between these matrices. Up next the details on these algorithms, and where they appear on the matrix train. 5