Lecture 5: Transforms II. Computer Graphics and Imaging UC Berkeley CS184/284A

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

Specifying Complex Scenes

3D Transformations. CS 4620 Lecture 10. Cornell CS4620 Fall 2014 Lecture Steve Marschner (with previous instructors James/Bala)

Viewing and Projection

3D Transformations. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 11

Viewing and Projection

Geometric transformations in 3D and coordinate frames. Computer Graphics CSE 167 Lecture 3

Today. Parity. General Polygons? Non-Zero Winding Rule. Winding Numbers. CS559 Lecture 11 Polygons, Transformations

Fachhochschule Regensburg, Germany, February 15, 2017

Viewing and Projection

CS 418: Interactive Computer Graphics. Projection

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CSE328 Fundamentals of Computer Graphics

3.1 Viewing and Projection

Perspective projection and Transformations

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

CSE 167: Introduction to Computer Graphics Lecture #3: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

CSE 167: Introduction to Computer Graphics Lecture #3: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

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

GEOMETRIC TRANSFORMATIONS AND VIEWING

Lecture 4: 3D viewing and projections

CSC 305 The Graphics Pipeline-1

Geometry: Outline. Projections. Orthographic Perspective

2D/3D Geometric Transformations and Scene Graphs

Announcement. Project 1 has been posted online and in dropbox. Due: 11:59:59 pm, Friday, October 14

Overview. By end of the week:

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

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

Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline

Graphics pipeline and transformations. Composition of transformations

Computer Graphics 7: Viewing in 3-D

CMSC427 Transformations II: Viewing. Credit: some slides from Dr. Zwicker

Game Architecture. 2/19/16: Rasterization

Computer Graphics (CS 543) Lecture 6a: Hierarchical 3D Models. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Transforms 1 Christian Miller CS Fall 2011

Camera Model and Calibration

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

Computer Graphics. P05 Viewing in 3D. Part 1. Aleksandra Pizurica Ghent University

MAE : Lecture #12 - Projection and Perspective. Lecture Overview:

Lecture 4: Transforms. Computer Graphics CMU /15-662, Fall 2016

Linear and Affine Transformations Coordinate Systems

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

CSE 167: Introduction to Computer Graphics Lecture #3: Coordinate Systems

Hierarchical Models. Roadmap. Importance of shadows. Importance of shadows. Importance of shadows. Importance of shadows

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

Geometric Transformations

Reminder: Affine Transformations. Viewing and Projection. Shear Transformations. Transformation Matrices in OpenGL. Specification via Ratios

Autonomous Navigation for Flying Robots

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

Viewing. Announcements. A Note About Transformations. Orthographic and Perspective Projection Implementation Vanishing Points

Transforms. COMP 575/770 Spring 2013

Computer Viewing. CITS3003 Graphics & Animation. E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley

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

Rigid Body Motion and Image Formation. Jana Kosecka, CS 482

Transformations. Rotation and Scaling

Lecture 4. Viewing, Projection and Viewport Transformations

Virtual Cameras and The Transformation Pipeline

Computer Graphics: Viewing in 3-D. Course Website:

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

Introduction to Computer Graphics with WebGL

OpenGL Transformations

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

Agenda. Rotations. Camera models. Camera calibration. Homographies

The Graphics Pipeline and OpenGL I: Transformations!

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

1 OpenGL - column vectors (column-major ordering)

Fundamental Types of Viewing

Models and The Viewing Pipeline. Jian Huang CS456

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

Computer Graphics. Ch 6. 3D Viewing

So we have been talking about 3D viewing, the transformations pertaining to 3D viewing. Today we will continue on it. (Refer Slide Time: 1:15)

Viewing with Computers (OpenGL)

3D Viewing. CS 4620 Lecture 8

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

Visual Recognition: Image Formation

3-D D Euclidean Space - Vectors

CS354 Computer Graphics Rotations and Quaternions

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

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

Viewing. Reading: Angel Ch.5

SUMMARY. CS380: Introduction to Computer Graphics Projection Chapter 10. Min H. Kim KAIST School of Computing 18/04/12. Smooth Interpolation

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

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

Agenda. Perspective projection. Rotations. Camera models

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

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

Camera Model and Calibration. Lecture-12

INTRODUCTION TO COMPUTER GRAPHICS. cs123. It looks like a matrix Sort of. Viewing III. Projection in Practice 1 / 52

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

Motivation. What we ve seen so far. Demo (Projection Tutorial) Outline. Projections. Foundations of Computer Graphics

Prof. Feng Liu. Fall /19/2016

Perspective projection. A. Mantegna, Martyrdom of St. Christopher, c. 1450

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

Computer Viewing Computer Graphics I, Fall 2008

To Do. Demo (Projection Tutorial) Motivation. What we ve seen so far. Outline. Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 5: Viewing

Early Fundamentals of Coordinate Changes and Rotation Matrices for 3D Computer Vision

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

Computer Graphics Geometric Transformations

Computer Science 426 Midterm 3/11/04, 1:30PM-2:50PM

Transcription:

Lecture 5: Transforms II Computer Graphics and Imaging UC Berkeley

3D Transforms

3D Transformations Use homogeneous coordinates again: 3D point = (x, y, z, 1) T 3D vector = (x, y, z, 0) T Use 4 4 matrices for affine transformations x y z 1 = a b c t x d e f t y g h i t z 0 0 0 1 x y z 1

3D Transformations Scale s x 0 0 0 S(s x,s y,s z ) = 0 s y 0 0 0 0 s z 0 0 0 0 1 Translation 1 0 0 t x T(t x,t y,t z ) = 0 1 0 t y 0 0 1 t z 0 0 0 1 Coordinate Change (Frame-to-world) F(u, v, w, o) = apple u v w o 0 0 0 1

3D Transformations Rotation around x-, y-, or z-axis y 1 0 0 0 R x ( )= 0 cos sin 0 0 sin cos 0 0 0 0 1 cos 0 sin 0 R y ( )= 0 1 0 0 sin 0 cos 0 0 0 0 1 cos sin 0 0 R z ( )= sin cos 0 0 0 0 1 0 0 0 0 1 z Rotation around x-axis x

3D Rotations Compose any 3D rotation from Rx, Ry, Rz? R xyz (,, ) = R x ( ) R y ( ) R z ( ) So-called Euler angles Often used in flight simulators: roll, pitch, yaw

3D Rotations Compose any 3D rotation from Rx, Ry, Rz? R xyz (,, ) = R x ( ) R y ( ) R z ( ) So-called Euler angles Often used in flight simulators: roll, pitch, yaw

3D Rotation Around Arbitrary Axis Construct orthonormal frame transformation F with p, u, v, w, y v where p and w match the rotation axis w p x Apply the transform (F R z (θ) F -1 ) Interpretations (both valid): z u 2 Move to Z axis, rotate, then move back Cast w-axis rotation in new coordinate frame

Rodrigues Rotation Formula Rotation by angle α around axis n R(n, ) = cos( ) I + (1 cos( )) nn T + sin( ) 0 1 0 n z n y @ n z 0 n A x n y n x {z 0 } N How to prove this magic formula? Matrix N computes a cross-product: N x = n x Assume orthonormal system e1, e2, n Rn = n Re 1 = cos e 1 + sin e 2 Re 2 = sin e 1 + cos e 2

Many Other Representations of Rotations Quaternions Exponential map

Hierarchical Transforms

Skeleton - Linear Representation head torso right upper arm right lower arm right hand left upper arm left lower arm left hand right upper leg right lower leg right foot left upper leg left lower leg left foot

Linear Representation Each shape associated with its own transform A single edit can require updating many transforms E.g. raising arm requires updating transforms for all arm parts

Skeleton - Hierarchical Representation torso head right arm upper arm lower arm hand left arm upper arm lower arm hand right leg upper leg lower leg foot left leg upper leg lower leg foot

Hierarchical Representation Grouped representation (tree) Each group contains subgroups and/or shapes Each group is associated with a transform relative to parent group Transform on leaf-node shape is concatenation of all transforms on path from root node to leaf Changing a group s transform affects all parts Allows high level editing by changing only one node E.g. raising left arm requires changing only one transform for that group

Skeleton - Hierarchical Representation translate(0, 10); drawtorso(); pushmatrix(); // push a copy of transform onto stack translate(0, 5); // right-multiply onto current transform rotate(headrotation); // right-multiply onto current transform drawhead(); popmatrix(); // pop current transform off stack pushmatrix(); translate(-2, 3); rotate(rightshoulderrotation); drawupperarm(); pushmatrix(); translate(0, -3); rotate(elbowrotation); drawlowerarm(); pushmatrix(); right translate(0, -3); lower right rotate(wristrotation); arm drawhand(); hand group popmatrix(); popmatrix(); popmatrix();. right arm group

Skeleton - Hierarchical Representation translate(0, 10); drawtorso(); pushmatrix(); // push a copy of transform onto stack translate(0, 5); // right-multiply onto current transform rotate(headrotation); // right-multiply onto current transform drawhead(); popmatrix(); // pop current transform off stack pushmatrix(); translate(-2, 3); rotate(rightshoulderrotation); drawupperarm(); pushmatrix(); translate(0, -3); rotate(elbowrotation); drawlowerarm(); pushmatrix(); right translate(0, -3); lower right rotate(wristrotation); arm drawhand(); hand group popmatrix(); popmatrix(); popmatrix();. right arm group

Viewing and Perspective

Viewing and Perspective Transforms? Scene modeling 3D world coordinates Rasterization 2D screen coordinates

Camera Space

Standard Camera Space y z We will use this convention for standard camera coordinates: camera located at the origin x looking down negative z-axis vertical vector is y-axis (x-axis) orthogonal to y & z

Standard Camera Coordinates y z y x x Resulting image (z-axis pointing away from scene)

Consider A Camera Pointing in The World

Consider A Camera Pointing in The World u = up vector v = view direction e = eye point (position of camera)

Camera Look-At Transformation u = up vector v = view direction e = eye point (position of camera) Input: e, u & v given in world space coordinates Output: transform matrix from world space to standard camera space

Camera Look-At Transformation Inverse: Matrix from standard camera to world space (Why? This is a coordinate frame transform to (e,r,u,-v)) r x u x v x e x r y u y v y e y r z u z v z e z 0 0 0 1 Look-at transform is the inverse of above matrix: r x u x v x e x r y u y v y e y r z u z v z e z 0 0 0 1 1 r x r y r z 0 1 0 0 e x = u x u y u z 0 v x v y v z 0 0 1 0 e y 0 0 1 e z 0 0 0 1 0 0 0 1

Transform Camera Space to Image Plane? z How to transform from 3D camera space to 2D image plane? One option: orthographic projection (just delete z) Useful, e.g. for engineering drawings But is this the whole story?

Perspective Credit: jefflynchphoto.com

Perspective in Art Berlinghieri 1235

Perspective in Art Giotto 1290

Perspective in Art Giotto 1290

Perspective in Art Brunelleschi experiment c. 1413

Perspective in Art Delivery of the Keys (Sistine Chapel), Perugino, 1482

Perspective in Art The Last Supper, Leonardo da Vinci, 1499

Could An Orthographic Projection Model Leonardo s Last Supper? z

Pinhole Camera Model

Pinhole Camera

Projective Transform x, y (x, y, z) T Scene point Image point C -z d Inverted image (as in real pinhole camera)

Pinhole Camera Projective Transform x, y (x, y, z) T Image point Scene point C -z d Upright image

Projective Transforms Standard perspective projection Center of projection: (0, 0, 0) T Image plane at z = d x, y (x,y,z) T 0 1 x @ ya 7! 0 1 x d/z B C @ y d/za C -z z d z = d

Projective Transforms Standard perspective projection Center of projection: (0, 0, 0) T Image plane at z = d 0 1 x @ ya 7! z 0 1 x d/z B C @ y d/za d Perspective foreshortening Need division by z Matrix representation? Homogeneous coordinates!

Homogenous Coordinates (3D) p = 0 1 wx Bwy C @ wza 0 1 x By C @ za M = 0 1 1 0 0 0 B0 1 0 0 C @ 0 0 1 0A w 1 0 0 1/d 0 q = M 0 1 x By C @ za = 0 B @ x y z 1 C A 0 1 xd/z Byd/z C @ d A Note non-zero term in final row. First time we have seen this. 1 z/d 1

Pinhole Camera Model This mathematical model produces all linear perspective effects! Converging lines + vanishing points Closer objects appear larger in images

Specifying Real Camera Perspectives

Perspective Composition = Camera Position + Angle of View In this sequence, angle of view decreases as distance from subject increases, to size of human subject in image. Notice the dramatic change in background perspective. From Canon EF Lens Work III

Perspective Composition 16 mm (110 ) Up close and zoomed wide with short focal length

Perspective Composition 200 mm (12 ) Walk back and zoom in with long focal length

Specifying Perspective Projection From Angel and Shreiner, Interactive Computer Graphics

Specifying Perspective Viewing Volume From Angel and Shreiner, Interactive Computer Graphics

Specifying Perspective Viewing Volume Parameterized by fovy aspect ratio near far : vertical angular field of view : width / height of field of view : depth of near clipping plane : depth of far clipping plane Derived quantities top bottom right left = near * tan (fovy) = top = top * aspect = right

Perspective Projection Implementation

Perspective Projection Transform (1, 1, 1) (right, top, near) (left, bottom, near) z = far z = near ( 1, 1, 1) Camera Coordinates Normalized Device Coords NDC Later we will flatten NDC to get screen coordinates

Perspective Projection Transform Notes: Need not be symmetric about z- axis, but for simplicity here we assume so This transform will preserve depth information (ordering) in NDC

Perspective Transform Matrix P = 2 2 6 4 near 0 0 0 right 0 near 0 0 top 0 0 far+near far near 2far near far near 0 0 1 0 3 3 7 5 6 7

Perspective Transform Matrix Example P = 2 6 = = = 2 6 4 6 0 4 0 0 0 1 0 3 3 2 near near 6 4near far+near far near near 2 3 6 4 2 6 4 near 2 0 0 0 right 0 near 0 0 top 1 1 far+near far near 1 3 1 1 7 15 7 5 far+near far near 7 2far near far near 2far near far near 7 5 3 7 5 2 6 4 3 23 right top 7 67 near 5 45 1 3 7 5 1

Transforms Recap

Transforms Recap Coordinate Systems Object coordinates Apply modeling transforms World (scene) coordinates Apply viewing transform Camera (eye) coordinates Apply perspective transform + homog. divide Normalized device coordinates Apply 2D screen transform Screen coordinates

Transforms Recap Modeling transforms Object coords World coords

Transforms Recap Viewing transform World coords Camera coords

Transforms Recap (1, 1, 1) Perspective projection and ( 1, 1, 1) homogeneous divide Camera coords NDC

Transforms Recap (w, h) (1, 1, 1) Screen transform ( 1, 1, 1) NDC (0, 0) Screen coords

Transforms Recap (w, h) Rasterization (0, 0) Screen coords

Things to Remember Transform uses Basic transforms: rotate, scale, translate, Modeling, viewing, projection, perspective Change in coordinate system Hierarchical scene descriptions by push/pop Implementing transforms Linear transforms = matrices Transform composition = matrix multiplication Homogeneous coordinates for translation, projection

Acknowledgments Thanks to Pat Hanrahan, Kayvon Fatahalian, Mark Pauly for presentation resources.