Geometric Transforms Changing coordinate systems.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Transformations Ed Angel Professor Emeritus of Computer Science
Computer Graphics Lecture 4 Geometry & Transformations.
Geometric Transformations
Transformations II Week 2, Wed Jan 17
2D Geometric Transformations
Image Warping : Computational Photography Alexei Efros, CMU, Fall 2006 Some slides from Steve Seitz
Linear Algebra and SVD (Some slides adapted from Octavia Camps)
CS5500 Computer Graphics March 22, Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Coordinate-Free Geometry When we learned simple.
Image Warping : Computational Photography Alexei Efros, CMU, Fall 2008 Some slides from Steve Seitz
3-D Geometry.
Now Playing: Gong Sigur Rós From Takk... Released September 13, 2005.
Math for CSLecture 11 Mathematical Methods for Computer Science Lecture 1.
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Introduction to Computer Graphics CS 445 / 645 Lecture 5 Transformations Transformations M.C. Escher – Smaller and Smaller (1956)
CAP4730: Computational Structures in Computer Graphics
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Mathematical Fundamentals
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
C O M P U T E R G R A P H I C S Stuff CMSC 435 / 634 Transformations 1/29 Geometric Transformations Readings: Chapters 5-6.
Mathematical Topics Review of some concepts:  trigonometry  aliasing  coordinate systems  homogeneous coordinates  matrices, quaternions.
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
Lecture Notes: Computer Graphics.
Geometric Transformations Jehee Lee Seoul National University.
Intro to 3D Models Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Transformations Jehee Lee Seoul National University.
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
Geometric Objects and Transformation
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Geometric Transformations
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Multimedia Programming 07: Image Warping Keyframe Animation Departments of Digital Contents Sang Il Park.
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
January 19, y X Z Translations Objects are usually defined relative to their own coordinate system. We can translate points in space to new positions.
Affine Geometry.
Computer Graphics Matrices
1 Representation. 2 Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames.
Recap from Monday DCT and JPEG Point Processing Histogram Normalization Questions: JPEG compression levels Gamma correction.
III- 1 III 3D Transformation Homogeneous Coordinates The three dimensional point (x, y, z) is represented by the homogeneous coordinate (x, y, z, 1) In.
Geometric Transformations. Transformations Linear transformations Rigid transformations Affine transformations Projective transformations T Global reference.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Computer Graphics I, Fall 2010 Transformations.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Transformations Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Image Warping 2D Geometric Transformations
Modeling Transformation
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Objectives Introduce standard transformations Introduce standard transformations Derive homogeneous coordinate transformation matrices Derive homogeneous.
Math Fundamentals Maths revisit.
Computer Graphics CC416 Week 15 3D Graphics.
Computer Graphics Transformations.
2D Transformations with Matrices
Computer Graphics Transformations.
Introduction to Computer Graphics CS 445 / 645
Lecture 2 Transformations
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
3D Transformation CS380: Computer Graphics Sung-Eui Yoon (윤성의)
Transformations 2 University of British Columbia
Presentation transcript:

Geometric Transforms Changing coordinate systems

The plan Describe coordinate systems and transforms Introduce homogeneous coordinates Introduce numerical integration for animation Later: – camera transforms – physics – more on vectors and matrices

World Coordinates Objects exist in the world without need for coordinate systems But, describing their positions is easier with a frame of reference “ World ” or “ object-space ” or “ global ” coordinates

Screen vs World Coordinates Some objects only exist on the screen – mouse pointer, “ radar ” display, score, UI elements Screen coordinates typically 2D Cartesian – x, y Objects in the world also appear on the screen – need to project world coordinates to screen coordinates – camera transform

Coordinate Transforms A Cartesian coordinate system has three things: an origin – reference point measurements are taken from axes – canonical directions scale – meaning of units of distance

Types of transforms Translation – moving in a fixed position Rotation – changing orientation Scale – changing size All can be viewed either as affecting the model or as affecting the coordinate system

Changing coordinate systems Translation: changing the origin of the coordinate system (0,0) (5,13) (2,12)

Changing coordinate systems Rotation: changing the axes of the coordinate system (0,0) (5,5) (7,1)

Changing coordinate systems Scaling: changing the units of the coordinate system (0,0) (4,4) (8,8)

Matrix Transforms For "simplicity"s sake, we want to represent our transforms as matrix operations Why is this simple? – single type of operation for all transforms – IMPORTANT: collection of transforms can be expressed as a single matrix efficiency

Scaling If we express our 2D coordinates as (x,y), scaling by a factor a multiplies each coordinate: so (ax, ay) Can write as a matrix multiplication: a0 0b x y ax by =

Scaling Syntax Matrix.CreateScale( s ); – scalar argument s describes amount of scaling alternatively, Matrix.CreateScale( v ); – vector argument v describes scale amount in x y z

Rotation Similarly, rotating a point by an angle θ: – (x,y)  (x cos θ - y sin θ, x sin θ + y cos θ) cos θ-sin θ sin θcos θ x y x cos θ – y sin θ x sin θ + y cos θ =

Rotation Syntax Matrix.CreateRotationZ(angle) Note, specify the axis about which the rotation occurs – also have CreateRotationX, CreateRotationY argument is angle of rotation, in radians

Translation Translating a point by a vector involves a vector addition: – (x,y) + (s,t) = (x+s, y+t)

Translation Translating a point by a vector involves a vector addition: – (x,y) + (s,t) = (x+s, y+t) Problem: cannot compose multiplications and additions into one operation

Coordinate Transforms Scaling: p ’ = Sp Rotation: p ’ = Rp Translation: p ’ = t + p Problem: Translation is treated differently.

Homogeneous Coordinates Add an extra coordinate w 2D point written (x,y,w) Cartesian coordinates of this point are (x/w, y/w) – w=0 represents points at infinity and should be avoided if representing location [Aside: w=0 also used to represent vector, e.g., normal] – in practice, usually have w=1

Translation now (x,y,1) + (s,t,0) = (x+s,y+t, 1) 10s 01t 001 x y 1 x+s y+t 1 =

Composing Translations 10s1s1 01t1t s2s2 01t2t s 1 +s 2 01t 1 +t =

Translation Syntax Matrix.CreateTranslation( v ); – vector v is the translation vector Also, Matrix.CreateTranslation( x, y, z); – x, y, z are scalars (floats)

Composing Transformations Rotation, scale, and translate are all matrix multiplications We can compose an arbitrary sequence of transformations into one matrix C = T 0 T 1 … T n-1 T n Remember – order matters In XNA, later transforms are added on the right

Kinds of Transformations Rigid transformations – composed of only rotations and translations – preserve distances between points Affine transformations – include scales – preserve parallelism of lines – distances and angles might change

More on Rotations R matrix we wrote allows rotation about origin Usually, origin and point of rotation do not coincide

More on Rotations Want to rotate about arbitrary point How to achieve this?

More on Rotations Want to rotate about arbitrary point How to achieve this? Composite transform – first translate to origin – next, rotate desired amount – finally, translate back – C = T -1 RT

More on Order of Operations AB != BA in general But, AB = BA if: – A is translation, B is translation – A is scale, B is scale – A is rotation, B is rotation – A is rotation, B is scale (that preserves aspect ratio) All in two dimensions, note Like transforms commute

ISROT ISROT: a mnemonic for the order of transformations – Identity: gets you started – Scale: change the size of your model – Rotation: rotate in place – Orbit: rotate about an external point first translate then rotate (about origin) – Translation: move to final position

3D transforms Translation same as in 2D – use 4D homogeneous coordinates x,y,z,w Scaling same as 2D For rotation, need to specify axis – unique in 2D, but different possibilities available in 3D – can represent any 3D rotation by a composition of rotations about axes

Transforming objects So far, talked about transforming points How about objects? Lines get transformed sensibly with transforms on endpoints Polygons same, mutatis mutandis

Hierarchical Models Many times, structures (and models) will be built as a hierarchy: Body Arm Other limbs... Hand Thumbother fingers...

Transforms on Hierarchies Transforms applied to nodes higher in the hierarchy are also applied to lower nodes – parent transforms propagate to children How to achieve this? Simple: multiply your transform with your parent's transform May want a stack for hierarchy management – push transform on descending – pop when current node finished

Transforms on Hierarchies pseudocode for computing final transform: applyWorld = myWorld * parentWorld; applyWorld is the final transform myWorld is the local transform parentWorld is the parent node's transform The power of matrix transforms! Complex hierarchical models can be expressed simply.

Moving objects Want to get things to move Can adjust transform parameters – translation amount – rotation, orbit angles Just incorporate changes into Update() Need to do this in a disciplined way

Speed  position If we know – where an object started – how fast it is moving (and the direction) – and how much time has passed we can figure out where it is now x(t + dt) = x(t) + v(t)dt Numerical integration!

Euler integration Assumes constant speed within a timestep – still gives an answer if speed changes, but answer might be wrong x(t + dt) = x(t) + v(t)dt "Explicit integration" Most commonly used in graphics/game applications

Implementation Time available in Update as gameTime object.position += object.velocity * gameTime.ElapsedGameTime.TotalSeconds; – if speed expressed in distance units per second – assumes that position and velocity are vectors – may have some way of updating velocity physics, player control, AI,... Similar approach for angle updates (need angular velocity)

Recap How to use world transformations – scale, rotate, translate Use of homogeneous coordinates for translation Order of operations – ISROT Animation and Euler integration

Future lectures matrix and vector math camera transformations illumination and texture particle systems – linear physics