CS770/870 Spring 2017 Transformations

Similar documents
CS770/870 Spring 2017 Transformations

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

Computer Graphics. Geometric Transformations

Computer Graphics. Geometric Transformations

CS559: Computer Graphics

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

4. Two Dimensional Transformations

Two Dimensional Viewing

What and Why Transformations?

CS F-07 Objects in 2D 1

Image Warping. Some slides from Steve Seitz

The 3-D Graphics Rendering Pipeline

Modeling Transformations

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

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

Transformations II. Week 2, Wed Jan 17

Modeling Transformations Revisited

Homework 5: Transformations in geometry

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

Vector Algebra Transformations. Lecture 4

Image Warping (Szeliski Sec 2.1.2)

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

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

CS Computer Graphics: Transformations & The Synthetic Camera

CT5510: Computer Graphics. Transformation BOCHANG MOON

CMSC 425: Lecture 10 Basics of Skeletal Animation and Kinematics

3D Geometry and Camera Calibration

3-Dimensional Viewing

Modeling Transformations

Homework 5: Transformations in geometry

Image Warping CSE399b, Spring 07 Computer Vision

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

Scene Graphs & Modeling Transformations COS 426

Viewing and Projection

Image Warping. Some slides from Steve Seitz

Computer Graphics. P04 Transformations. Aleksandra Pizurica Ghent University

Geometric Model of Camera

Transformations. Examples of transformations: shear. scaling

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Introduction to Homogeneous Transformations & Robot Kinematics

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

Transformations of Functions. 1. Shifting, reflecting, and stretching graphs Symmetry of functions and equations

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

Editing and Transformation

To Do. Course Outline. Course Outline. Goals. Motivation. Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1

Geometric Transformations

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

Computer Graphics. Si Lu. Fall er_graphics.htm 10/11/2017

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

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

More on Transformations. COS 426, Spring 2019 Princeton University

Homogeneous Coordinates

Lecture 4: Viewing. Topics:

Appendix C: Review of Graphs, Equations, and Inequalities

Lines and Their Slopes

Chap 7, 2009 Spring Yeong Gil Shin

Unit 5 Lesson 2 Investigation 1

Transformations III. Week 2, Fri Jan 19

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

Viewing/Projections III. Week 4, Wed Jan 31

2D Geometric Transformations and Matrices

Transforms. COMP 575/770 Spring 2013

Performing Congruence and Similarity Transformations. C m

Enhanced Instructional Transition Guide

Monday, 12 November 12. Matrices

MEM380 Applied Autonomous Robots Winter Robot Kinematics

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

Viewing/Projection IV. Week 4, Fri Jan 29

What does OpenGL do?

1 Points and Distances

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

Flux Integrals. Solution. We want to visualize the surface together with the vector field. Here s a picture of exactly that:

CS4670: Computer Vision

12.4 The Ellipse. Standard Form of an Ellipse Centered at (0, 0) (0, b) (0, -b) center

High Dimensional Rendering in OpenGL

Modeling Transformations

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

To Do. Computer Graphics (Fall 2004) Course Outline. Course Outline. Motivation. Motivation

Introduction to Homogeneous Transformations & Robot Kinematics

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

Notes. University of British Columbia

Intermediate Algebra. Gregg Waterman Oregon Institute of Technology

Geometric Transformations

Modeling Transformations

2D/3D Geometric Transformations and Scene Graphs

Overview. By end of the week:

Image Metamorphosis By Affine Transformations

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

Graphs and Functions

8.6 Three-Dimensional Cartesian Coordinate System

2.4 Coordinate Proof Using Distance with Quadrilaterals

Chapter 2 - Basic Mathematics for 3D Computer Graphics

20 Calculus and Structures

Plot and connect the points in a coordinate plane to make a polygon. Name the polygon.

2D and 3D Transformations AUI Course Denbigh Starkey

News. Projections and Picking. Transforming View Volumes. Projections recap. Basic Perspective Projection. Basic Perspective Projection

Graphics Pipeline 2D Geometric Transformations

Modeling Transformations

Transcription:

CS770/870 Spring 2017 Transformations Coordinate sstems 2D Transformations Homogeneous coordinates Matrices, vectors, points Coordinate Sstems Coordinate sstems used in graphics Screen coordinates: the phsical location on a specific displa device Window coordinates: screen coords relative to window origin Normalized device coordinates (NDC: a device independent abstraction of displa window World coordinates: a generic coordinate sstem that an application can use to define objects for displa 0,0 s s 0,0 w w 01/29/2017 1 2 Screen Coordinates GUI Window Coordinates Phsical device coords Location of piels S b S piels 640480, 1024768, 1280800, 1440900, etc. Variation is difficult for application program; leads to device dependent code S -1, S -1 GUI windows add another complication GUI Window sstem gives the application a portion of the screen that is w h piels, for arbitrar w and h Window sstem maps window coordinates to screen coordinates w-1, h-1 3 4

Normalized Device Coordinates An abstraction of displa device coordinates (screen and/or GUI window Floating point (, coordinates from 0 to 1 goes up 1, 1 World Coordinates The application should be able to define objects in a wa natural for the domain: 0 to 100 feet for a house floor plan 0 to 4000 miles for a map of the US etc. World coordinates are simpl 2D or 3D float or double values that can represent locations and sizes of object to be displaed 5 6 Mapping World Coordinates to Device Coordinates Application needs to tell the graphics sstem: what portion of the world is to be displaed, called the window on the world. where on the screen the window should be mapped, called the viewport. In 2D the window is a rectangle in world coordinates the viewport is a rectangle in normalized device coordinates Some graphics sstems allow a rotation as well 7 Window to Viewport Mapping Window: ( lo, lo to ( hi, hi Viewport: (u lo, v lo to (u hi, v hi lo, lo World Coordinates ( hi, hi Viewport Window u lo, v lo NDC (uv 1, 1 u hi, v hi 8

Window to Viewport Mapping Window to Viewport Mapping 2 Given (, in world, what is its (u,v in ndc? Consider the coordinate first Let S be the width of the window = hi - lo Let S u be the width of the viewport = u hi - u lo what of the wa from lo to hi is? ratio = ( - lo / S it is eactl that of the wa from u lo to u hi in ndc: uratio = ( u - u lo / S u so, ( u - u lo / S u = ( - lo / S or, u = u lo + ( - lo / S * S u Similarl, v = v lo + ( - lo / S * S v u = u lo + ( - lo / S * S u v = v lo + ( - lo / S * S v lo, lo - lo World Coordinates + S S hi, hi u lo, u lo u-u lo NDC + S u 1, 1 u hi, v hi S v 9 10 Clipping What if (, is outside the window? it should not be visible in the viewport cant just ignore a point outside window; its part of a line or polgon or more comple object must displa onl the portion of each object that is inside the window must do it efficientl well re-visit clipping later 2D Transformations Wed like to define an object with 1 set of coordinate specifications, then transform it to another location, size, and/or orientation. Translation b (d, d Scale b (s, s Rotation b α about the origin (0,0 11 12

2D Translation 2D Scale Translation b ( d, d for each (, in the object = + d ; = + d for each (, in the object = * s; = * s 3*s, 3*s 2*s, 2*s d 3, 3 2, 2 1*s, 1*s d 1, 1 CS770/870 Fall 2014 Bergeron 13 14 2D Rotation 2D Ais Ordering Conventions Rotation of α degrees about the origin, where α > 0 is counter clockwise rotation = cos α - sin α = sin α + cos α Note: equations onl make sense if the aes labels are known If we sa the aes are labeled, we assume that is horizontal, increasing to the right, and is vertical increasing upward It s pure convention What is a positive angle? if aes are, an angle >0 rotates -ais towards another convention. v coord sstem uv coord sstem u coord sstem 15 16

Affine Transformations Affine transformations leave the origin (0,0 unchanged Scale and rotation are affine transformations Translation is not affine 2D affine transformations can be elegantl represented in matri format as 22 matrices unifies the representation of scale and rotation provides an eas implementation of composition of transformations: rotate, then scale, then rotate Linear Algebra Linear algebra isn t scar: it s notation. Consider the 2 linear equations on the right The meaning of the equations is all in the constants (a,b,c,d; the variables (u,v,, are just placeholders. We encapsulate the constants in a 22 matri and the variables as 21 vectors. u = a + b v = c + d " u v " a c " b d 17 18 Linear Algebra Operators To utilize this notation efficientl, we can define some operators on matrices and vectors: Multiplication of a matri times a vector let s us recover the underling equations The dot product (also called inner product let s us combine 2 vectors into a scalar; it s definition leads to convenient computations of vector lengths and the angle between two vectors The cross product (outer product let s us easil compute a new vector that is orthogonal to 2 vectors Dot (inner Product Given two vectors of the same length, the dot product is the sum of the products of corresponding entries: " a b " a+b which reall should be written as a row vector * a column vector " a b " a+b 19 20

Matri times a vector Consider the 22 matri and a 21 vector: " a b " c d The product of the matri * vector is defined as " a + b c + d Each entr is the dot product of a row of the input matri with the input vector (thus the row*col form of the dot product definition 21 " Matri times Matri The row/column dot product convention etends to matri products: Row i of the left operand is dotted with column j of the right operand to get position (i,j in the result: a c b d r s " t u " ar + bt as + bu cr + dt cs + du All this etends easil to 3D and more 22 Matrices for Affine Transforms Matri Multiplication Scale: = S, = S " S 0 0 S Rotation: = cos α - sin α, = sin α + cos α cosα sinα sinα cosα ( " 0 1 ais (1,0 ais (0,1 ais (0,1 - ais (-1,0 1 0 Assumes aes are labeled. +90 rotation: cos 90 = 0, sin 90 = 1 23 Matri multiplication is just a series of matrivector multiplications Each column of the right hand matri is multiplied b the left to get the net column of result a b u * " c d " w au + bw a + b " cu + dw c + d Matri multiplication is associative (M1 * (M2 * V = (M1 * M2 * V 24

Transformation Composition Suppose ou want to scale an object b ( s, t, then rotate b α degrees Create S and R matrices Let M = R*S foreach point in object, p newp = M * p Simpler and more efficient than first transforming all points b S and then transforming the results b R. Wh? Are Affine Transforms Smmetric? Given two affine transforms, M 1 and M 2 Does M 1 * M 2 = M 2 * M 1? Consider S = scale b ( 1, 2, R = rotate b 90 Does S*R = R*S Surel, not. What about 2 rotations? es (in 2D, but not 3D What about 2 scales? es Rotation and uniform scale? es 25 26 THE Problem Translation is not affine but we cant live without it How can we combine translation with scale and rotate into one unified model? Homogeneous coordinates Well present it as a convenient engineering trick There is a rigorous mathematical eplanation 27 Translation Transformation = + d, = + d Consider the 33 matri and the 31 vector: " 1 0 d 0 1 d 0 0 1 " 1 The product of this matri times the vector is: " + d + d 1 Its just what we want (if we ignore the etra coord But what about scale and rotation? 28

Revised Scale/Rotate Matrices Epand the Scale and Rotate matrices to 33 " S 0 0 0 S 0 0 0 1 cosα sinα 0 sinα cosα 0 0 0 1( You should verif that multipling these matrices b [ 1] produce same results as before. Homogeneous Coordinates The 33 matri representation for 2D transformations is called homogeneous coordinates The 3rd coordinate is called the homogeneous coordinate and is usuall designated with a w In this model, rotation, scale and translation can be represented in a single uniform notation and can be composed in arbitrar order 29 30 Wh does it work? There is a comple mathematical eplanation and an intuitive geometric one. 2D Shear Transform Shear of b a factor of : = + *h turns a rectangle into a parallelogram Which do ou want? Shear of b a factor of : = + * h similar result 31 32

What is a 2D shear in 1D? Suppose ou represent all our objects with =1; this becomes a 1D world with scale and translation operations. A 2D shear becomes a 1D translation at =1 =1 Similarl, a 3D shear at w=1 is a 2D translation in the w=1 plane 33 2D Shear Matri 22 shear matri " 1 h h 1 33 homogeneous shear matri for 2D shear " 1 h 0 h 1 0 0 0 1 Verif that these are correct 34 3D Shear Matri A complete 3D shear matri is " 1 h h z h 1 h z h z h z 1 " 1 0 h w 0 1 h w 0 0 1 But, when we use the matri as a 2D homogeneous matri, all the factors ecept h z and h z are 0 and those should be renamed as h w and h w or even d, d " 1 0 d 0 1 d 0 0 1 35 Scale/Rotation about a Point Scale/Rotation leave the origin fied we sa that the occur about the origin Often, want the transformation to occur about an arbitrar point, perhaps the objects center Can do this with a composite transformation that: translates the desired center point to the origin applies the scale or rotate (or both translates the origin back to the original center point The composite is applied to all points 36

Arbitrar Rotation Rotate b α about (c, c T(-c, -c : Translate (c, c to ( R(α: Rotation b α T(c, c : Translate ( to (c, c (c, c T(-c, -c R(α T(c, c (c, c Arbitrar Rotation Matrices Rotate b α about (c, c T 1, Translate (c, c to ( R, Rotation T 2, Translate ( to (c, c Composite C = T 2 RT 1 for each point P: P= CP 1 0 c ( T 1 = 0 1 c ( 0 0 1 ( cosα sinα 0 R = sinα cosα 0 0 0 1( " 1 0 c T 2 = 0 1 c 0 0 1 37 38 Multiplication Eercise Review/Preview C=T 2 RT 1 1. T 2 *R r 0 *c 0 r 0 *c 1 r 0 *c 2 etc 2. (T 2 R*T 1 " 1 0 c " cosα sinα 0 " 1 0 c C = 0 1 c sinα cosα 0 0 1 c 0 0 1 0 0 1 0 0 1 cosα sinα c 1 0 c = sinα cosα c 0 1 c 0 0 1 ( 0 0 1 ( cosα sinα c cosα + c sinα + c = sinα cosα c sinα c cosα + c 0 0 1 ( Review Coordinate sstems 2D Transformations Homogeneous coordinates Matrices, vectors, points Preview 3D Transformations Homogeneous coords Matrices, vectors, points 39 40