Transformations of Objects CVG lab. Introduction  Affine transformations : Affine transformations are a fundamental cornerstone of computer graphics.

Slides:



Advertisements
Similar presentations
1Computer Graphics Homogeneous Coordinates & Transformations Lecture 11/12 John Shearer Culture Lab – space 2
Advertisements

Transformations Ed Angel Professor Emeritus of Computer Science
MAT 594CM S2010Fundamentals of Spatial ComputingAngus Forbes Overview Goals of the course: 1. to introduce real-time 3D graphics programming with openGL.
University of North Carolina at Greensboro
CMPE 466 COMPUTER GRAPHICS
Math 1Hofstra University – CSC171A1 Modeling Objects by Polygonal Approximations Define volumetric objects in terms of surfaces patches that surround the.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
CMPE 466 COMPUTER GRAPHICS
University of North Carolina at Greensboro
2/7/2001Hofstra University – CSC290B1 Review: Math (Ch 4)
Modeling Objects by Polygonal Approximations
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
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.
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
CS 4731: Computer Graphics Lecture 8: 3D Affine transforms Emmanuel Agu.
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.
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.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360.
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.
Geometric transformations The Pipeline
Chi-Cheng Lin, Winona State University CS430 Computer Graphics Transformations of Objects – 2D Part I.
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that.
Transformations of Objects – 3D
Geometric Objects and Transformation
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
CSE Real Time Rendering Week 5. Slides(Some) Courtesy – E. Angel and D. Shreiner.
Computer Graphics I, Fall 2010 OpenGL Transformations.
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.
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.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
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.
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
OpenGL LAB III.
CSCE 441 Computer Graphics: 2D Transformations
Transformations. Transformations Introduce standard transformations ◦ Rotation ◦ Translation ◦ Scaling ◦ Shear Derive homogeneous coordinate transformation.
Modeling Transformations Mario Costa Sousa University of Calgary CPSC 453, Fall 2001 Mario Costa Sousa University of Calgary CPSC 453, Fall 2001.
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360/4360.
Objectives Introduce standard transformations Introduce standard transformations Derive homogeneous coordinate transformation matrices Derive homogeneous.
Geometric Transformations
Camera Position (5.6) we specify the position and orientation of the camera to determine what will be seen. use gluLookAt (eye x, y, z, at x, y, z, up.
2D Transformations with Matrices
Summary of Properties of 3D Affine Transformations
Review: Transformations
Review: Transformations
Introduction to Computer Graphics with WebGL
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Transformations 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Transformations in OpenGL
Geometric Objects and Transformations (II)
Translation in Homogeneous Coordinates
Presentation transcript:

Transformations of Objects CVG lab

Introduction  Affine transformations : Affine transformations are a fundamental cornerstone of computer graphics and are central to OpenGL as well as most other graphics systems.

Introduction to Transformations  The overall transformation is a combination of three elementary ones : scaling, rotation and translation.  Transformations are useful in a number of situations : 1. Composing a “scene” out of a number of objects. 2. Creating a complex object from a single “motif”. 3. A designer may to view an object from different vantage points and make a picture from each one. 4. In a computer animation, several objects must move to one another from frame to frame.

Introduction to Transformations

 Where Are We Headed? Using Transformations with OpenGL A number of graphics platforms, including OpenGL, provide a “graphics pipeline,” or a sequence of operations that are applied to all points that are “sent through”. glBegin (GL_LINES) glVertex3f(...);//send P1 through the pipeline glVertex3f(...);//send P2 through the pipeline glVertex3f(...);//send P2 through the pipeline glEnd();

Introduction to Transformations  Object Transformations versus Coordinate Transformations -. There are two ways to view a transformation : as an object transformation or as a coordinate transformation.. An object transformation alters the coordinates of each point on the object to some rule, leaving the underlying coordinate system fixed.. A coordinate transformation defines a new coordinate system in terms of the old one and then represents all of the object’s points in this new system.

Introduction to Transformations 1.Transforming Points and Objects A transformation alters each point P in space (2D or 3D) into a new point Q by means of a specific formula or algorithm. P = (P x, P y, 1) Q = (Q x, Q y, 1) (Q x, Q y, 1) = T (P x, P y, 1) Q = T(P).

Introduction to Transformations 2.The Affine Transformations -. Affine transformations are the most common transformations used in computer graphics. -. Affine transformations have a simple form : The coordinates of Q are linear combinations of those of P. That is, (Q x, Q y, 1) = (m 11 P x +m 12 Py+m13, m11Px+m12Py+m13, 1) For an affine transformation, the third row of the matrix is always (0, 0, 1)

Introduction to Transformations 3. Geometric Effects of Elementary 2D Affine Transformations -. Affine transformations produce combinations of four elementary transformations : translation, scaling, rotation, and shear. a. Translation b. Scaling

Introduction to Transformations c. Rotation d. Shearing

Introduction to Transformations 4.The Inverse of an Affine Transformation Most affine transformations of interest are nonsingular, which means that the determinant of m Det M = m 11 m 22 – m 12 m 21 Q = MP by the inverse of M, denoted M -1 P = M -1 Q The inverse of M M-1 = 1/det M

Introduction to Transformations a. Scaling b. Rotation

Introduction to Transformations c. Shearing d. Translations

Introduction to Transformations 5.Composing Affine Transformations -. The process of applying several transformations in succession to form one overall transformation is called composing(or concatenating) the transformations. W = MP M = M 2 M 1

Introduction to Transformations 6.Example Composing 2D Transformations

Introduction to Transformations 7.Some Useful Properties of Affine Transformations a. Affine Transformations Preserve Affine Comvinations of Points W = a 1 P 1 + a 2 P 2 T(a 1 P 1 + a 2 P 2 ) = a 1 T(P 1 ) + a 2 T(P 2 ) MW = M (a 1 P 1 + a 2 P 2 ) = a 1 MP 1 + a 2 MP 2 b. Affine Transformations Preserve Lines and Planes L(t) = (1 – t)A + tB Q(t) = (1 - t)T(A) + tT(B) P(s, t) = sA + tB + (1 - s- t)C T(P(s, t)) = sT(A) + tT(B) + (1 – s – t)T(C)

Introduction to Transformations c. Parallelism of Lines and Planes is Preserved d. The Columns of the Matrix Reveal the Transformed Coordinate Frame M = = (m 1 | m 2 | m 3 ) ט = (0, 0, 1), I = (1, 0, 0), j = (0, 1, 0) m 1 = Mi. P = P x i + P y j + ט Q = P x m 1 + P y m 2 + m 3

Introduction to Transformations e. Relative Ratios Are Preserved f. Effect of Transformations on the Areas of Figures area after transformation / area before transformation = |det M|

Introduction to Transformations f. Every Affine Transformation Is Composed of Elementary Operations -. 2D affine Transformation : M = (translation)(shear)(scaling)(rotation) -. 3D affine transformation : M = (translation)(scaling)(rotation)(shear 1 )(shear 2 )

3D AFFINE TRANSFORMATIONS P = P x i + P y j +P Z K + ט P = (P X, P y, P z, 1) M = = M

3D AFFINE TRANSFORMATIONS 1.The Elementary 3D Transformations a. Translation b. Scaling

3D AFFINE TRANSFORMATIONS c. Shearing d. Rotations -. Elementary rotations about a coordinate axis Positive values of β cause a counterclockwise (CCW) rotation about an axis as one looks inward from a point on the positive axis toward the origin.

3D AFFINE TRANSFORMATIONS 90° rotation :. For a z-roll, the x-axis rotates to the y-axis.. For a x-roll, the y-axis rotates to the x-axis.. For a y-roll, the z-axis rotates to the x-axis.

3D AFFINE TRANSFORMATIONS. An x-roll R x (β) =. A y-roll R y (β) =

3D AFFINE TRANSFORMATIONS. An x-roll R z (β) =

3D AFFINE TRANSFORMATIONS 2. Composing 3D Affine Transformations M = M 2 M 1

3D AFFINE TRANSFORMATIONS 3. Combining Rotations M = R z (β 3 )R y (β 2 )R x (β 1 )  Rotations about an Arbitrary Axis EUSER’S THEOREM : Any rotation (or sequence of rotations) about a point is equivalent to a single rotation about some axis through that point. -. The Classic Way : We decompose the required rotation into a sequence of known steps:

3D AFFINE TRANSFORMATIONS 1. Perform two rotations so that u becomes aligned with the x-axis. 2. Do a z-roll through the angle β. 3. Undo the two alignment rotations to restore u to its original direction. R u (β) = R y (-θ)R z (Φ)R x (β)R z (- Φ)R y (θ)  The Constructive Way

3D AFFINE TRANSFORMATIONS R u (β) =

3D AFFINE TRANSFORMATIONS  Rotations about an Arbitrary Axis R u (β) = u x =( m 32 – m 23 )/ (2sin (β)) u y =( m 13 – m 31 )/ (2sin (β)) u z =( m 21 – m 12 )/ (2sin (β))

CHANGING COORDINATE SYSTEMS (P x, P y, 1) T = = M

CHANGING COORDINATE SYSTEMS  Successive Changes in a Coordinate Frame = M1 = M1M2

CHANGING COORDINATE SYSTEMS -. Transforming Points M = M 3 * M 2 * M Transforming the Coordinate System M = M 1 * M 2 * M 3

USING AFFINE TRANSFORMATIONS IN A PROGRAM glBegin (GL_LINES) glVertex2d(V[0].x, V[0].y); glVertex2d(V[1].x, V[1].y); glVertex2d(V[2].x, V[2].y); ….. // the remaining points glEnd ( ); In either case, cvs.setWindow (...) ; cvs.setViewport (...) ;

USING AFFINE TRANSFORMATIONS IN A PROGRAM  The Hard Way Q = transform2D (M, P); cvs.moveTo (transform2D (M,V[0])) cvs.lineTo (transform2D (M,V[1])) cvs.lineTo (transform2D (M,V[2])) …

USING AFFINE TRANSFORMATIONS IN A PROGRAM  The Easy Way OpenGL maintains a so-called modelview matrix, and every vertex that is passed down the graphics pipeline is multiplied by this matrix.

USING AFFINE TRANSFORMATIONS IN A PROGRAM CT = CT*M. glScaled (sx, sy, 1.0) ; Postmultiply CT by a matrix that performs a scaling by sx in x and by sy in y ; put the result back into CT. No scaling in z is done.. glScaled (dx, dy, 1.0) ; Postmultiply CT by a matrix that performs a translation by dx in x and by dy in y ; put the result back into CT. No scaling in z is done.. glScaled (angle, 0, 1.0) ; Postmultiply CT by a matrix that performs a rotation through angle degrees about the z-axis. Put the result back into CT.

USING AFFINE TRANSFORMATIONS IN A PROGRAM

for (int count = 0; count<5; count ++) { starMotif ( ); cvs.rotate2D(72.0);//concatenate another rotation } 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);}}

USING AFFINE TRANSFORMATIONS IN A PROGRAM 1.Saving the CT for Later Use

USING AFFINE TRANSFORMATIONS IN A PROGRAM

DRAWING 3D SCENES WITH OPENGL

 Some OpenGL Tools for Modeling and Vewing -. Setting the Camera in OpenGL (for a Parallel Projection) glMatrixMode (GL_PROJEXTION); glLoadIdentity ( ); glOrtho (left, right, bottom, top, near, far);  Positioning and Aiming the Camera glMatixMode (GL_PROJECTION); glLoadIdentity ( ); glOrhto (-3.2, 3.2, -2.4, 2.4, 1, 50); glMatrixMode (GL_MODELVIEW); glLoadIdentity ( ); gluLookAt (4, 4, 4, 0, 1, 0, 0, 1, 0);