Review: Transformations

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Invariants (continued).
Computer Graphics Lecture 4 Geometry & Transformations.
University of North Carolina at Greensboro
Geometry (Many slides adapted from Octavia Camps and Amitabh Varshney)
2D Geometric Transformations
Chapter 4.1 Mathematical Concepts
Linear Algebra and SVD (Some slides adapted from Octavia Camps)
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation.
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
3-D Geometry.
Computer Graphics CSC 630 Lecture 2- Linear Algebra.
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Introduction to 3D Graphics Lecture 3: General Camera Model Anthony Steed University College London.
1 Matrix Math ©Anthony Steed Overview n To revise Vectors Matrices n New stuff Homogenous co-ordinates 3D transformations as matrices.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1
Mathematical Fundamentals
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Transformations Dr. Amy Zhang.
Homogeneous Coordinates (Projective Space) Let be a point in Euclidean space Change to homogeneous coordinates: Defined up to scale: Can go back to non-homogeneous.
Geometric Transformations Jehee Lee Seoul National University.
2003CS Hons RW778 Graphics1 Chapter 5: Transforming Objects 5.2 Introduction to Transformations 5.2 Introduction to Transformations –Affine transformations.
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Transformations Jehee Lee Seoul National University.
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Geometric Transformations
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
Affine Geometry.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 3: Transformations 1
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Transformations of objects
Geometric Transformations. Transformations Linear transformations Rigid transformations Affine transformations Projective transformations T Global reference.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
4. Affine transformations. Reading Required:  Watt, Section 1.1. Further reading:  Foley, et al, Chapter  David F. Rogers and J. Alan Adams,
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
CSCE 441 Computer Graphics: 2D Transformations
Modeling Transformation
Transformations University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner.
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
CSE 167 [Win 17], Lecture 3: Transformations 1 Ravi Ramamoorthi
Ch. 2: Rigid Body Motions and Homogeneous Transforms
3. Transformation
Geometric Transformations Hearn & Baker Chapter 5
2D Transformations By: KanwarjeetSingh
2D Geometric Transformations
Computer Graphics CC416 Week 15 3D Graphics.
2D Transformations with Matrices
Review: Transformations
2D Transformations y y x x y x.
Homogeneous Coordinates (Projective Space)
Three-Dimensional Graphics
Transformations.
ECE 383/ME 442: Intro to Robotics and Automation
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Geometric Camera Models
Chapter IV Spaces and Transforms
(c) University of Wisconsin, CS559
Transformations 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Linear Algebra A gentle introduction
TWO DIMENSIONAL TRANSFORMATION
Game Programming Algorithms and Techniques
Presentation transcript:

Review: Transformations Need to transform points and vectors Transform object data from object space to world space CSE 681

Transformations Modeling transformations build complex models by positioning (transforming) simple components relative to each other Viewing transformations placing virtual camera in the world transformation from world coordinates to camera coordinates Perspective projection of 3D coordinates to 2D Animation vary transformations over time to create motion CSE 681

Transformations - Modeling Object parts defined in their own object coordinate spaces Transform them relative to each other to assemble object CSE 681

Transformations - Viewing CAMERA OBJECT Object defined in object space is transformed into world space Camera with its own local coordinate system is transformed into world space Need object relative to camera coordinate system WORLD CSE 681

Modeling Transformations Transform objects/points Transform coordinate system Can think of transformation either as: Transforming object relative to fixed coordinate system transforming coordinate system that object is in (e.g. moving camera) CSE 681

Affine Transformations Transform P = (x, y, z) to Q = (x’, y’, z’). Affine transformation: x’ = m11 x + m12 y + m13 z + m14 y’ = m21 x + m22 y + m23 z + m24 z’ = m31 x + m32 y + m33 z + m34 Math name of what we’re interested in: Affine transformations Means: Linear equations. CSE 681

Translation Translation by (tx, ty, tz): x’ = x + tx y’ = y + ty z’ = z + tz (tx, ty, tz) Translation is an affine transformation. CSE 681

Scaling Scaling by (sx, sy, sz): x’ = sx x y’ = sy y z’ = sz z CSE 681 Scaling is an affine transformation. Note: Location of lower left corner of house is changed CSE 681

Rotation Rotation counter-clockwise by angle  around the z-axis: x’ = x cos() – y sin() y’ = x sin() + y cos() z’ = z x z y   r Proof: x = r cos() y = r sin() x’ = r cos( + ) = r cos() cos() – r sin() sin() = x cos() – y sin() y’ = r sin( + ) = r cos() sin() + r sin() cos() = x sin() + y cos() USE RIGHT HAND RULE Rotation is an affine transformation. (x,y,z) =( r*cos(alpha), r*sin(alpha) , z) Another viewpoint: Where do the points (1, 0, 0) and (0, 1, 0) go? CSE 681

Rotation around x-axis Rotation counter-clockwise by angle  around the x-axis: x’ = x y’ = y cos() – z sin() z’ = y sin() + z cos() z  x y CSE 681

Rotation around y-axis Rotation counter-clockwise by angle  around the y-axis: y’ = y z’ = z cos() – x sin() x’ = z sin() + x cos() Or x’ = x cos() + z sin() z’ = – x sin() + z cos() x Note: Here x plays role of y in rotation around z-axis.  y z CSE 681

Matrix Multiplication Scaling by (sx, sy, sz): x’ = sx x y’ = sy y z’ = sz z Rotation counter-clockwise by angle  around the z-axis: x’ = x cos() – y sin() y’ = x sin() + y cos() z’ = z Translation by (tx, ty, tz): x’ = x + tx y’ = y + ty z’ = z + tz CSE 681

Homogeneous Coordinates Represent P by (x, y, z, 1) and Q by (x’, y’, z’, 1). (Homogeneous coordinates.) Translation by (tx, ty, tz): x’ = x + tx y’ = y + ty z’ = z + tz Scaling by (sx, sy, sz): x’ = sx x y’ = sy y z’ = sz z CSE 681

Rotation Matrices Rotation counter-clockwise by angle  around the x-axis: x’ = x y’ = y cos() – z sin() z’ = y sin() + z cos() Rotation counter-clockwise by angle  around the y-axis: x’ = x cos() + z sin() y’ = y z’ = – x sin() + z cos() Rotation counter-clockwise by angle  around the z-axis: x’ = x cos() – y sin() y’ = x sin() + y cos() z’ = z CSE 681

Affine Transformation Matrix x’ = m11 x + m12 y + m13 z + m14 y’ = m21 x + m22 y + m23 z + m24 z’ = m31 x + m32 y + m33 z + m34 Transformation Matrix: Translation in right colum Scale along diagonal (uniform or non uniform) Rotation elsewhere Rigid transformations (w/ uniform scale) CSE 681

Shearing Shear along the x-axis: x’ = x + hy y’ = y z’ = z y x z Note change in location of lower left corner of house. Can construct shear by combination of rotations and non-uniform scaling. CSE 681

Reflection Reflection across the x-axis: x’ = (-1) x y’ = y z’ = z Use this with rhs of world to lhs of amera Reflection is a special case of scaling! CSE 681

Elementary Transformations Translation Rotation Scaling Shear CSE 681

Compose Transformations Rotate by 30° counter-clockwise around the z-axis x z y Scale by (2, 1, 1) Translate by (20, 5, 0) Translate by (0, -50, 0) CSE 681

Compose Transformation Matrices Rotate by 30° counter-clockwise around the z-axis; Rotate Scale by (2, 1, 1); Scale x z y Translate by (20, 5, 0); Translate Translate by (0, -50, 0). Translate Multiply matrices together. Real advantage of matrix multiplication/homogeneous coordinates. CSE 681

Compose Transformation Matrices Scale by (2, 1, 1); x z y Translate by (20, 5, 0); Rotate by 30° counter-clockwise around the z-axis; Translate by (0, -50, 0). CSE 681

Order Matters! Transformations are not necessarily commutative! Translate by (20, 0, 0). Rotate by 30. Rotate by 30. Translate by (20, 0, 0). x z y x z y CSE 681

Order of Transformation Matrices Apply transformation matrices from right to left. Translate by (20, 0, 0). Rotate by 30. Rotate by 30. Translate by (20, 0, 0). CSE 681

Which transformations commute? Translation and translation? Scaling and scaling? Rotation and rotation? Translation and scaling? Translation and rotation? Scaling and rotation? Uniform scaling and rotation commute. CSE 681

Elementary Transformations Translation; Rotation; Scaling; Shear. Theorem: Every affine transformation can be decomposed into elementary operations. Euler’s Theorem: Every rotation around the origin can be decomposed into a rotation around the x-axis followed by a rotation around the y-axis followed by a rotation around the z-axis. (or a single rotation about an arbitrary axis). CSE 681

Vectors Vector V = (Vx, Vy, Vz). Homogeneous coordinates: (Vx, Vy, Vz, 0). Affine transformation: CSE 681

Vectors Rotation: Scaling: Translation: (Note: No change.) CSE 681

Transform Parametric Line V P(u) P0 u M Q(u) M M u W Q0 CSE 681

Line transformed point on a line ?= point on transformed line M(P(u) T) ?= M(P0T + u* VT) Line through P0 = (x, y, z, 1) in direction V = (Vx, Vy, Vz, 0): P(u) = P0T + u* VT {(x0, y0, z0, 1) + u* (Vx, Vy, Vz, 0): u  Reals}. Apply affine transformation matrix M to line P(u): M *P(u) = { M (P0T + u VT) : u  Reals} = { M P0T + uM VT : u  Reals} = { Q0 + u V’ : u  Reals}. Theorem: Affine transformations transform lines to lines. CSE 681

Affine Transformation of Lines y y Which points don’t change? z x z x CSE 681

Affine Combinations Q R b a P M R’ M M b a Q’ P’ CSE 681

Affine Combinations Affine combinations of P = (x, y, z, 1) and Q = (x’, y’, z’, 1): {R = a (x, y, z, 1) + b (x’, y’, z’, 1): a,b  Reals and a + b = 1} Apply affine transformation matrix M to (a PT + b QT) gives: M (a PT + b QT) = M a PT + M b QT = a M PT + b M QT = a P’ + b Q’ = MR = R’ Theorem: Affine transformations preserve affine combinations. CSE 681

Properties of Affine Transformations Affine transformations map lines to lines; Affine transformations preserve affine combinations; Affine transformations preserve parallelism; Affine transformations change volume by | Det(M) |; Any affine transformation can be decomposed into elementary transformations. Affine transformations [does/does not] preserve angles? Affine transformations [does/does not] the intersection of two lines? Affine transformations [does/does not] preserve distances? CSE 681

Properties of Transformation Matrices First column is how (1,0,0,0) transforms Second column is how (0,1,0,0) transforms Third column is how (0,0,1,0) transforms Matrix holds how coordinate axes transform and how origin transforms CSE 681

Properties of Pure Rotation Matrices Rows (columns) are orthogonal to each other A row dot product any other row = 0 Each row (column) dot product times itself = 1 RT = R-1 CSE 681

Coordinate Frame y j  i k z x Coordinate frame is given by origin  and three mutually orthogonal unit vectors, i, j, k - defined in (x,y,z) space Mutually orthogonal (dot products): i•j = ?; i•k = ?; j•k = ?. Unit vectors (dot products): i•i = ?; j•j = ?; k•k = ?. CSE 681

Orientation Right handed coordinate system: Left handed coordinate system: x z y y (Into page) z x (Out of page) CSE 681

Orientation Right handed coordinate system: Left handed coordinate system: k x z y i j k  x z y j i  How could you test if the I,j,k coordinate frame is right-handed or left-handed Cross product: i x j = ? Cross product: i x j = ? How do you test whether (i,j,k) is left handed or right handed? CSE 681

Coordinate Transformations x z y i j k  Given object data points defined in the (i, j, k, ) coordinate frame, Given the definition of (i, j, k, ) in (x, y, z) coordinates, How do you determine the coordinates of the object data points in the (x, y, z, 0) frame? x,y,z,0 are mapped to i,j,k,, respectively. CSE 681

Coordinate change (Translation) b x z y (x, y, z) a (0,0,0) c Change from (a,b,c,) coordinates to (x,y,z,0) coordinates: Move (a,b,c, ) to (x,y,z,0) and invert Move data relative from (0,0,0) out to  position by adding  CSE 681

Coordinate change (Rotation) (x, y, z) a b y x  z-axis rotation by  (0,0,0) z What does (1,0,0) trasform to? What does (0,1,0) transform to? What does (0,0,1) transform to? Change from (a,b,c,) coordinates to (x,y,z,0) coordinates: Rotate (a,b,c) by  and invert Rotate data by - CSE 681

Object Transformations k  . 1 ú û ù ê ë é f z y x x z y i j k Given (i,j,k,p) defined in the (x,y,z,0) coordinate frame, Transform points defined in the (i, j, k, ) coordinate frame to the (x,y,z,0) coordinate frame. Rotate object to get x to line up with i, then translate to  x,y,z,0 are mapped to i,j,k,, respectively. CSE 681

Object Transformations x z y i j k  i j k x,y,z,0 are mapped to i,j,k,, respectively. Affine transformation matrix: CSE 681

Coordinate Transformations x z y i j k  Given (i,j,k,p) defined in the (x,y,z,0) coordinate frame, Transform points in (x,y,z,0) coordinate frame to (i, j, k, ) coordinate frame. Apply transform to coordinate system, then invert: Coordinate system transform: translate by - , then rotate to align i with x x,y,z,0 are mapped to i,j,k,, respectively. CSE 681

Coordinate Transformations x z y i j k  x,y,z,0 are mapped to i,j,k,, respectively. T = R= CSE 681

Coordinate Transformations x z y i j k  Apply RT to coordinate system Apply (RT)-1 to data = T-1R-1 x,y,z,0 are mapped to i,j,k,, respectively. Affine transformation matrix: CSE 681

Composition of coordinate change y y’ M1 y”  z M2 x ’ x’ z’ z” x” M1 changes from coordinate frame (x,y,z,) to (x’,y’,z’,’). M2 changes from coordinate frame (x’,y’,z’,’) to (x’’,y’’,z’’,’’). Change from coordinate frame (x,y,z,) to (x’’,y’’,z’’,0): ? CSE 681

Composition of transformations - example B’ y B q A x CSE 681

Transformations of normal vectors  n is a unit normal vector to plane . M is an affine transformation matrix. How is n transformed, to keep it perpendicular to the plane, under: translation? rotation by ? uniform scaling by s? shearing or non-uniform scaling? CSE 681

Shear transformation n n’ n n is a unit normal vector to plane : (-nx,0) M is a shear transformation matrix that only modifies x-coordinates If we just transform the n as a vector, then M nT = n But we want n’ – that has a non-zero y-coordinate value CSE 681

Transformations of normal vectors Planar equation: a x + b y + c z + d = 0. Let N = (a, b, c, d). (Note: (a, b, c) is normal vector) Let P = (x, y, z, 1) be a point in plane . Planar equation: N • P = 0. M is an affine transformation matrix. (MT is M transpose.) Let P’ = M PT. Find N’ such that N’ • P’ = 0 (transformed planar equation) N • P = 0; N PT = 0; N (M-1 M) PT = 0; (N M-1) (M PT) = 0; (N M-1) P’T = 0; So N’ = NM-1 To put in column-vector form, (N’)T = (NM-1)T = (M-1)TNT So N’ = ((M-1)T NT)T and (M-1)T is the transformation matrix to take NT into N’T Note: If M is a rotation matrix, (M-1)T = M. n  P CSE 681