2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.

Slides:



Advertisements
Similar presentations
Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
Advertisements

Geometric Transformations
25 May May May 2015Week 5-2D Transformations1 2D Transformations By: KanwarjeetSingh.
CMPE 466 COMPUTER GRAPHICS
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Transformations Objectives Understand how transformations work in 2D and 3D Understand the concept of homogenous coordinate system Understand scene graphs.
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 OpenGL Transformations Ed Angel Professor of Computer Science, Electrical and Computer.
Rotations and Translations. Representing a Point 3D A tri-dimensional point A is a reference coordinate system here.
2IV60 Computer Graphics 2D transformations
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.
CAP4730: Computational Structures in Computer Graphics
COMP 175: Computer Graphics March 10, 2015
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.
And an introduction to matrices COORDINATE SYSTEMS JEFF CHASTINE 1.
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.
2D Transformations.
Geometric Transforms Changing coordinate systems.
Geometric Transformations Jehee Lee Seoul National University.
Part7: Geometric Transformations
Rotations and Translations 1. Mathematical terms The inner product of 2 vectors a,b is defined as: The cross product of 2 vectors is defined as: A unit.
Geometric Transformations
Week 4 Lecture 1: Hierarchical Modeling Part 1 Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E ©
Geometry: 2-D Transformations Course web page: Chapter #3.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
1 Computer Graphics Week9 -3D Geometric Transformation.
Viewing CS418 Computer Graphics John C. Hart. Graphics Pipeline Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords.
Computer Graphics I, Fall 2010 OpenGL Transformations.
1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Geometric Transformations
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Affine Transformation. Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
Geometric Transformations UBI 516 Advanced Computer Graphics Aydın Öztürk
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Hierarchical Modeling.
CS552: Computer Graphics Lecture 4: 2D Graphics. Recap 2D Graphics Coordinate systems 2D Transformations o Translation o Scaling o Rotation Combining.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
1 OpenGL Transformations. 2 Objectives Learn how to carry out transformations in OpenGL ­Rotation ­Translation ­Scaling Introduce OpenGL matrix modes.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
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.
CSCE 441 Computer Graphics: 2D Transformations
Transformations. Transformations Introduce standard transformations ◦ Rotation ◦ Translation ◦ Scaling ◦ Shear Derive homogeneous coordinate transformation.
Robotic Arms and Matrices By Chris Wong and Chris Marino.
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360/4360.
OpenGL Transformations
OpenGL Transformations
OpenGL Transformations
Computer Graphics OpenGL Transformations
Introduction to Computer Graphics with WebGL
OpenGL Transformations
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Transformations in OpenGL
2D/3D Transformations User Interfaces.
Geometric Objects and Transformations (II)
OpenGL Transformations
OpenGL Transformations
Hierarchical Modeling
Presentation transcript:

2D Transformations

World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together

Transformations Rigid Body Transformations - transformations that do not change the object. Translate –If you translate a rectangle, it is still a rectangle Scale –If you scale a rectangle, it is still a rectangle Rotate –If you rotate a rectangle, it is still a rectangle

Vertices We have always represented vertices as (x,y) An alternate method is: Example:

Matrix * Vector

Matrix * Matrix Does A*B = B*A? NO What does the identity do? AI=A

Translation Translation - repositioning an object along a straight-line path (the translation distance) from one coordinate location to another. (x,y)(x,y) (x’,y’) (t x,t y )

Translation Given: We want: Matrix form:

Translation Examples P=(2,4), T=(-1,14), P’=(?,?) P=(8.6,-1), T=(0.4,-0.2), P’=(?,?) P=(0,0), T=(1,0), P’=(?,?)

Recall A point is a position specified with coordinate values in some reference frame. We usually label a point in this reference point as the origin. All points in the reference frame are given with respect to the origin.

Applying to Triangles (t x,t y )

What do we have here? You know how to:

Scale Scale - Alters the size of an object. Scales about a fixed point (x,y)(x,y) (x’,y’)

Scale Given: We want: Matrix form:

Non-Uniform Scale (x,y)(x,y) (x’,y’) S=(1,2)

Rotation Rotation - repositions an object along a circular path. Rotation requires an  and a pivot point 

Rotation

Example P=(4,4)  =45 degrees

Rotations V(-0.6,0) V(0,-0.6) V(0.6,0.6) Rotate -30 degrees V(0,0.6) V(0.3,0.9) V(0,1.2)

Combining Transformations Q: How do we specify each transformation?

Specifying 2D Transformations Translation –T(t x, t y ) –Translation distances Scale –S(s x,s y ) –Scale factors Rotation –R(  ) –Rotation angle

Combining Transformations Using translate, rotation, and scale, how do we get:

Combining Transformations Note there are two ways to combine rotation and translation. Why?

Let’s look at the equations

Combining them We must do each step in turn. First we rotate the points, then we translate, etc. Since we can represent the transformations by matrices, why don’t we just combine them?

2x2 -> 3x3 Matrices We can combine transformations by expanding from 2x2 to 3x3 matrices.

Homogenous Coordinates We need to do something to the vertices By increasing the dimensionality of the problem we can transform the addition component of Translation into multiplication.

Homogenous Coordinates Homogenous Coordinates - term used in mathematics to refer to the effect of this representation on Cartesian equations. Converting a pt(x,y) and f(x,y)=0 -> (x h,y h,h) then in homogenous equations mean (v*x h,v*y h,v*h) can be factored out. What you should get: By expressing the transformations with homogenous equations and coordinates, all transformations can be expressed as matrix multiplications.

Final Transformations - Compare Equations

Combining Transformations

How would we get:

Coordinate Systems Object Coordinates World Coordinates Eye Coordinates

Object Coordinates

World Coordinates

Screen Coordinates

Coordinate Hierarchy

Let’s reexamine assignment 1

Transformation Hierarchies (See chapter 10 for details) For example, a robot arm

Transformation Hierarchies Let’s examine:

Transformation Hierarchies What is a better way?

Transformation Hierarchies What is a better way?

Transformation Hierarchies We can have transformations be in relation to each other World Coordinates Upper Arm Coordinates Lower Arm Coordinates Hand Coordinates Transformation: Upper Arm -> World Transformation: Lower -> Upper Transformation: Hand-> Lower

44 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rotation about a Fixed Point Start with identity matrix: C  I Move fixed point to origin: C  CT Rotate: C  CR Move fixed point back: C  CT -1 Result: C = TR T –1 which is backwards – Cp This result is a consequence of doing postmultiplications. Let’s try again.

45 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Reversing the Order We want C = T –1 R T so we must do the operations in the following order C  I C  CT -1 C  CR C  CT Each operation corresponds to one function call in the program. Note that the last operation specified is the first executed in the program

46 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Example Rotation about z axis by 30 degrees with a fixed point of (1.0, 2.0, 3.0) Remember that last transform specified in the program is the first applied glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(1.0, 2.0, 3.0); glRotatef(30.0, 0.0, 0.0, 1.0); glTranslatef(-1.0, -2.0, -3.0); glBegin(GL_TRIANGLES);...

47 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Matrix Stacks In many situations we want to save transformation matrices for use later –Traversing hierarchical data structures (Chapter 10) –Avoiding state changes when executing display lists OpenGL maintains stacks for each type of matrix –Access present type (as set by glMatrixMode) by glPushMatrix() glPopMatrix()