Overview. Affine Transformations (2D and 3D) Coordinate System Transformations Vectors Rays and Intersections

Similar documents
2D and 3D Coordinate Systems and Transformations

UNIT 2 2D TRANSFORMATIONS

Computer Graphics: Geometric Transformations

2D TRANSFORMATIONS AND MATRICES

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

Graphics and Interaction Transformation geometry and homogeneous coordinates

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

Section III: TRANSFORMATIONS

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

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

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

Transforms. COMP 575/770 Spring 2013

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

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

Transformations: 2D Transforms

2D and 3D Transformations AUI Course Denbigh Starkey

Transformations Week 9, Lecture 18

Computer Graphics Geometric Transformations

The Viewing Pipeline Coordinate Systems

COMP3421. Vector geometry, Clipping

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Affine Transformation. Edith Law & Mike Terry

CSE328 Fundamentals of Computer Graphics

Computer Graphics 7: Viewing in 3-D

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

CSC418 / CSCD18 / CSC2504

3D Computer Graphics. Jared Kirschner. November 8, 2010

Advanced Computer Graphics Transformations. Matthias Teschner

UNIT 2. Translation/ Scaling/ Rotation. Unit-02/Lecture-01

Homogeneous Coordinates and Transformations of the Plane

Chapter 2 - Basic Mathematics for 3D Computer Graphics

Vector Algebra Transformations. Lecture 4

Visual Recognition: Image Formation

Computer Graphics Viewing Objective

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

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

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

2D transformations: An introduction to the maths behind computer graphics

3D Transformations World Window to Viewport Transformation Week 2, Lecture 4

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

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

Overview. By end of the week:

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

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

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

Interactive Computer Graphics. Hearn & Baker, chapter D transforms Hearn & Baker, chapter 5. Aliasing and Anti-Aliasing

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

Image Warping. Some slides from Steve Seitz

Last week. Machiraju/Zhang/Möller

Shadows in Computer Graphics

Computer Science 336 Fall 2017 Homework 2

GEOMETRIC TRANSFORMATIONS AND VIEWING

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

Representing 2D Transformations as Matrices

CS4620/5620. Professor: Kavita Bala. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

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 Hands-on

Institutionen för systemteknik

Game Engineering: 2D

Coordinate transformations. 5554: Packet 8 1

2D Object Definition (1/3)

N-Views (1) Homographies and Projection

Two Dimensional Viewing

THE VIEWING TRANSFORMATION

CS770/870 Spring 2017 Transformations

Chapter 5. Transformations of Objects

Computer Vision cmput 428/615

CS452/552; EE465/505. Geometry Transformations

Midterm Review II Math , Fall 2018

Mathematics (

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

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

From Vertices To Fragments-1

CHAPTER 4 RAY COMPUTATION. 4.1 Normal Computation

MODULE - 7. Subject: Computer Science. Module: Other 2D Transformations. Module No: CS/CGV/7

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

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

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

Cs602-computer graphics MCQS MIDTERM EXAMINATION SOLVED BY ~ LIBRIANSMINE ~

Today s Topics. 3. Transformations in 2D. 4. Coordinate-free geometry. 5. 3D Objects (curves & surfaces) 6. Transformations in 3D

Graphics Pipeline 2D Geometric Transformations

Lines and Planes in 3D

Ray scene intersections

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

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

CS 325 Computer Graphics

Introduction to 3D Graphics

521493S Computer Graphics Exercise 1 (Chapters 1-3)

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

PetShop (BYU Students, SIGGRAPH 2006)

Computer Graphics I Lecture 11

Viewing COMPSCI 464. Image Credits: Encarta and

3D Rendering Pipeline (for direct illumination)

2D/3D Geometric Transformations and Scene Graphs

15. Clipping. Projection Transformation. Projection Matrix. Perspective Division

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

CS452/552; EE465/505. Transformations

Models and The Viewing Pipeline. Jian Huang CS456

Geometric Transformations

Transcription:

Overview Affine Transformations (2D and 3D) Coordinate System Transformations Vectors Rays and Intersections ITCS 4120/5120 1 Mathematical Fundamentals

Geometric Transformations A set of tools that aid in manipulating graphical objects and their coordinate systems Y Y D C M D B C A B X A X ITCS 4120/5120 2 Mathematical Fundamentals

Affine Transformations most common in computer graphics permits a simple matrix representation can be composed Definition P (P x, P y ) is transformed into Q(Q x, Q y ) as follows: Q x = ap x + cp y + T x Q y [ ] Qx Q y = bp x + dp y + T y = Q = [ ] [ ] a c Px + b d P y M P + T [ ] Tx T y ITCS 4120/5120 3 Mathematical Fundamentals

2D Primitive Affine Transformations Q = M P + T Translation [ ] Qx Q y M = T = = [ ] 1 0 = I (Identity) 0 1 [ ] Tx T y [ ] Px + T x P y + T y ITCS 4120/5120 4 Mathematical Fundamentals

Scale [ ] Qx Q y M = = [ ] Sx 0, T = [ 0 0 ] 0 S y [ ] Px S x P y S y S x = S y (Uniform Scaling) S x S y (Differential Scaling) ITCS 4120/5120 5 Mathematical Fundamentals

Rotation [ ] Cosθ Sinθ M = Sinθ Cosθ T = [ 0 0 ] Q = MP + T = P x Cosθ P y Sinθ = P x Sinθ + P y Cosθ Q x Q y Y Q y Q P y O θ R φ Exercise: Derive the above rotation matrix. ITCS 4120/5120 6 Mathematical Fundamentals R Q x P x P X

An Application of Affine Transforms (wx_max, wy_max) (vx_max, vy_max) (xw,yw) (wx_min, wy_min) (xv,yv) (vx_min, vy_min) Window to Viewport Transform Break M wv into a series of primitive transformations. 1. Translate a corner of window to the origin. 2. Scale window to unit size. 3. Scale window to viewport size. 4. Translate to viewport origin. ITCS 4120/5120 7 Mathematical Fundamentals

An Application of Affine Transforms (wx_max, wy_max) (vx_max, vy_max) (xw,yw) (wx_min, wy_min) (xv,yv) (vx_min, vy_min) 1. Translate window to the origin: T ( w xmin, w ymin ) 2. Scale window to unit size: S(S wx, S wy ) 3. Scale to viewport size: S(S vx, S vy ) 4. Translate to viewport origin: T (v xmin, v ymin ) M wv = T (v xmin, v ymin )S(S vx, S vy )S(S wx, S wy )T ( w xmin, w ymin ) ITCS 4120/5120 8 Mathematical Fundamentals

Homogeneous Coordinate Representation Motivation Translation: Q = P + T (Tx, T y ) Rotation: Scale: Q = R(θ) P Q = S(Sx, S y ) P Translation involves a vector addition instead of a vector-matrix multiplication. Better if all transforms are accomplished using a vector-matrix multiply. ITCS 4120/5120 9 Mathematical Fundamentals

Homogeneous Coordinates: Representing Points P 2d = (x, y), P H = (x, y, w) W P (x, y, w) W = 1 Plane X Y Points in 2D are the projection of points in homogeneous space onto the w = 1 plane. To convert from P H to P 2D, divide each coordinate by the w coordinate and discard the 3rd coordinate. w = 0 represents points at infinity. ITCS 4120/5120 10 Mathematical Fundamentals

Homogeneous Matrices Additional row and column T H (T x, T y ) = S H (S x, S y ) = R H (θ) = 1 0 T x 0 1 T y 0 0 1 S x 0 0 0 S y 0 0 0 1 Cosθ Sinθ 0 Sinθ Cosθ 0 0 0 1 ITCS 4120/5120 11 Mathematical Fundamentals

Homogeneous Matrices(contd) Hence Q = T H (T x, T y ) P Q = S H (S x, S y ) P Q = R H (θ) P In particular, 1 0 T x 0 1 T y P x P y = [ ] P x + T x, P y + T y 0 0 1 1 ITCS 4120/5120 12 Mathematical Fundamentals

Affine Transforms (contd.) Shear Transform: Q x = P x + hp y, Q y = gp x + P [ ] y 1 h M sh = g 1 g = 0 (X axis shear), h = 0 (Y axis shear) Y X Application X Shear (h > 0) 3D Viewing Pipeline ITCS 4120/5120 13 Mathematical Fundamentals

Reflection Transform Produces a mirror image about an axis of reflection. Y B B A A M y refl = M x refl = M = C C [ ] 1 0 Y axis reflection 0 1 [ ] 1 0 X axis reflection 0 1 [ ] 1 0 =?? 0 1 ITCS 4120/5120 14 Mathematical Fundamentals X

Affine Transform Inverses T 1 (T x, T y ) = T ( T x, T y ) S 1 (S x, S y ) = S(1/S x, 1/S y ) R 1 (θ) = [ ] Cosθ Sinθ Sinθ Cosθ = R T In general, MM 1 = M 1 M = I Exercise: Determine the inverse of M sh = [ ] 1 h. g 1 ITCS 4120/5120 15 Mathematical Fundamentals

Transformation About a Reference Point x r, yr Y Y M X X Strategy x, y r r = Reference point Translation of (x r, y r ) to the origin. Transform. Translate back by same amount. M = T (x r, y r ).S(S x, S y ).T ( x r, y r ) For rotation about a point, replace scale by a rotation transform. ITCS 4120/5120 16 Mathematical Fundamentals

Parametric Representations x(t) = x 0 + t(x 1 x 0 ) y(t) = y 0 + t(y 1 y 0 ) t (0.0, 1.0) corresponds to the segment from (x 0, y 0 ) to (x 1, y 1 ) In general, x(0) = x 0, x(1) = x 1 y(0) = y 0, y(1) = y 1 r(t) = p(t) + t d(t) where p(t) = origin, d(t) = direction vector. Application: Parametric Curves,Surfaces, Ray Tracing, Clipping ITCS 4120/5120 17 Mathematical Fundamentals

Properties of Affine Transforms Lines Remain Lines A t B P (t) = A + t( B A) Q(t) = M P (t) + T = M( A + t( B A)) + T = ( M A + T ) + tm( B A) which is also a line with origin ( A M + T ) and direction ( B A) M. ITCS 4120/5120 18 Mathematical Fundamentals

Parallel Lines Remain Parallel R 1 (t) = A 1 + βt R 2 (t) = A 2 + βt After Transformation, New Origins: A1 M + T, A2 M + T New Direction: βm ITCS 4120/5120 19 Mathematical Fundamentals

Transformation of Coordinate Systems j O P i M O v u Q To determine Q, in terms of P. u = v = M i = left column of M M j = right column of M How? [ ] [ ] u = M m00 m i = 01 1 = m 10 m 11 0 [ ] [ ] v = M m00 m j = 01 0 = m 10 m 11 1 [ m00 ] m 10 [ ] m01 m 11 ITCS 4120/5120 20 Mathematical Fundamentals

Transformation of Coordinate Systems(contd) M = [ u v ] j Tj b v a u P T (0, 0) Ti i P = a u + b v + T = [ u v ] [ ] a + T b [ a Q = = b] [ u v ] 1 [ ] P T = M [ ] 1 P T ITCS 4120/5120 21 Mathematical Fundamentals

3-D Affine Transformations Translation M t = 1 0 0 T x 0 1 0 T y 0 0 1 T z 0 0 0 1 ITCS 4120/5120 22 Mathematical Fundamentals

3-D Affine Transformations Rotation R z (θ) = R x (θ) = R y (θ) = Cosθ Sinθ 0 0 Sinθ Cosθ 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 Cosθ Sinθ 0 0 Sinθ Cosθ 0 0 0 0 1 Cosθ 0 Sinθ 0 0 1 0 0 Sinθ 0 Cosθ 0 0 0 0 1 ITCS 4120/5120 23 Mathematical Fundamentals

3-D Affine Transformations Scaling S x 0 0 0 0 S S(S x, S y, S z ) = y 0 0 0 0 S z 0 0 0 0 1 ITCS 4120/5120 24 Mathematical Fundamentals

Composing Affine Transforms If M 1, M 2,..., M n are affine transforms to be applied in succession to a point P. Q = (M n.(m n 1...(M 2.(M 1.P )...) = (M n.m n 1...M 3.M 2.M 1 )P For transforming large numbers of points, the matrix product (M 1.M 2.M 3...M n 1.M n ) needs to be performed only once. Example Y Y M comp X X M comp = T (T x, T y ).S(S x, S y ).R(θ).T ( T x, T y ) ITCS 4120/5120 25 Mathematical Fundamentals

3D Affine Transforms about pivot point Scaling Translate pivot point to origin. Scale by (S x, S y, S z ). Translate pivot point back. M = T (T x, T y, T z ).S(S x, S y, S z ).T ( T x, T y, T z ) ITCS 4120/5120 26 Mathematical Fundamentals

Rotation about Arbitrary Axis Y d P X Z Given P, point on axis and axis direction vector d ITCS 4120/5120 27 Mathematical Fundamentals

Rotation about Arbitrary Axis Y d P X Strategy Translate rotation axis to pass through origin. Align rotation axis with a coordinate axis. Rotate by given angle A Inverse Rotations. Inverse translations. Z M = T (T x, T y, T z )R y (θ)r x (φ)r y (A)R x ( φ)r y ( θ).t ( T x, T y, T z ) ITCS 4120/5120 28 Mathematical Fundamentals

Reflection (3D) M rl z = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 Similarly, M rl x and M rl y can be defined. Reflection about an arbitrarily oriented plane? ITCS 4120/5120 29 Mathematical Fundamentals

Properties of 3D Affine Transforms Lines are preserved. Parallel lines remain parallel after transformation. Proportional distances are preserved. Transformation of coordinate systems used in hierarchical modeling, 3D Viewing. ITCS 4120/5120 30 Mathematical Fundamentals

Vectors An entity that possesses both magnitude and direction Addition Length Normalization V = (v 0, v 1, v 2 ) V = X + Y = (x 0 + y 0, x 1 + y 1, x 2 + y 2 ) V = (v 2 0 + v 2 1 + v 2 2) 1/2 U = V / V, hence V = V U ITCS 4120/5120 31 Mathematical Fundamentals

Vectors(contd) Dot (Inner) Product V = X Y = x 0 y 0 + x 1 y 1 + x 2 y 2, Also, V = X Y Cosθ where θ is the angle between X and Y Application Shading calculations Detecting back facing polygons Reflection Vector Calculation ITCS 4120/5120 32 Mathematical Fundamentals

Reflected Ray Calculation V N R θ θ O ON = 1 ON = ( OV. ON) N V N = NR = OV + ( OV. ON) N OR = ON + NR = 2( OV. ON) ON OV ITCS 4120/5120 33 Mathematical Fundamentals

Vector Cross (Outer) Product Application V = X Y i j k = x 0 x 1 x 2 y 0 y 1 y 2 Normal Vector calculations if X and Y are vectors on a polygon (or tangent vectors on a surface, N = X Y is the Normal vector to the surface. ITCS 4120/5120 34 Mathematical Fundamentals

Rays and Intersections Ray Representation Rays generally use a parametric representation May be bounded (eg. line segments) Application x = x 1 + t(x 2 x 1 ) = x 1 + it y = y 1 + t(y 2 y 1 ) = y 1 + jt z = z 1 + t(z 2 z 1 ) = z 1 + kt Ray Tracing and Ray Casting Algorithms Direct Volume Rendering (using Ray Casting) ITCS 4120/5120 35 Mathematical Fundamentals

Ray-Polygon Intersection Check for intersection between ray and the plane containing the polygon Check that the intersection is contained by the polygon Ax + By + Cz + D = 0 (polygon plane equation) Substitution ray equations, t = (Ax 1 + By 1 + Cz 1 + D) (A i + B j + C k) ITCS 4120/5120 36 Mathematical Fundamentals

Ray-Box Intersection t_n1 near2 t_n1 t_n2 t_f1 t_n2 far2 near1 Bounded Volume t_f1 far1 t_f2 t_f2 Intersection Condition Max (Near Inters.) < Min (Far Inters.)? If the maximum of the near intersections is less than the minimum of the far intersections, there an intersection. ITCS 4120/5120 37 Mathematical Fundamentals