Modeling Transformations Mario Costa Sousa University of Calgary CPSC 453, Fall 2001 Mario Costa Sousa University of Calgary CPSC 453, Fall 2001.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Vector Calculus Mengxia Zhu Fall Objective Review vector arithmetic Distinguish points and vectors Relate geometric concepts to their algebraic.
University of North Carolina at Greensboro
Math 1Hofstra University – CSC171A1 Modeling Objects by Polygonal Approximations Define volumetric objects in terms of surfaces patches that surround the.
1 Geometrical Transformation 2 Outline General Transform 3D Objects Quaternion & 3D Track Ball.
University of North Carolina at Greensboro
Based on slides created by Edward Angel
2/7/2001Hofstra University – CSC290B1 Review: Math (Ch 4)
CS 4731: Computer Graphics Lecture 7: Introduction to Transforms, 2D transforms Emmanuel Agu.
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.
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter Vector Tools for Graphics.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 OpenGL Transformations Ed Angel Professor of Computer Science, Electrical and Computer.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
10/5/04© University of Wisconsin, CS559 Fall 2004 Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 3 due Oct 12 in class.
Vectors Tools for Graphics.  To review vector arithmetic, and to relate vectors to objects of interest in graphics.  To relate geometric concepts to.
Transformations of Objects CVG lab. Introduction  Affine transformations : Affine transformations are a fundamental cornerstone of computer graphics.
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.
Transformations Dr. Amy Zhang.
Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Raster Devices Transformations Areg Sarkissian.
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.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Intro to 3D Models Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Geometric Transformations
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Geometric Objects and Transformation
10/3/02 (c) 2002 University of Wisconsin, CS 559 Last Time 2D Coordinate systems and transformations.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 52 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 52 Computer Graphics Three-Dimensional Graphics I.
Background Mathematics Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006.
CAP 4730 Computer Graphic Methods Prof. Roy Levow Chapter 4.
Computer Graphics I, Fall 2010 OpenGL Transformations.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Subject Name: Computer Graphics Subject Code: Textbook: “Computer Graphics”, C Version By Hearn and Baker Credits: 6 1.
Transformations Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
CS552: Computer Graphics Lecture 4: 2D Graphics. Recap 2D Graphics Coordinate systems 2D Transformations o Translation o Scaling o Rotation Combining.
Transformations of objects
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
1 OpenGL Transformations. 2 Objectives Learn how to carry out transformations in OpenGL ­Rotation ­Translation ­Scaling Introduce OpenGL matrix modes.
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 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.
Chapter 1 Graphics Systems and Models Models and Architectures.
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Graphics Graphics Korea University kucg.korea.ac.kr Geometric Primitives 고려대학교 컴퓨터 그래픽스 연구실.
Transformations. Transformations Introduce standard transformations ◦ Rotation ◦ Translation ◦ Scaling ◦ Shear Derive homogeneous coordinate transformation.
4. Geometric Objects and Transformations
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Rendering Pipeline Fall, 2015.
Summary of Properties of 3D Affine Transformations
3D Transformations Source & Courtesy: University of Wisconsin,
CSC461: Lecture 19 Computer Viewing
Unit-5 Geometric Objects and Transformations-II
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Transformations in OpenGL
Geometric Objects and Transformations (II)
Presentation transcript:

Modeling Transformations Mario Costa Sousa University of Calgary CPSC 453, Fall 2001 Mario Costa Sousa University of Calgary CPSC 453, Fall 2001

3D object RENDERING ANIMATION MODELING 2D image IMAGE PROCESSING ~44% ~4% ~8% representation : ~9% IMAGING 10% (~ 35%)

1.INTRODUCTION 2.IMAGING 3.3D RENDERING OVERVIEW 4.MODELING (1) shapes and transformations 1.Modeling Transformations 2.Overview of 3D Object Representation 5.RENDERING (1, 2, 3, 4) 6.MODELING (2) 7.ANIMATION 8.TOPICS 1.INTRODUCTION 2.IMAGING 3.3D RENDERING OVERVIEW 4.MODELING (1) shapes and transformations 1.Modeling Transformations 2.Overview of 3D Object Representation 5.RENDERING (1, 2, 3, 4) 6.MODELING (2) 7.ANIMATION 8.TOPICS CPSC 453 – Computer Graphics I

3D Scene Representation Approximated by 3D primitives PointPoint Line segmentLine segment PolygonPolygon Curved surfaceCurved surface Solid objectSolid object etc.etc.

3D Rendering Pipeline Object definition Compose scene Define view reference Define lighting Cull Clip to 3D view volume Hidden surface removal RasterizationShading Local coordinate space World coordinate space View space 3D screen space Display space Modeling transformation View transformation 1.INTRODUCTION 2.IMAGING 3.3D RENDERING OVERVIEW 4.MODELING (1) shapes and transformations 1.Modeling Transformations 2.Overview of 3D Object Representation 5.RENDERING (1, 2, 3, 4) 6.MODELING (2) 7.ANIMATION 8.TOPICS

Modeling Transformations Readings Chapter 1 – Mathematical fundamentals of computer graphics Chapter 2 – Representation and modeling of three-dimensional objects (1) Chapter 2 – State management and drawing geometric objects Appendix F – Homogeneous coordinates and transformation matrices

Vector Tools for GraphicsVector Tools for Graphics Transformations of ObjectsTransformations of Objects Vector Tools for GraphicsVector Tools for Graphics Transformations of ObjectsTransformations of Objects 4. MODELING (1) : 1. Modeling Transformations Topics

Review vector arithmeticReview vector arithmetic Relate vectors to objects in graphicsRelate vectors to objects in graphics Relate geometric concepts to their algebraic representationsRelate geometric concepts to their algebraic representations Describe lines and planes parametricallyDescribe lines and planes parametrically Distinguish points and vectors properlyDistinguish points and vectors properly Exploit the dot product in graphicsExploit the dot product in graphics Develop tools for working with objects in 3D spaceDevelop tools for working with objects in 3D space Review vector arithmeticReview vector arithmetic Relate vectors to objects in graphicsRelate vectors to objects in graphics Relate geometric concepts to their algebraic representationsRelate geometric concepts to their algebraic representations Describe lines and planes parametricallyDescribe lines and planes parametrically Distinguish points and vectors properlyDistinguish points and vectors properly Exploit the dot product in graphicsExploit the dot product in graphics Develop tools for working with objects in 3D spaceDevelop tools for working with objects in 3D space Vector Tools for Graphics Goals

Why Are Vectors So Important? Example : 3 problems For the coordinate given, where is the center of the circle located? Where does the image of the tree appear on the viewplane, and what is its exact shape? Given the positions of the cone, cube and viewing camera, where exactly does the reflected image appear, and what is its color and shape?

Some Basics Coordinate Systems a) Two-dimensional b) Right-handed Math, engineering, physics, … Set up models for objects (local and world spaces) c) Left-handed Natural in computer graphics Viewing systems and “cameras” (view space)

Review 3D Vector : specifies a direction and a magnitude Represented by three coordinates Magnitude Has no location typedef struct { Coordinate dx; Coordinate dy; Coordinate dz; } Vector; (dx1, dy1, dz1) (dx2, dy2, dz2) Displacement

Review Operations

Review Linear combinations Affine combinations Two special cases: Convex combinations Often forced to sum to unity: and

Review “set of all convex combinations” Example: vector that is 20% on the way from v1 to v3 along L:

Review Magnitude Unit vector Normalizing At times, we refer to a unit vector as direction

Dot Product Angle between Two Vectors Sign and Perpendicularity “perpendicular” orthogonal normal

Vector Tools for Graphics (more later…)Vector Tools for Graphics (more later…) Transformations of ObjectsTransformations of Objects Vector Tools for Graphics (more later…)Vector Tools for Graphics (more later…) Transformations of ObjectsTransformations of Objects 4. MODELING (1) : 1. Modeling Transformations Topics

Developing tools for transforming one picture into anotherDeveloping tools for transforming one picture into another Introduce the fundamental concepts of affine transformations (combinations of rotations, scalings, translations)Introduce the fundamental concepts of affine transformations (combinations of rotations, scalings, translations) Develop functions that apply affine transformations to objectsDevelop functions that apply affine transformations to objects Modeling transformations in OpenGLModeling transformations in OpenGL Developing tools for transforming one picture into anotherDeveloping tools for transforming one picture into another Introduce the fundamental concepts of affine transformations (combinations of rotations, scalings, translations)Introduce the fundamental concepts of affine transformations (combinations of rotations, scalings, translations) Develop functions that apply affine transformations to objectsDevelop functions that apply affine transformations to objects Modeling transformations in OpenGLModeling transformations in OpenGL Transformations of Objects Goals

Introduction Control over the size, orientation, and position of objects of interest Each 3D point in the house: Scaling Rotation Translation Very useful in a number of situations: 1.Scene composition 2.“Motif” design 3.Viewing 4.Computer animation

Introduction Scene Composition Many instances of a simple form 3D primitives

Introduction “Motif” design Viewing Computer Animation

CPSC 453’s Framework for Interactive Graphics Graphics system Application program Imaging Modeling Application model Rendering Image Processing Animation User Interface OpenGL 3D graphics and modeling library Object-Oriented Design, C/C++

Application program OpenGL Command Buffer Transform and Lighting Rasterization Frame buffer OpenGL API Calls OpenGL OpenGL pipeline (simplified version)

Introduction OpenGL Pipeline glBegin(GL_LINES) glVertex3f(…); // send P1 through the pipeline glVertex3f(…); // send P2 through the pipeline glVertex3f(…); // send P3 through the pipeline glEnd(); CT : “Current Transformation”: Crucial tool Essential to know how to adjust it

Introduction Transforming Points and Objects Homogeneous representation or

Introduction Affine Transformations The coordinates of Q are linear combinations of those of P

Introduction Elementary 2D Affine Transformations Translation Scaling Rotation

Introduction Inverse of an Affine Transformation Translation Scaling Rotation

Composing (or Concatenating) Affine Transformations Introduction Example: Translate by (3, -4) Then rotate through 30 degrees Then scale by (2, -1) Then translate by (0.15) And finally, rotate through –30 degrees When homogeneous coordinates are used, affine transformations are composed by simple matrix multiplication

Example : Rotating about an arbitrary point Introduction 1.Translate point P through vector v = (-Vx, -Vy) 2.Rotate about the origin through angle theta 3.Translate P back through v

Transforming Points and Objects Homogeneous representation 3D Affine Transformations

Elementary 3D Affine Transformations Translation Scaling

3D Affine Transformations Rotations x-roll: y-roll: z-roll:

3D Affine Transformations Rotations

Order does matter 3D rotation matrices do not commute Combining Rotations Composing (or Concatenating): Same as in 2D case

Affine Transformations in a Program House #1 glBegin(GL_LINES) glVertex2f(V[0].x, V[0].y); glVertex2f(V[1].x, V[1].y); glVertex2f(V[2].x, V[0].y); …. // the remaining points glEnd(); House #2 ?

The Canvas Class class Canvas { private: Point2 CP; // current position in world float CD; // current direction in degrees public: Canvas(int width, int height, char* title); ~Canvas(); void setWindow(float l, float r, float b, float t); void lineTo(float x, float y); void moveTo(float x, float y); void turn(float ang); void turnTo(float ang); void forward(float dist, int vis); };

Affine Transformations in a Program House #1 cvs.moveTo (V[0]); cvs.lineTo (V[1]); cvs.lineTo (V[2]); …. // the remaining points House #2 ?

Affine Transformations in a Program House #2 : The Hard Way cvs.moveTo ( transform2D (CT, V[0]) ); cvs.lineTo ( transform2D (CT, V[1]) ); cvs.lineTo ( transform2D (CT, V[2]) ); …. // the remaining points Q = transform2D(CT, P);

Affine Transformations in a Program House #2 : The Easy Way Q = transform2D(CT, P); OpenGL cvs.moveTo (V[0]); cvs.lineTo (V[1]); cvs.lineTo (V[2]); …. // the remaining points OpenGL maintains modelview matrix CT : modelview matrix

Affine Transformations in a Program glScaled(sx, sy, 1.0); glTranslated(dx, dy, 0.0); glRotated(angle, 0.0, 0.0, 1.0); modelview matrix Alter the modelview matrix Do not set CT directly Each postmultiplies the CT : CT = CT * M

Back to Canvas… void Canvas :: initCT() // initialize the CT (model view matrix) { glMatrixMode(GL_MODELVIEW); // informs OpenGL which matrix we are altering glLoadIdentity(); // set CT to the identity matrix } void Canvas :: rotate2D(double angle) { glMatrixMode(GL_MODELVIEW); glRotated(angle, 0.0, 0.0, 1.0); // set CT to CT * (2D rotation) } void Canvas :: translate2D(double dx, double dy) { glMatrixMode(GL_MODELVIEW); glTranslated(dx, dy, 0.0); // set CT to CT * (2D translation) } void Canvas :: scale2D(double sx, double sy) { glMatrixMode(GL_MODELVIEW); glScaled(sx, sy, 1.0); // set CT to CT * (2D scaling) }

Examples Object definition Compose scene Define view reference Define lighting Local coordinate space World coordinate space Modeling transformation Local coordinate space World coordinate space Object definition Compose scene

Examples Drawing snowflakes void drawFlake() { for (int count = 0; count < 6; count++) { flakeMotif(); cvs.scale2D(1.0, -1.0); flakeMotif(); cvs.scale2D(1.0, -1.0); cvs.rotate2D(60.0); } }

Examples A flurry of snowflakes while (!bored) { cvs.initCT(); cvs.translate2D ( random amount, random amount ); drawFlake(); }

Examples Patterns from a motif const int numMotifs = 12; for (int i = 0; i < numMotifs ; i++) { cvs.initCT(); cvs.rotate2D ( i * 360 / numMotifs ); cvs.translate2D(0.0, H); drawDino(); }

Saving the CT for Later Use Top matrix : actual CT void Canvas :: pushCT(void) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); } void Canvas :: popCT(void) { glMatrixMode(GL_MODELVIEW); glPopMatrix(); }

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT();

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT1 = identity

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity CT1 = identity

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) CT1 = identity

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) CT1 = identity CT3 = identity * translation (W, H)

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) CT1 = identity CT3 = identity * translation (W, H)

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) CT1 = identity CT3 = identity * translation (W, H) * translation (L, 0)

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) CT1 = identity CT3 = identity * translation (W, H) * translation (L, 0)

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) CT1 = identity CT3 = identity * translation (W, H) * translation (L, 0) * translation (L, 0)

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) CT1 = identity CT3 = identity * translation (W, H) * translation (L, 0) * translation (L, 0)

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) CT1 = identity

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) * translation (0, D) CT1 = identity

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) * translation (0, D) CT1 = identity CT3 = identity * translation (W, H) * translation (0, D)

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) * translation (0, D) CT1 = identity CT3 = identity * translation (W, H) * translation (0, D)

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) * translation (0, D) CT1 = identity CT3 = identity * translation (W, H) * translation (0, D) * translation (L, 0)

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT2 = identity * translation (W, H) * translation (0, D) CT1 = identity CT3 = identity * translation (W, H) * translation (0, D) * translation (L, 0) until…

Tilings made easy cvs.pushCT(); cvs.translate2D (W, H); for (int row = 0; row < 3; row++) { cvs.pushCT(); for (int row = 0; row < 3; row++) { motif(); cvs.translate2D (L, 0); } cvs.popCT(); cvs.translate2D (0, D); } cvs.popCT(); CT1 = identity

CAD program Code ?