CS Computer Graphics: Transformations & The Synthetic Camera

Similar documents
IMGD The Game Development Process: 3D Modeling and Transformations

CS 543: Computer Graphics. Projection

6. Modelview Transformations

1. We ll look at: Types of geometrical transformation. Vector and matrix representations

CPSC 314, Midterm Exam 1. 9 Feb 2007

Computer Graphics. Chapter 7 2D Geometric Transformations

CS 543: Computer Graphics. 3D Transformations

Viewing/Projection IV. Week 4, Fri Jan 29

(x, y) (ρ, θ) ρ θ. Polar Coordinates. Cartesian Coordinates

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Viewing and Projection

GLOBAL EDITION. Interactive Computer Graphics. A Top-Down Approach with WebGL SEVENTH EDITION. Edward Angel Dave Shreiner

What does OpenGL do?

Two Dimensional Viewing

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

4. Two Dimensional Transformations

CS 4731/543: Computer Graphics Lecture 5 (Part I): Projection. Emmanuel Agu

3D graphics rendering pipeline (1) 3D graphics rendering pipeline (3) 3D graphics rendering pipeline (2) 8/29/11

Computer Graphics Geometric Transformations

Viewing/Projections III. Week 4, Wed Jan 31

Realtime 3D Computer Graphics & Virtual Reality. Viewing

Computer Graphics 7: Viewing in 3-D

3D Coordinates & Transformations

Notes. University of British Columbia

Transformations II. Arbitrary 3D Rotation. What is its inverse? What is its transpose? Can we constructively elucidate this relationship?

Computer Graphics. Geometric Transformations

Illumination & Shading I

Computer Graphics. Geometric Transformations

CS 4204 Computer Graphics

1/29/13. Computer Graphics. Transformations. Simple Transformations

3-Dimensional Viewing

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

CPSC 314, Midterm Exam. 8 March 2010

Transformations II. Week 2, Wed Jan 17

Modeling Transformations Revisited

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

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

Today s class. Geometric objects and transformations. Informationsteknologi. Wednesday, November 7, 2007 Computer Graphics - Class 5 1

CSC 470 Computer Graphics

CS 428: Fall Introduction to. Viewing and projective transformations. Andrew Nealen, Rutgers, /23/2009 1

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

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

What and Why Transformations?

Lecture 4: Viewing. Topics:

CS 4204 Computer Graphics

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

High Dimensional Rendering in OpenGL

CS559: Computer Graphics

GEOMETRIC TRANSFORMATIONS AND VIEWING

Scene Graphs & Modeling Transformations COS 426

CS770/870 Spring 2017 Transformations

Overview. By end of the week:

CPSC 314, Midterm Exam. 8 March 2013

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

Image Warping : Computational Photography Alexei Efros, CMU, Fall Some slides from Steve Seitz

Image Warping. Some slides from Steve Seitz

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Interactive Computer Graphics. Warping and morphing. Warping and Morphing. Warping and Morphing. Lecture 14+15: Warping and Morphing. What is.

p =(x,y,d) y (0,0) d z Projection plane, z=d

Transformations. CSCI 420 Computer Graphics Lecture 4

5.8.3 Oblique Projections

Editing and Transformation

Viewing. Cliff Lindsay, Ph.D. WPI

CS4202: Test. 1. Write the letter corresponding to the library name next to the statement or statements that describe library.

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

3D Geometry and Camera Calibration

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

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

Name: [20 points] Consider the following OpenGL commands:

Transformations Computer Graphics I Lecture 4

Chap 7, 2009 Spring Yeong Gil Shin

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

Homogeneous Coordinates

CSE328 Fundamentals of Computer Graphics: Theory, Algorithms, and Applications

Modeling Transformations

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

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

Computer Graphics. P04 Transformations. Aleksandra Pizurica Ghent University

Last Time. Correct Transparent Shadow. Does Ray Tracing Simulate Physics? Does Ray Tracing Simulate Physics? Refraction and the Lifeguard Problem

CS F-07 Objects in 2D 1

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

Geometric Transformations

CS452/552; EE465/505. Transformations

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

Computer Graphics CS 543 Lecture 5 (Part 2) Implementing Transformations

To Do. Motivation. Demo (Projection Tutorial) What we ve seen so far. Computer Graphics. Summary: The Whole Viewing Pipeline

The 3-D Graphics Rendering Pipeline

CS Computer Graphics: Introduction to Ray Tracing

CS Computer Graphics: Introduction to Ray Tracing

Transformations. Examples of transformations: shear. scaling

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

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

Transformations III. Week 2, Fri Jan 19

2D Image Transforms Computer Vision (Kris Kitani) Carnegie Mellon University

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

Computer Graphics. Transformation

Evening s Goals. Mathematical Transformations. Discuss the mathematical transformations that are utilized for computer graphics

Institutionen för systemteknik

Viewing and Modeling

Transcription:

CS 543 - Computer Graphics: Transformations The Snthetic Camera b Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-)

Introduction to Transformations A transformation changes an objects Size (scaling) Position (translation) Orientation (rotation) Shape (shear) We will introduce first in 2D or (,), build intuition Later, talk about 3D and 4D? Transform object b appling sequence of matri multiplications to object vertices R.W. Lindeman - WPI Dept. of Computer Science 2

Wh Matrices? All transformations can be performed using matri/vector multiplication Allows pre-multiplication of all matrices Note: point (, ) needs to be represented as (,, ), also called homogeneous coordinates R.W. Lindeman - WPI Dept. of Computer Science 3

Point Representation We use a column matri (2 matri) to represent a 2D point General form of transformation of a point (, ) to (, ) can be written as: = a + b + c = d + e + f or a b c = d e f * R.W. Lindeman - WPI Dept. of Computer Science 4

Translation To reposition a point along a straight line Given point (, ) and translation distance (t, t ) The new point: (, ) (, ) = + t = + t (,) or = P T where = P + P P = T = t t R.W. Lindeman - WPI Dept. of Computer Science 5

R.W. Lindeman - WPI Dept. of Computer Science 6 33 2D Translation Matri t t = + use 3 vector t t = * Note: it becomes a matri-vector multiplication = + t = + t

Translation of Objects How to translate an object with multiple vertices? Translate individual vertices R.W. Lindeman - WPI Dept. of Computer Science 7

2D Scaling Scale: Alter object size b scaling factor (s, s). i.e., = * S = * S = S S (4,4) (2,2) S = 2, S = 2 (,) (2,2) R.W. Lindeman - WPI Dept. of Computer Science 8

R.W. Lindeman - WPI Dept. of Computer Science 9 33 2D Scaling Matri = S S = S S = * S = * S

Shearing Y coordinates are unaffected, but coordinates are translated linearl with That is = + *h = h is fraction of to be added to h = ( R.W. Lindeman - WPI Dept. of Computer Science

2D Rotation Default rotation center is origin (,) θ θ> : Rotate counter clockwise θ θ< : Rotate clockwise R.W. Lindeman - WPI Dept. of Computer Science

2D Rotation (cont.) (,) -> Rotate about the origin b θ (, ) (, ) θ r φ (,) How to compute (, )? = r*cos(φ) = r*sin(φ) = r*cos(φ +θ) = r*sin(φ +θ) R.W. Lindeman - WPI Dept. of Computer Science 2

2D Rotation (cont.) Using trig. identities cos( + ) = cos cos sin sin (, ) sin( + ) = sin cos + cos sin = cos(θ) sin(θ) = sin(θ) + cos(θ) θ r φ (,) Matri form? = cos( ( ) sin( ( ) sin( ( ) cos( ( ) R.W. Lindeman - WPI Dept. of Computer Science 3

R.W. Lindeman - WPI Dept. of Computer Science 4 33 2D Rotation Matri (,) (, ) θ φ r = ) cos( ) sin( ) sin( ) cos( ( ( ( ( = ) cos( ) sin( ) sin( ) cos( ( ( ( (

2D Rotation How to rotate an object with multiple vertices? Rotate individual Vertices θ R.W. Lindeman - WPI Dept. of Computer Science 5

R.W. Lindeman - WPI Dept. of Computer Science 6 Arbitrar Rotation Center To rotate about arbitrar point P = (P, P) b θ: Translate object b T(-P, -P) so that P coincides with origin Rotate the object b R(θ) Translate object back: T(P, P) In matri form T(P,P) R(θ) T(-P,-P) * P Similar for arbitrar scaling anchor = ) cos( ) sin( ) sin( ) cos( P P P P ( ( ( (

Composing Transformations Composing transformations Appling several transforms in succession to form one overall transformation Eample M X M2 X M3 X P where M, M2, M3 are transform matrices applied to P Be careful with the order For eample Translate b (5, ), then rotate 6 degrees is NOT same as Rotate b 6 degrees, then translate b (5, ) R.W. Lindeman - WPI Dept. of Computer Science 7

OpenGL Transformations Designed for 3D For 2D, simpl ignore z dimension Translation: gltranslated( t, t, tz ) gltranslated( t, t, ) => for 2D Rotation: glrotated( angle, V, V, Vz ) glrotated( angle,,, ) => for 2D Scaling: glscaled( s, s, sz ) glscaled( s, s, ) => for 2D R.W. Lindeman - WPI Dept. of Computer Science 8

3D Transformations Affine transformations Mappings of points to new points that retain certain relationships Lines remain lines Several transformations can be combined into a single matri Two was to think about transformations Object transformations All points of an object are transformed Coordinate transformations The coordinate sstem is transformed, and models remain defined relative to this R.W. Lindeman - WPI Dept. of Computer Science 9

3D Transformations (cont.) Scale glscaled( s, s, sz ): Scale object b (s, s, sz) Translate gltranslated( d, d, dz ): Translate object b (d, d, dz) Rotate glrotated( angle, u, u, uz ): Rotate b angle about an ais passing through origin and (u, u, uz) OpenGL Creates a matri for each transformation Multiplies matrices together to form a single, combined matri Transformation matri is called modelview matri R.W. Lindeman - WPI Dept. of Computer Science 2

Eample: Translation The vertices of an object are mapped to new points Similarl for scaling and rotation R.W. Lindeman - WPI Dept. of Computer Science 2

OpenGL Matrices Graphics pipeline takes all vertices through a series of operations R.W. Lindeman - WPI Dept. of Computer Science 22

OpenGL Matrices and the Pipeline OpenGL uses three matrices for geometr Modelview matri Projection matri Viewport matri Modelview matri Combination of modeling matri M and camera transforms V Other OpenGL matrices include teture and color matrices glmatrimode command selects matri mode glmatrimode parameters GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE, etc. Ma initialize matrices with glloadidentit( ) R.W. Lindeman - WPI Dept. of Computer Science 23

OpenGL Matrices and the Pipeline OpenGL matri operations are 44 matrices Graphics card Fast 44 multiplier -> tremendous speedup R.W. Lindeman - WPI Dept. of Computer Science 24

View Frustum Side walls determined b window borders Other walls are programmer defined Near clipping plane Far clipping plane Transform 3D models to 2D Project points/vertices inside view volume onto view window using parallel lines along z-ais R.W. Lindeman - WPI Dept. of Computer Science 25

Tpes of Projections Different tpes of projections? Different view volume shapes Different visual effects Eample projections Parallel (a.k.a. orthographic) Perspective Parallel is simple Will use this for intro, epand later R.W. Lindeman - WPI Dept. of Computer Science 26

OpenGL Matrices and the Pipeline Projection matri Scales and shifts each verte in a particular wa View volume lies inside cube of to Reverses sense of z increasing z = increasing depth Effectivel squishes view volume down to cube centered at Clipping in 3D then eliminates portions outside view frustum Viewport matri: Maps surviving portion of block (cube) into a 3D viewport Retains a measure of the depth of a point R.W. Lindeman - WPI Dept. of Computer Science 27

Lighting and Shading Light components: Diffuse, ambient, specular OpenGL gllightfv( ), gllightf( ) Materials OpenGL glmaterialfv( ), glmaterialf( ) R.W. Lindeman - WPI Dept. of Computer Science 28

A Snthetic Camera Define: Ee position LookAt point Up vector (if spinning: confusing) Programmer knows scene, chooses: ee lookat Up direction usuall set to (,, ) OpenGL: glulookat( ee.pos[x], ee.pos[y], ee.pos[z], look.pos[x], look.pos[y], look.pos[z], up.vec[x], up.vec[y], up.vec[z] ); R.W. Lindeman - WPI Dept. of Computer Science 29

A Snthetic Camera (cont.) R.W. Lindeman - WPI Dept. of Computer Science 3