Affine Transformation. Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite.

Slides:



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

COMPUTER GRAPHICS 2D TRANSFORMATIONS.
Computer Graphics Lecture 4 Geometry & Transformations.
Math 1Hofstra University – CSC171A1 Modeling Objects by Polygonal Approximations Define volumetric objects in terms of surfaces patches that surround the.
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.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 OpenGL Transformations Ed Angel Professor of Computer Science, Electrical and Computer.
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.
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
CS 450: Computer Graphics 2D TRANSFORMATIONS
3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. 3D Transformation glVertex3f(x, y,z);
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.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.
Geometric 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
1 Computer Graphics Week9 -3D Geometric Transformation.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
CAP 4730 Computer Graphic Methods Prof. Roy Levow Chapter 4.
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.
Two-Dimensional Geometric Transformations ch5. 참조 Subjects : Basic Transformations Homogeneous Coordinates Composite Transformations Other Transformations.
3D Transformations. Translation x’ = x + tx y’ = y + ty z’ = z + tz P = P’ = T = P’ = T. P tx ty tz xyz1xyz1 x’ y’ z’ 1 x y.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
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.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
CS552: Computer Graphics Lecture 4: 2D Graphics. Recap 2D Graphics Coordinate systems 2D Transformations o Translation o Scaling o Rotation Combining.
Composing Transformations
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 By Dr. HANY ELSALAMONY.  We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations.
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.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
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.
CS 325 Introduction to Computer Graphics 02 / 19 / 2010 Instructor: Michael Eckmann.
Transformations in 3D Lecture 17 Mon, Oct 6, 2003.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Computer Graphic 2 D Transformation.
CSCE 441 Computer Graphics: 2D Transformations
4. Geometric Objects and Transformations
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.
2D Geometric Transformations
2D Transformations with Matrices
Review: Transformations
Review: Transformations
Introduction to Computer Graphics with WebGL
CSC461: Lecture 19 Computer Viewing
Unit-5 Geometric Objects and Transformations-II
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Chapters 5/4 part2 understanding transformations working with matrices
Transformations 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
The Modelview Matrix Lecture 8 Mon, Sep 10, 2007.
Three-Dimensional Graphics
Transformations in OpenGL
Geometric Objects and Transformations (II)
TWO DIMENSIONAL TRANSFORMATION
Translation in Homogeneous Coordinates
Presentation transcript:

Affine Transformation

Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite transformation matrix

Reflection  Reflection produces a mirror image of an object  It is also a rigid body transformation  Reflection is relative the axis of the reflection. In 2-D, the axis are either x and y whereas 3-D includes z axis.  Reflection is actually a special case of scaling (with the negative scale factor)

Reflection (cont.) For 2-D reflection, the transformation matrix F has the Following form F(x) = F(y) = About x-axisabout y-axis

Reflection (cont.) For 3-D reflection, the transformation matrix F has the following form F(z) = Reflection about z-axis

Reflection (cont.) Reflection can be generalized by concatenating rotation and reflection matrices. Example: If reflection at y=x axis (45 degree), the transformations involved are: 1. Clockwise rotation of 45 degree 2. Reflection about x axis 3. Counter clockwise rotation of 45 degree

Shearing  Distort an object by moving one side relative to another  It neither rigid body nor orthogonal transformation. I.e. changing a square into parallelogram in 2-D or cube into parallelepiped in 3-D space  It is normally used to display italic text using regular ones

Shearing (cont.) For 2-D shearing transformation the transformation matrix has The following form X directiony direction

Shearing (cont.) The values can be positive or negative numbers Positive: moves points to the right Negative: moves points to the left

Shearing (cont.) For 3-D space shearing transformations the number of Transformation matrix are many. Basically, to get one transformation matrix for shearing, we can Substitute any zero term in identity matrix with a value like Example below:

Example (3-D shearing) Let us consider a unit cube whose lower left corner coincides With the origin

Example (3-D shearing) Based on the diagram, we want to shear the cube at about the z axis. In this case the face of the cube that lies on the xy-coordinate plane does not move. The face that lies on the plane z=1 is translated by a vector (shx,shy). This is called xy-shear. Under the xy-shear, the origin and x- and y-unit vectors are unchanged. The transformation matrix for this transformation is:

Composition matrix  As can be seen in the previous example, we can actually compose or concatenate many affine transformation matrices to produce a single (resultant) affine transformation matrix  For example, to get a composition matrix for rotation and translation, we perform matrix multiplication.  We can build a composite transformation for a general-case transformation at any other points (besides origin)

Example Let say we want to produce an object that goes through the following transformation operations: translate by (3, -4), M 1 then rotate through 30 degree, M 2 then scale by (2, -1), M 3 then translate by (0, 1.5), M 4 and finally, rotate through –30 degree, M 5 All of these transformation can be represented by a single matrix, M M = M 5 M 4 M 3 M 2 M 1

Example (cont.) Composition matrix for affine transformations can only be produced if we use homogenous coordinates (for translation case). Notice the multiplication is done in reverse order (FILO) Exercise: Build a transformation matrix that a) rotates through 45 degrees b) then scales in x by 1.5 and in y by –2, c) and finally translates through (3,5) Find the image under this transformation of the point (1,2)

Affine transformation in OpenGL Recall our lesson on OpenGL graphics pipeline. CT = Current Transformation

OpenGL All the transformations will be performed in CT by changing the Current transformation matrix. In other way, the CT matrix is An example of composite matrix. Typically, in OpenGL, we will have the following fragment of code in our program before we start performing transformations. glMatrixMode(GL_MODELVIEW); glLoadIdentity();

OpenGL By having this code in our program, we set our matrix Mode to be GL_MODELVIEW and initialize the CT matrix to be identity CT I Once we have set this, we can perform transformation Which means we modify the CT by post-multiplication by a matrix

OpenGL CTCT.T(translation matrix) CTCT.S(scaling matrix) CTCT.R(rotation matrix) CTCT.M(arbitrary matrix) Once all of the transformation matrix multiplications have been done, the vertices will be transformed based on the final (composite) matrix In OpenGL all matrices are in 4 x 4 matrix

OpenGL The three transformation supported in most graphics system (including OpenGL) are translation, rotation with a fixed point of the origin and scaling with a fixed point of the origin. The functions for these transformation in OpenGL are: glTranslatef(dx, dy, dz); glRotatef (angle, vx, vy, vz); glScalef(sx, sy, sz);

OpenGL If we want to perform rotation at any other point using the provided functions in OpenGL, (I.e. 45 degree rotation about the line through the origin and the point (1,2,3) with a fixed point of (4,5,6).) the following code fragment shows us how to perform this transformation. glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(4.0,5.0,6.0); glRotatef(45.0,1.0,2.0,3.0); glTranslatef(-4.0,-5.0,-6.0); NB: Take note at the reverse order implementation

OpenGL For most purposes, rotation, translation and scaling can be used to form our desired object. However, in some cases the provided transformation matrices are not enough. For example, if we want to form a transformation matrix for shearing and reflection. For these transformations, it is easier if we set up the matrix directly. We can load a 4 x 4 homogeneous-coordinate matrix as the current matrix (CT)

OpenGL To load the matrix we call this function: glLoadMatrixf(myarray); Or we can multiply our shearing matrix by calling this function glMultMatrixf(myarray); Where myarray is a one-dimensional array of 16 element arranged by colomns.

OpenGL To define a user-defined matrix (for shearing and reflection) we can follow the same way as shown below: Glfloat myarray[16]; for (i=0;i<3;i++) for(j=0;j=3;j++) myarray[4*j+i] = M[i][j];