1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.

Slides:



Advertisements
Similar presentations
Computer Graphics 2D & 3D Transformation.
Advertisements

MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
CLASS 4 CS770/870. Translation Scale Multiplying Matrices. The R C rule What happens when we do two translates? What happens when we do two scales?
Computer Graphics Lecture 4 Geometry & Transformations.
Geometric Transformations
CMPE 466 COMPUTER GRAPHICS
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Transformations III Week.
Math 1Hofstra University – CSC171A1 Modeling Objects by Polygonal Approximations Define volumetric objects in terms of surfaces patches that surround the.
Transformations II Week 2, Wed Jan 17
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations II Week.
2D Geometric Transformations
2/7/2001Hofstra University – CSC290B1 Review: Math (Ch 4)
Modeling Objects by Polygonal Approximations
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.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Transformations III Week.
OpenGL (II). How to Draw a 3-D object on Screen?
CSC 123 – Animating characters Hierarchical modeling Zoë Wood.
2IV60 Computer Graphics 2D transformations
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
CS 450: Computer Graphics 2D TRANSFORMATIONS
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
Hierarchical Transformations Hierarchical Models Scene Graphs
Transformations of Objects CVG lab. Introduction  Affine transformations : Affine transformations are a fundamental cornerstone of computer graphics.
Transformations Dr. Amy Zhang.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.
2003CS Hons RW778 Graphics1 Chapter 5: Transforming Objects 5.2 Introduction to Transformations 5.2 Introduction to Transformations –Affine transformations.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Geometric transformations The Pipeline
Transforms Hierarchical Modeling Scene Graphs Using hierarchical modeling techniques in 3D software design Transforms Local basis Matrix math review Matrices.
Week 4 Lecture 1: Hierarchical Modeling Part 1 Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E ©
Hierarchical Modeling. Instance Transformation Start with a prototype object (a symbol) Each appearance of the object in the model is an instance – Must.
CS559: Computer Graphics Lecture 15: Hierarchical Modeling and Shading Li Zhang Spring 2008.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
OpenGL: Introduction Yanci Zhang Game Programming Practice.
Transformations Tutorial
Computer Graphics I, Fall 2010 OpenGL Transformations.
2 COEN Computer Graphics I Evening’s Goals n Discuss viewing and modeling transformations n Describe matrix stacks and their uses n Show basic geometric.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
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.
CS559: Computer Graphics Lecture 13: Hierarchical Modeling and Curves Li Zhang Spring 2010.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
The Modelview Stack Lecture 9 Wed, Sep 12, The Modelview Stack OpenGL maintains a stack of matrices. The matrix on top of the stack is the current.
Transformations Introduction to Computer Graphics and Animation
Summary of Properties of 3D Affine Transformations
Transformation and Viewing
Computer Graphics - Hierarchical Models-
CSCE 441: Computer Graphics: Hierarchical Models
Unit-5 Geometric Objects and Transformations-II
Chapter 4/5 glMatrixMode Modeling Transformations glTranslate glScale
Transformations IV Week 3, Wed Jan 20
Transformations 4 University of British Columbia
Transformations 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Transformations in OpenGL
Geometric Objects and Transformations (II)
Transformations III Week 3, Mon Jan 21
Transformations IV Week 3, Wed Jan 23
Hierarchical Modeling
CSCE 441: Computer Graphics: Hierarchical Models
Presentation transcript:

1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms

2/50 © Louie Psihoyos

3/50 Rotate glRotatef(angle,ax,ay,az)

4/50 Translate glTranslatef(tx,ty,tz)

5/50 Scale Uniform Nonuniform glScalef(sx,sy,sz)

6/50 Transformations What? Just functions acting on points (x’,y’,z’) = T(x,y,z) P’ = T(P) Why? Viewing ■ Window coordinates to framebuffer coordinates ■ Virtual camera: parallel/perspective projections Modeling ■ Create objects in convenient coordinates ■ Multiple instances of a prototype shape ■ Kinematics of linkages/skeletons - characters/robots

7/50 Scale

8/50 Scale

9/50 Reflection

10/50 Shear

11/50 Linear Transform = Matrices

12/50 Lines Map to Lines→ Linear Transform →

13/50 Non-Linear Transform! Lines Map to Curves

14/50 Parametric Form of a Line

15/50 Linear Transform→ Lines Map to Lines Start with the parametric form of a line Transform all the points on the line Thus, a line transforms into a linear combination of transformed points, which is a line

16/50 Coordinate System An origin o and two unit vectors x, y define a frame of reference

17/50 Points are Defined wrt to the Frame

18/50 Coordinate Frames Can interpret the columns of the matrix as the x and y axes that define the frame

19/50 Rotation Matrix?

20/50 Rotation Matrix Setting the columns of the matrix to the x and y axes creates the transform from that frame

21/50 Rotation Matrix

22/50

23/50 Translate??

24/50 Solution: Homogenous Coordinates

25/50 Vectors

26/50 Composing Transformations

27/50 Rotate, Then Translate R(45) T(1,1) R(45)

28/50 Translate, Then Rotate T(1,1) R(45) T(1,1)

29/50 Order Matters R(45) T(1,1)T(1,1) R(45) ≠

30/50 Rotate 45 about the Center (1,1)?

31/50 Rotate (1,1) T(-1,-1) ⇒ ⇓ T(1,1) R(45) T(-1,-1) ⇒ ⇑ R(45) T(1,1)

32/50 Order of Transformations The rightmost transform is applied first P’ = T(1,1) (R(45)(P)) That is, the rotate is applied before the translate OpenGL glTranslatef( 1.0, 1.0, 0.0 ); glRotatef( 45.0, 0., 0., 1. ); The last gl call is applied first; we’ll see why later

33/50 Advantages of the Matrices Combine a sequence of transforms into a single transform P’ = A ( B ( C ( D ( p ) ) ) ) = ( A B C D ) P = M P Why? Matrix multiplication is associative Advantages ■ Very inefficient to recompute the matrix entries ■ Very inefficient to multiply matrix times point multiple times ■ Compute the matrix M once and then apply that matrix to many points

34/50 Transforming Points vs. Transforming Coordinate Systems

35/50 Transforming the Coordinate System T(1,1) R(45) T(1,1) Transforms are defined wrt the Global/World C.S. R(45) T(1,1) R(45)

36/50 Transforming the Coordinate System T(1,1) T(1,1) R(45) R(45) R(45) T(1,1) Transforms are defined wrt the Local/Object C.S.

37/50 Two Interpretations are Equivalent T(1,1) R(45) T(1,1) R(45) R(45) T(1,1) World: Read right to leftObject: Read left to right

38/50 Two Interpretations are Equivalent R(45) T(1,1) R(45) T(1,1) T(1,1) R(45) World: Read right to leftObject: Read left to right

39/50 Two Interpretations are Equivalent R(45) T(1,1) R(45) T(1,1) T(1,1) R(45) World: Read right to leftObject: Read left to right Object way will be very useful when creating hierarchies

40/50 Hierarchical Transformations

41/50 Skeleton body torso head shoulder larm upperarm lowerarm hand rarm upperarm lowerarm hand hips lleg upperleg lowerleg foot rleg upperleg lowerleg foot

42/50 Skeletons and Linkages 1. Skeleton represents the hierarchy of an assembly of parts - The arm is made of an upper arm and a lower arm - Different parts may have the same shape, i.e. are “geometric instances” 2. Parts connected by joints - “The ankle joint is connected to the knee joint” - Different types of joints move differently e.g. a ball and socket joint, a linear actuator

43/50 How Linkages Work Lower levels of the hierarchy move when the upper levels moves ■ e.g. moving the left shoulder moves the left arm and the left hand Motion in one sub-tree does not effect the position of a part in another sub-tree ■ e.g. moving the left hand does not effect the right hand

44/50 Pat Hanrahan, Fall 2011 Skeleton Text translate(0,4,0); torso(); pushmatrix(); translate(0,3,0); shoulder(); pushmatrix(); rotatey(necky); rotatex(neckx); head(); popmatrix(); pushmatrix(); translate(1.5,0,0); rotatex(lshoulderx); upperarm(); pushmatrix(); translate(0,-2,0); rotatex(lelbowx); lowerarm();... popmatrix();... translate(0,4,0); torso(); pushmatrix(); translate(0,3,0); shoulder(); pushmatrix(); rotatey(necky); rotatex(neckx); head(); popmatrix(); pushmatrix(); translate(1.5,0,0); rotatex(lshoulderx); upperarm(); pushmatrix(); translate(0,-2,0); rotatex(lelbowx); lowerarm();... popmatrix();...

45/50 OpenGL

46/50 Current Transformation Matrix OpenGL maintains a current transformation matrix (CTM). All geometry is transformed by the CTM. Transformation commands are concatenated onto the CTM on the right. CTM *= T This causes T to be applied before the old CTM

47/50 OpenGL Matrix Functions glLoadIdentity( ) ■ Set the transform matrix to the identity matrix glLoadMatrix( matrix M ) ■ Replace the transform matrix with M glMultMatrix( matrix M ) ■ Multiplies transform matrix by CTM * M ■ glRotate, glTranslate, glScale etc. are just wrappers for glMultMatrix

48/50 Graphics Coordinate Frames Object ■ Raw values as provided by glVertex (ex. teacup centered at origin) World ■ Object at final location in environment (ex. teacup recentered to be on top of a table) Screen ■ Object at final screen position

49/50 OpenGL Matrix Functions glMatrixMode( mode ) ■ Sets which transformation matrix to modify ■ GL_MODELVIEW: object to world transform ■ GL_PROJECTION: world to screen transform ■ CTM = GL_PROJECTION * GL_MODELVIEW Why? May need to transform by one of these matrices for certain calculations like lighting. More on this latter.

50/50 OpenGL Matrix Stack Save and restore transformations glPushMatrix ( ) ■ Pushes the current matrix onto the top of the matrix stack glPopMatrix ( ) ■ Pops the matrix off the top of the matrix stack and loads it as the current matrix