Modeling Transformations

Similar documents
Modeling Transformations

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

Modeling Transformations

Indirect Illumination

Modeling Transformations

Modeling Transformations

Modeling Transformations Revisited

Scene Graphs & Modeling Transformations COS 426

Indirect Illumination

Image Warping. Some slides from Steve Seitz

3D Rendering and Ray Casting

3D Rendering and Ray Casting

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

Image Warping. Some slides from Steve Seitz

Computer Graphics. P04 Transformations. Aleksandra Pizurica Ghent University

Ray-Tracing. Misha Kazhdan

Image Warping CSE399b, Spring 07 Computer Vision

What and Why Transformations?

Computer Graphics. Geometric Transformations

Computer Graphics. Geometric Transformations

Image Warping (Szeliski Sec 2.1.2)

Illumination. Michael Kazhdan ( /657) HB Ch. 14.1, 14.2 FvDFH 16.1, 16.2

Image warping. image filtering: change range of image. image warping: change domain of image g(x) = f(h(x)) h(y)=0.5y+0.5. h([x,y])=[x,y/2] f h

Modeling Transformations

The 3-D Graphics Rendering Pipeline

Image Warping. Many slides from Alyosha Efros + Steve Seitz. Photo by Sean Carroll

CS4670: Computer Vision

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

Transformations II. Week 2, Wed Jan 17

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

Two Dimensional Viewing

Uses of Transformations. 2D transformations Homogeneous coordinates. Transformations. Transformations. Transformations. Transformations and matrices

Affine and Projective Transformations

How is project #1 going?

3-Dimensional Viewing

Image Warping. Computational Photography Derek Hoiem, University of Illinois 09/28/17. Photo by Sean Carroll

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

Image Warping, mesh, and triangulation CSE399b, Spring 07 Computer Vision

MAN-522: COMPUTER VISION SET-2 Projections and Camera Calibration

CS 2770: Intro to Computer Vision. Multiple Views. Prof. Adriana Kovashka University of Pittsburgh March 14, 2017

Warping, Morphing and Mosaics

Announcements. Equation of Perspective Projection. Image Formation and Cameras

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

Determining the 2d transformation that brings one image into alignment (registers it) with another. And

Last Lecture. Edge Detection. Filtering Pyramid

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

CS 335 Graphics and Multimedia. Geometric Warping

3D Geometry and Camera Calibration

CS559: Computer Graphics

Geometric Transformations

Computer Graphics. 2D transformations. Transforma3ons in computer graphics. Overview. Basic classes of geometric transforma3ons

Homogeneous Coordinates

4. Two Dimensional Transformations

Global Illumination. Connelly Barnes CS 4810: Graphics

More on Transformations. COS 426, Spring 2019 Princeton University

Image warping/morphing

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

Prof. Feng Liu. Winter /05/2019

[ ] [ ] Orthogonal Transformation of Cartesian Coordinates in 2D & 3D. φ = cos 1 1/ φ = tan 1 [ 2 /1]

CS770/870 Spring 2017 Transformations

Parallelization. Memory coherency helps when distributing rays to various threads/processors

3D Coordinates & Transformations

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

Transformations III. Week 2, Fri Jan 19

Geometric Model of Camera

Chap 7, 2009 Spring Yeong Gil Shin

Ray Tracing. Local Illumination. Object Space: Global Illumination. Image Space: Backward Ray Tracing. First idea: Forward Ray Tracing

Acceleration Data Structures

Announcements. The equation of projection. Image Formation and Cameras

CSCI-4530/6530 Advanced Computer Graphics

CS F-07 Objects in 2D 1

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Transformations. Examples of transformations: shear. scaling

CPSC GLOBAL ILLUMINATION

General Purpose Computation (CAD/CAM/CAE) on the GPU (a.k.a. Topics in Manufacturing)

What does OpenGL do?

CS Computer Graphics: Transformations & The Synthetic Camera

Image Metamorphosis By Affine Transformations

Editing and Transformation

CSCI-4530/6530 Advanced Computer Graphics

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

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

2D transformations and homogeneous coordinates

Ray Tracing. Outline. Ray Tracing: History

Perspective Projection Transformation

Ray Casting. Outline in Code. Outline. Finding Ray Direction. Heckbert s Business Card Ray Tracer. Foundations of Computer Graphics (Fall 2012)

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

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

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

Solid Modeling. Thomas Funkhouser Princeton University C0S 426, Fall Represent solid interiors of objects

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

Computer Graphics. Ray Tracing. Copyright Gotsman, Elber, Barequet, Karni, Sheffer. Page 1. Ray-Tracing. Illumination Models

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

CS5620 Intro to Computer Graphics

Spatial Data Structures

Chapter 3 : Computer Animation

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

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

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

Lecture 4: Viewing. Topics:

Transcription:

Modeling Transformations Michael Kazhdan (601.457/657) HB Ch. 5 FvDFH Ch. 5

Announcement Assignment 2 has been posted: Due: 10/24 ASAP: Download the code and make sure it compiles» On windows: just build the Assignment2 project» On Linu: make f Makefile2 (Feel free to tr building the other projects. Let me know if ou have trouble.)

Overview Ra-Tracing so far Modeling transformations

Ra Tracing Image RaTrace( Camera camera, Scene scene, int width, int height, int depth, float cutoff ) { Image image = new Image( width, height ); for( int i=0 ; i<width ; i++ ) for( int j=0 ; j<height ; j++ ) { Ra ra = ConstructRaThroughPiel( camera, i, j ); image[i][j] = GetColor( scene, ra, 1, depth, Color( cutoff, cutoff, cutoff ) ); } return image; }

Ra Tracing For each sample Construct ra from ee position through view plane Compute color contribution of the ra Ras through view plane Ee position Samples on view plane

Ra Tracing Image RaTrace( Camera camera, Scene scene, int width, int height, int depth, float cutoff ) { Image image = new Image( width, height ); for( int i=0 ; i<width ; i++ ) for( int j=0 ; j<height ; j++ ) { Ra ra = ConstructRaThroughPiel( camera, i, j ); image[i][j] = GetColor( scene, ra, 1, depth, Color( cutoff, cutoff, cutoff ) ); } return image; }

Constructing Ra Through a Piel 2D Eample: The ra passing through the i-th piel is defined b: Ra t = p 0 + t Ԧv p 0 : camera position Ԧv: direction to the i-th piel: Ԧv = p i p 0 p i p 0 p 0 θ p[i]: i-th piel location: Ԧv i + 0.5 p i = p 1 + 2 d tan θ up height p 1 and p 2 are the endpoints of the view plane: p 1 = p 0 + d towards d tan θ up p 2 = p 0 + d towards + d tan θ up up towards d p[i] p 2 p 1 2 d tan(θ)

Ra Tracing Image RaTrace( Camera camera, Scene scene, int width, int height, int depth, float cutoff ) { Image image = new Image( width, height ); for( int i=0 ; i<width ; i++ ) for( int j=0 ; j<height ; j++ ) { Ra ra = ConstructRaThroughPiel( camera, i, j ); image[i][j] = GetColor( scene, ra, 1, depth, Color( cutoff, cutoff, cutoff ) ); Color GetColor( } Scene scene, Ra ra, float ir, int d, Color co ) { return image; HitInformation } hit; Color c(0,0,0); if( d 0 (co[0]>1 && co[1]>1 && co[2]>1) ) return c; } if( Intersect( scene, ra, hit ) 0 ) { c = GetEmissive( hit ); for( i=0 ; i<lightnum ; i++) c += light[i].getambientdiffuseandspecular( ra, hit ); Ra reflectedra = ReflectedRa( ra, hit.p, hit.n ); c += GetColor( scene, reflectedra, ir, d-1, co/hit.spec ) * hit.spec; Ra refractedra = RefractedRa( ra, hit.p, hit.n, hit.ir ); c += GetColor( scene, refractedra, hit.ir, d-1, co/hit.tran ) * hit.tran; } return c;

Ra Tracing Image RaTrace( Camera camera, Scene scene, int width, int height, int depth, float cutoff ) { Image image = new Image( width, height ); for( int i=0 ; i<width ; i++ ) for( int j=0 ; j<height ; j++ ) { Ra ra = ConstructRaThroughPiel( camera, i, j ); image[i][j] = GetColor( scene, ra, 1, depth, Color( cutoff, cutoff, cutoff ) ); Color GetColor( } Scene scene, Ra ra, float ir, int d, Color co ) { return image; HitInformation } hit; Color c(0,0,0); if( d 0 (co[0]>1 && co[1]>1 && co[2]>1) ) return c; } if( Intersect( scene, ra, hit ) 0 ) { c = GetEmissive( hit ); for( i=0 ; i<lightnum ; i++) c += light[i].getambientdiffuseandspecular( ra, hit ); Ra reflectedra = ReflectedRa( ra, hit.p, hit.n ); c += GetColor( scene, reflectedra, ir, d-1, co/hit.spec ) * hit.spec; Ra refractedra = RefractedRa( ra, hit.p, hit.n, hit.ir ); c += GetColor( scene, refractedra, hit.ir, d-1, co/hit.tran ) * hit.tran; } return c;

Ra-Scene Intersection Intersections with geometric primitives Sphere Triangle Groups of primitives (scene) Acceleration techniques Bounding volume hierarchies Spatial partitions» Uniform grids» Octrees» BSP trees

Ra Tracing Image RaTrace( Camera camera, Scene scene, int width, int height, int depth, float cutoff ) { Image image = new Image( width, height ); for( int i=0 ; i<width ; i++ ) for( int j=0 ; j<height ; j++ ) { Ra ra = ConstructRaThroughPiel( camera, i, j ); image[i][j] = GetColor( scene, ra, 1, depth, Color( cutoff, cutoff, cutoff ) ); Color GetColor( } Scene scene, Ra ra, float ir, int d, Color co ) { return image; HitInformation } hit; Color c(0,0,0); if( d 0 (co[0]>1 && co[1]>1 && co[2]>1) ) return c; } if( Intersect( scene, ra, hit ) 0 ) { c = GetEmissive( hit ); for( i=0 ; i<lightnum ; i++) c += light[i].getambientdiffuseandspecular( ra, hit ); Ra reflectedra = ReflectedRa( ra, hit.p, hit.n ); c += GetColor( scene, reflectedra, ir, d-1, co/hit.spec ) * hit.spec; Ra refractedra = RefractedRa( ra, hit.p, hit.n, hit.ir ); c += GetColor( scene, refractedra, hit.ir, d-1, co/hit.tran ) * hit.tran; } return c;

Surface Illumination Calculation Viewer L 1 L 2 N V I = I E + L K A I L A + K D N, L + K S V, R n I L S L

Ra Tracing (Recursive) Image RaTrace( Camera camera, Scene scene, int width, int height, int depth, float cutoff ) { Image image = new Image( width, height ); for( int i=0 ; i<width ; i++ ) for( int j=0 ; j<height ; j++ ) { Ra ra = ConstructRaThroughPiel( camera, i, j ); image[i][j] = GetColor( scene, ra, 1, depth, Color( cutoff, cutoff, cutoff ) ); Color GetColor( } Scene scene, Ra ra, float ir, int d, Color co ) { return image; HitInformation } hit; Color c(0,0,0); if( d 0 (co[0]>1 && co[1]>1 && co[2]>1) ) return c; } if( Intersect( scene, ra, hit ) 0 ) { c = GetEmissive( hit ); for( i=0 ; i<lightnum ; i++) c += light[i].getambientdiffuseandspecular( ra, hit ); Ra reflectedra = ReflectedRa( ra, hit.p, hit.n ); c += GetColor( scene, reflectedra, ir, d-1, co/hit.spec ) * hit.spec; Ra refractedra = RefractedRa( ra, hit.p, hit.n, hit.ir ); c += GetColor( scene, refractedra, hit.ir, d-1, co/hit.tran ) * hit.tran; } return c;

Ra Tracing (Recursive) Consider the contribution of: Reflected Ras Refracted Ras L 1 L 0 I = I E + L K A I L A + K D N, L + K S V, R n I L S L + K s I R + K T I T

Overview Ratracing so far Modeling transformations

Modeling Transformations Specif transformations for objects Allows definitions of objects in own coordinate sstems Allows use of object definition multiple times in a scene H&B Figure 109

Overview 2D Transformations Basic 2D transformations Matri representation Matri composition 3D Transformations Basic 3D transformations Same as 2D

Simple 2D Transformations Translation p = p + t p p = p p + t t

Simple 2D Transformations Scale p = S p p p = s 0 0 s p p

Simple 2D Transformation Rotation p = R p p p = cos θ sin θ sin θ cos θ p p

2D Modeling Transformations Object Coordinates Scale Translate Scale Rotate Translate World Coordinates

2D Modeling Transformations Object Coordinates Let s look at this in detail World Coordinates

2D Modeling Transformations Object Coordinates

2D Modeling Transformations Object Coordinates Scale.3,.3 Rotate -90 Translate 5, 3

2D Modeling Transformations Object Coordinates Scale.3,.3 Rotate -90 Translate 5, 3

2D Modeling Transformations Object Coordinates Scale.3,.3 Rotate -90 Translate 3, 5 World Coordinates

Basic 2D Transformations Translation: = + t = + t Scale: = s = s Rotation: = cos θ sin θ = sin θ + cos θ Transformations can be combined (with simple algebra)

Basic 2D Transformations Translation: = + t = + t Scale: = s = s Rotation: = cos θ sin θ = sin θ + cos θ

Basic 2D Transformations Translation: = + t = + t Scale: = s = s (, ) (, ) Rotation: = cos θ sin θ = sin θ + cos θ = s = s

Basic 2D Transformations Translation: = + t = + t Scale: = s = s Rotation: = cos θ sin θ = sin θ + cos θ (, ) = s = s = s cos θ s sin θ = s sin θ + s cos θ

Basic 2D Transformations Translation: = + t = + t Scale: = s = s (, ) Rotation: = cos θ sin θ = sin θ + cos θ = s = s = s cos θ s sin θ = s sin θ + s cos θ = s cos θ s sin θ + t = s sin θ + s cos θ + t

Overview 2D Transformations Basic 2D transformations Matri representation Matri composition 3D Transformations Basic 3D transformations Same as 2D

Matri Representation Represent 2D transformation b a matri a c b d Multipl matri b column vector appl transformation to point = a b c d = a + b = c + d

Matri Representation Transformations combined b multiplication = a b c d e g f h i k j k Matrices are a convenient and efficient wa to represent a sequence of transformations!

22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Scale around (0,0)? = s = s = s 0 0 s 2D Rotate around (0,0)? = cos θ sin θ = sin θ + cos θ = cos θ sin θ sin θ cos θ 2D Mirror over Y ais? = = = 1 0 0 1

22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Scale around (0,0)? = s = s = s 0 0 s Like scale with negative scale values 2D Mirror over Y ais? = = = 1 0 0 1

22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Translation?

22 Matrices What tpes of transformations can be represented with a 22 matri? 2D Translation? = + t = + t ' ' = NO! a c b d Onl linear 2D transformations can be represented with a 2 2 matri

Linear Transformations Linear transformations are combinations of Scale, and Rotation Properties of linear transformations: Satisfies: T s 1 p 1 + s 2 p 2 = s 1 T p 1 + s 2 T(p 2 ) Origin maps to origin Lines map to lines Parallel lines remain parallel Closed under composition = a b c d

Linear Transformations Linear transformations are combinations of Scale, and Rotation Properties of linear transformations: Satisfies: T s 1 p 1 + s 2 p 2 = s 1 T p 1 + s 2 T(p 2 ) Origin maps to origin = Lines map to lines Parallel lines remain parallel Closed under composition a b c d Translations do not map the origin to the origin

2D Translation Treat 2D positions as 3D positions b adding a third coordinate with a 1 :, (,, 1) Represent translations using a 33 matri: 1 = 1 0 t 0 1 t 0 0 1 1 = + t = + t

Homogeneous Coordinates Add a 3rd coordinate to ever 2D point (,, w) represents a point at location, w w (,, 0) represents a (directed) point at infinit (0, 0, 0) is not allowed 2 1 (2,1,1) or (4,2,2) or (6,3,3) 1 2 Convenient coordinate sstem to represent man useful transformations

Basic 2D Transformations Basic 2D transformations as 3 3 matrices 1 1 0 t = 0 1 t 0 0 1 Translate 1 1 = s 0 0 0 s 0 0 0 Scale 1 1 1 = cos θ sin θ 0 sin θ cos θ 0 0 0 1 Rotate 1

Affine Transformations Affine transformations are combinations of Linear transformations, and Translations w = a b c d e f 0 0 1 w Properties of affine transformations: Origin does not necessaril map to origin Lines map to lines Parallel lines remain parallel Closed under composition

Affine Transformations Affine transformations are combinations of Linear transformations, and Translations w = a b c d e f 0 0 1 w Note that under projective transformations Properties of,, affine 1 has transformations: to map to (,, 1) Origin does not necessaril map to origin Lines map to lines Parallel lines remain parallel Closed under composition

Projective Transformations Projective transformations Affine transformations, and Projective warps w = a b c d e f g h i Properties of projective transformations: Origin does not necessaril map to origin Lines map to lines Parallel lines do not necessaril remain parallel Closed under composition w

Projective Transformations Projective transformations Affine transformations, and Projective warps w = a b c d e f g h i Properties Note of that projective under projective transformations: Origin, does, 1 not does necessaril not have to map to to ( origin,, 1) Lines map to lines Parallel lines do not necessaril remain parallel Closed under composition w

Overview 2D Transformations Basic 2D transformations Matri representation Matri composition 3D Transformations Basic 3D transformations Same as 2D

Matri Composition Transformations can be combined b matri multiplication 1 0 t cos θ sin θ 0 s 0 0 = 0 1 t sin θ cos θ 0 0 s 0 w 0 0 1 0 0 1 0 0 1 w p = T t, t R θ S s, s p

Matri Composition Matrices are a convenient and efficient wa to represent a sequence of transformations General purpose representation Efficienc with pre-multiplication of matrices p = T R S p p = (T R S)(p)

Matri Composition Be aware: order of transformations matters» Matri multiplication is not commutative p = T R S p Global Local

Matri Composition Rotate b θ around arbitrar point (a, b) M = T a, b R θ T( a, b) The trick: First, translate (a, b) to the origin. Net, do the rotation about origin. Finall, translate back. (a, b) Scale b (s, s ) around arbitrar point (a, b) M = T a, b S s, s T( a, b) (Use the same trick.) (a, b)

Overview 2D Transformations Basic 2D transformations Matri representation Matri composition 3D Transformations Basic 3D transformations Same as 2D

3D Transformations Same idea as 2D transformations Homogeneous coordinates: (,, z, w) 4 4 transformation matrices» Affine z 1» Projective z w = = a b c d e f g h i j k l 0 0 0 1 a b c d e f g h i j k l m n o p z 1 z w

Basic 3D Transformations z w = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 Identit z w z w = s 0 0 0 0 s 0 0 0 0 s z 0 0 0 0 1 Scale z w z w = 1 0 0 t 0 1 0 t 0 0 1 t z 0 0 0 1 z w Translation

Basic 3D Transformations Pitch-Roll-Yaw Convention: An rotation can be epressed as the combination of a rotation about the -, the -, and the z-ais. Rotate around z ais: z w = cos θ sin θ 0 0 sin θ cos θ 0 0 0 0 1 0 0 0 0 1 z w Rotate around ais: z w = cos θ 0 sin θ 0 0 1 0 0 sin θ 0 cos θ 0 0 0 0 1 z w Rotate around ais: z w = 1 0 0 0 0 cos θ sin θ 0 0 sin θ cos θ 0 0 0 0 1 z w

Basic 3D Transformations Pitch-Roll-Yaw Convention: An rotation can be epressed as the combination of a rotation about the -, the -, and the z-ais. Rotate around z ais: z w = cos θ sin θ 0 0 sin θ cos θ 0 0 0 0 1 0 0 0 0 1 z w How do ou rotate around an Rotate around ais: = arbitrar ais U b angle ψ? Rotate around ais: z w z w = cos θ 0 sin θ 0 0 1 0 0 sin θ 0 cos θ 0 0 0 0 1 1 0 0 0 0 cos θ sin θ 0 0 sin θ cos θ 0 0 0 0 1 z w z w

Rotation B ψ Around Arbitrar Ais U Align U (wlog) with the z-ais: T (a,b,c) : Translate U b (a, b, c) to pass through origin R φ R θ : Rotate around the - and -aes b θ and φ degrees to get U aligned with the z-ais. R z (ψ): Perform rotation b ψ around the z-ais. Do inverse of original transformation for alignment. U U z T (a,b,c) z R φ R θ z U

Rotation B ψ Around Arbitrar Ais U Align U (wlog) with the z-ais: T (a,b,c) : Translate U b (a, b, c) to pass through origin R φ R θ : Rotate around the - and -aes b θ and φ degrees to get U aligned with the z-ais. R z (ψ): Perform rotation b ψ around the z-ais. Do inverse of original transformation for alignment. p = R φ R θ T a,b,c 1 Rz ψ R φ R θ T a,b,c p Aligning Transformation