Transformations Computer Graphics I Lecture 4

Similar documents
Transformations Computer Graphics I Lecture 4

Transformations. CSCI 420 Computer Graphics Lecture 4

Transformations. CSCI 420 Computer Graphics Lecture 5

Transformations. OpenGL Transformations. 4x4 Model-view Matrix (this lecture) OpenGL Transformation Matrices. 4x4 Projection Matrix (next lecture)

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

Lecture 4: Transformations and Matrices. CSE Computer Graphics (Fall 2010)

CS 4204 Computer Graphics

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

CS452/552; EE465/505. Geometry Transformations

Computer Graphics 7: Viewing in 3-D

Computer Graphics I Lecture 11

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

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

Last week. Machiraju/Zhang/Möller

Computer Graphics. Chapter 7 2D Geometric Transformations

CS D Transformation. Junqiao Zhao 赵君峤

Viewing and Projection

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

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

EECE 478. Learning Objectives. Learning Objectives. Linear Algebra and 3D Geometry. Linear algebra in 3D. Coordinate systems

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

Introduction to Computer Graphics with WebGL

Today s Agenda. Geometry

CSC 470 Computer Graphics

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

Computer Graphics Geometric Transformations

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

Objectives. transformation. General Transformations. Affine Transformations. Notation. Pipeline Implementation. Introduce standard transformations

Order of Transformations

Three Main Themes of Computer Graphics

GEOMETRIC TRANSFORMATIONS AND VIEWING

CS452/552; EE465/505. Transformations

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

Computer Graphics. Coordinate Systems and Change of Frames. Based on slides by Dianna Xu, Bryn Mawr College

Viewing and Projection

Vector Algebra Transformations. Lecture 4

Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

BASIC ELEMENTS. Geometry is the study of the relationships among objects in an n-dimensional space

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

Objectives. Geometry. Coordinate-Free Geometry. Basic Elements. Transformations to Change Coordinate Systems. Scalars

Computer Graphics: Geometric Transformations

3D Computer Vision II. Reminder Projective Geometry, Transformations. Nassir Navab. October 27, 2009

Curves and Surfaces Computer Graphics I Lecture 9

Viewing and Projection

CT5510: Computer Graphics. Transformation BOCHANG MOON

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

Transformations: 2D Transforms

Today s class. Viewing transformation Menus Mandelbrot set and pixel drawing. Informationsteknologi

Computer Science 336 Fall 2017 Homework 2

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

Last week. Machiraju/Zhang/Möller/Fuhrmann

Reading. Hierarchical Modeling. Symbols and instances. Required: Angel, sections , 9.8. Optional:

Affine Transformation. Edith Law & Mike Terry

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

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

CS Computer Graphics: Transformations & The Synthetic Camera

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

2D TRANSFORMATIONS AND MATRICES

Transformations. Standard Transformations. David Carr Virtual Environments, Fundamentals Spring 2005 Based on Slides by E. Angel

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation

3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. x y z. x y z. glvertex3f(x, y,z);

Transformation. Jane Li Assistant Professor Mechanical Engineering & Robotics Engineering

Basic Graphics Programming

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

Lecture 6 Sections 4.3, 4.6, 4.7. Wed, Sep 9, 2009

CS380: Computer Graphics 2D Imaging and Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

UNIT 2 2D TRANSFORMATIONS

2D Object Definition (1/3)

Introduction to Computer Graphics with WebGL

Computer graphics MN1

Transformation Algebra

Computer Graphics Hands-on

Lecture 9: Transformations. CITS3003 Graphics & Animation

3D Computer Vision II. Reminder Projective Geometry, Transformations

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

Orientation & Quaternions

Lecture 3: Convex sets

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

CS354 Computer Graphics Rotations and Quaternions

Visual Recognition: Image Formation

Transformations II. Week 2, Wed Jan 17

1 Affine and Projective Coordinate Notation

Linear transformations Affine transformations Transformations in 3D. Graphics 2009/2010, period 1. Lecture 5: linear and affine transformations

2D and 3D Coordinate Systems and Transformations

Translation. 3D Transformations. Rotation about z axis. Scaling. CS 4620 Lecture 8. 3 Cornell CS4620 Fall 2009!Lecture 8

GL_MODELVIEW transformation

Column and row space of a matrix

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

Transforms. COMP 575/770 Spring 2013

Introduction to Homogeneous coordinates

Geometric Queries for Ray Tracing

Geometric Transformations

DRAFT: Mathematical Background for Three-Dimensional Computer Graphics. Jonathan R. Senning Gordon College

6.837 LECTURE 7. Lecture 7 Outline Fall '01. Lecture Fall '01

Affine Transformations Computer Graphics Scott D. Anderson

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

2D and 3D Transformations AUI Course Denbigh Starkey

Modeling Objects by Polygonal Approximations. Linear and Affine Transformations (Maps)

Image Warping. Some slides from Steve Seitz

Transcription:

15-462 Computer Graphics I Lecture 4 Transformations Vector Spaces Affine and Euclidean Spaces Frames Homogeneous Coordinates Transformation Matrices January 24, 2002 [Angel, Ch. 4] Frank Pfenning Carnegie Mellon University http://www.cs.cmu.edu/~fp/courses/graphics/

Announcement Guest lecture Tuesday, January 29 From Design to Production: How a Graphics Chip is Built, Scott Whitman, nvidia 01/24/2002 15-462 Graphics I 2

Compiling Under Windows (Answer) Must install GLUT Good source: http://www.opengl.org/ Includes should be #include <GL/glut.h> #include <stdlib.h> Do not include <GL/gl.h> or <GL/glu.h> Run on lab machines before handing in! 01/24/2002 15-462 Graphics I 3

Geometric Objects and Operations Primitive types: scalars, vectors, points Primitive operations: dot product, cross product Representations: coordinate systems, frames Implementations: matrices, homogeneous coor. Transformations: rotation, scaling, translation Composition of transformations OpenGL transformation matrices 01/24/2002 15-462 Graphics I 4

Scalars Scalars α, β, γ from a scalar field Operations α+β, α β, 0, 1, -α, ( ) -1 Expected laws apply Examples: rationals or reals with addition and multiplication 01/24/2002 15-462 Graphics I 5

Vectors Vectors u, v, w from vector space Includes scalar field Vector addition u + v Zero vector 0 Scalar multiplication α v 01/24/2002 15-462 Graphics I 6

Points Points P, Q, R from affine space Includes vector space Point-point subtraction v = P Q Define also P = v + Q 01/24/2002 15-462 Graphics I 7

Euclidean Space Assume vector space over real number Dot product: α = u v 0 0 = 0 u, v are orthogonal if u v = 0 v 2 = v v defines v, the length of v Generally work in an affine Euclidean space 01/24/2002 15-462 Graphics I 8

Geometric Interpretations Lines and line segments Convexity Dot product and projections Cross product and normal vectors Planes 01/24/2002 15-462 Graphics I 9

Lines and Line Segments Parametric form of line: P(α) = P 0 + α d Line segment between Q and R: P(α) = (1-α) Q + α R for 0 α 1 01/24/2002 15-462 Graphics I 10

Convex Hull Convex hull defined by P = α 1 P 1 + L + α n P n for a 1 + L + a n = 1 and 0 a i 1, i = 1,..., n 01/24/2002 15-462 Graphics I 11

Projection Dot product projects one vector onto other u v = u v cos(θ) [diagram correction: x = u] 01/24/2002 15-462 Graphics I 12

Normal Vector Cross product defines normal vector u v = n u v = u v sin(θ) Right-hand rule 01/24/2002 15-462 Graphics I 13

Plane Plane defined by point P 0 and vectors u and v u and v cannot be parallel Parametric form: T(α, β) = P 0 + α u + β v Let n = u v be the normal Then n (P P 0 ) = 0 iff P lies in plane 01/24/2002 15-462 Graphics I 14

Outline Vector Spaces Affine and Euclidean Spaces Frames Homogeneous Coordinates Transformation Matrices OpenGL Transformation Matrices 01/24/2002 15-462 Graphics I 15

Coordinate Systems Let v 1, v 2, v 3 be three linearly independent vectors in a 3-dimensional vector space Can write any vector w as w = α 1 v 1 + α 2 v 2 + α 3 v 3 for scalars α 1, α 2, α 3 In matrix notation: 01/24/2002 15-462 Graphics I 16

Frames Frame = coordinate system + origin P 0 Any point P = P 0 + α 1 v 1 + α 2 v 2 + α 3 v 3 Useful in with homogenous coordinates 01/24/2002 15-462 Graphics I 17

Changes of Coordinate System Bases {u 1, u 2, u 3 } and {v 1, v 2, v 3 } Express basis vectors u i in terms of v j Represent in matrix form 01/24/2002 15-462 Graphics I 18

Map to Representations w = α 1 v 1 + α 2 v 2 + α 3 v 3, a T = [α 1 α 2 α 3 ] w = β 1 u 1 + β 2 u 2 + β 3 u 3, b T = [β 1 β 2 β 3 ] So a = M T b and b = (M T ) -1 a Suffices for rotation and scaling, not translation 01/24/2002 15-462 Graphics I 19

Outline Vector Spaces Affine and Euclidean Spaces Frames Homogeneous Coordinates Transformation Matrices OpenGL Transformation Matrices 01/24/2002 15-462 Graphics I 20

Linear Transformations 3 3 matrices represent linear transformations a = M b Can represent rotation, scaling, and reflection Cannot represent translation a and b represent vectors, not points 01/24/2002 15-462 Graphics I 21

Homogeneous Coordinates In affine space, P = α 1 v 1 + α 2 v 2 + α 3 v 3 + P 0 Define 0 P = 0, 1 P = P Then Point p = [α 1 α 2 α 3 1] T Vector w = δ 1 v 1 + δ 2 v 2 + δ 3 v 3 Homogeneous coords: a = [δ 1 δ 2 δ 3 0] T 01/24/2002 15-462 Graphics I 22

Translation of Frame Express frame (u 1, u 2, u 3, P 0 ) in (v 1, v 2, v 3, Q 0 ) Then 01/24/2002 15-462 Graphics I 23

Homogeneous Coordinates Summary Points [α 1 α 2 α 3 1] T Vectors [δ 1 δ 2 δ 3 0] T Change of frame 01/24/2002 15-462 Graphics I 24

Outline Vector Spaces Affine and Euclidean Spaces Frames Homogeneous Coordinates Transformation Matrices OpenGL Transformation Matrices 01/24/2002 15-462 Graphics I 25

Affine Transformations Translation Rotation Scaling Any composition of the above Express in homogeneous coordinates Need 4 4 matrices Later: projective transformations Also expressible as 4 4 matrices! 01/24/2002 15-462 Graphics I 26

Translation p = p + d where d = [α x α y α z 0] T p = [x y z 1] T p = [x y z 1] T Express in matrix form p = T p and solve for T 01/24/2002 15-462 Graphics I 27

Scaling x = β x x y = β y y z = β z z Express as p = S p and solve for S 01/24/2002 15-462 Graphics I 28

Rotation in 2 Dimensions Rotation by θ about the origin x = x cos θ y sin θ y = x sin θ + y cos θ Express in matrix form Note determinant is 1 01/24/2002 15-462 Graphics I 29

Rotation in 3 Dimensions Decompose into rotations about x, y, z axes 01/24/2002 15-462 Graphics I 30

Compose by Matrix Multiplication R = R z R y R x Applied from right to left R p = (R z R y R x ) p = R z (R y (R x p)) Postmultiplication in OpenGL 01/24/2002 15-462 Graphics I 31

Rotation About a Fixed Point First, translate to the origin Second, rotate about the origin Third, translate back To rotate by θ in about z around p f M = T(p f ) R z (θ) T(-p f ) =... 01/24/2002 15-462 Graphics I 32

Deriving Transformation Matrices Other examples: see [Angel, Ch. 4.8] See also Assignment 2 when it is out Hint: manipulate matrices, but remember geometric intuition 01/24/2002 15-462 Graphics I 33

Outline Vector Spaces Affine and Euclidean Spaces Frames Homogeneous Coordinates Transformation Matrices OpenGL Transformation Matrices 01/24/2002 15-462 Graphics I 34

Current Transformation Matrix Model-view matrix (usually affine) Projection matrix (usually not affine) Manipulated separately glmatrixmode (GL_MODELVIEW); glmatrixmode (GL_PROJECTION); 01/24/2002 15-462 Graphics I 35

Manipulating the Current Matrix Load or postmultiply glloadidentity(); glloadmatrixf(*m); glmultmatrixf(*m); Library functions to compute matrices gltranslatef(dx, dy, dz); glrotatef(angle, vx, vy, vz); glscalef(sx, sy, sz); Recall: last transformation is applied first! 01/24/2002 15-462 Graphics I 36

Summary Vector Spaces Affine and Euclidean Spaces Frames Homogeneous Coordinates Transformation Matrices OpenGL Transformation Matrices 01/24/2002 15-462 Graphics I 37

OpenGL Tutors by Nate Robins Run under Windows Available at http://www.xmission.com/~nate/tutors.html Example: Transformation tutor 01/24/2002 15-462 Graphics I 38