Unit-5 Geometric Objects and Transformations-II

Slides:



Advertisements
Similar presentations
Computer Graphics - Transformation -
Advertisements

Figures based on regular polygons (lab3)
Computer Graphics 2D & 3D Transformation.
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.
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.
Chapter 3: Geometric Objects and Transformations Part 2
3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. 3D Transformation glVertex3f(x, y,z);
Fundamentals of Computer Graphics Part 4
Transformations Dr. Amy Zhang.
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.
Geometry: 2-D Transformations Course web page: Chapter #3.
PPT&Programs&Labcourse 1.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Modeling with OpenGL Practice with OpenGL transformations.
Geometric Objects and Transformations
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.
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.
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
Composing Transformations
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 73 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 73 Computer Graphics Three-Dimensional Graphics II.
1 OpenGL Transformations. 2 Objectives Learn how to carry out transformations in OpenGL ­Rotation ­Translation ­Scaling Introduce OpenGL matrix modes.
Homogeneous Coordinates and Matrix Representations Cartesian coordinate (x, y, z) Homogeneous coordinate (x h, y h, z h, h) Usually h = 1. But there are.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
CS380 LAB II OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
4. Geometric Objects and Transformations
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360/4360.
Geometric Transformations
OpenGL Transformations
Transformations Introduction to Computer Graphics and Animation
OpenGL 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 Geometric Transformations
2D Imaging and Transformation
3D Geometric Transformations
OpenGL Transformations
Computer Graphics OpenGL Transformations
Reference1. [OpenGL course slides by Rasmus Stenholt]
Three-Dimensional Graphics
Introduction to Computer Graphics with WebGL
OpenGL Transformations
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Chapters 5/4 part2 understanding transformations working with matrices
Geometric Transformations
Lecture 6 and 7 Transformations
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)
Advanced Graphics Algorithms Ying Zhu Georgia State University
OpenGL Transformations
OpenGL Transformations
Computer Graphics Transformations
Geometry Objects and Transformation
Chapter 4: Geometry.
Presentation transcript:

Unit-5 Geometric Objects and Transformations-II Course code: 10CS65 | Computer Graphics and Visualization Unit-5 Geometric Objects and Transformations-II Engineered for Tomorrow Prepared by :Asst. Prof. Sandhya Kumari Department : Computer Science and Engineering Date : dd.mm.yyyy

Geometric Objects and Transformations-II Transformations in homogeneous coordinates Concatenation of transformations OpenGL transformation matrices Interfaces to three-dimensional applications Quaternions.

Transformation in Homogeneous Coordinates Translation Scaling Inversion operations: T-1 = T ( -x , -y , -z ) S-1 = S ( 1/x , 1/ y , 1/ z )

Transformation in Homogeneous Coordinates Rotation in x-y plane Rotation in y-z plane Rotation in z-x plane R-1 () = R ( - ) = RT ()

Transformations Concatenation well known strategy q = C B A p interpretation q = C (B (A p) ) Transformation q = M p

Rotation About a Fixed Point Rotation about the fixed point M = T(pf ) Rz(  ) T(- pf )

Rotation About a Fixed Point Rotation about the fixed point M = T(pf ) Rz(  ) T(- pf )

Rotations in E3  Rxy Ryz  Cube can be rotated about all x, y, z axis In our case the transformation matrix is defined M = Rzx Ryz Rxy = Ry Rx Rz Rzx

Rotations in E3 Transformation is defined by the instance transformation M M = T R S (order is substantial!) Each occurrence of an object in the scene is an instance of the object’s prototype To obtain proper size, location, orientation – instance transformation to the prototype is to be applied

Rotations About an Arbitrary Axis Given: points p1 , p2 and rotation angle  objects to be rotated Define vectors u = p1 - p2 and v = u / |u| - normalized v = [ x , y , z ]T x2 + y2 + z2 = 1 – directional cosines cos( x ) = x , cos( y ) = y , cos( z ) = z cos2( x ) + cos2( y ) + cos2 ( z ) = 1  only two directions angles are independent !!

Rotations About an Arbitrary Axis Transformation R = Rx(-x) Ry(-y) Rz() Ry(y) Rx(x)

Rotations About an Arbitrary Axis Object is moved to the origin Rotation about x axis

Rotations About an Arbitrary Axis Object is moved to the origin Rotation about y axis note the “-” position Complete transformation M = T(p0) Rx(-x) Ry(-y) Rz() Ry(y) Rx(x) T(- p0)

OpenGL Transformation Matrices Three matrices as a part of the state in OpenGL Only Model-View will be used CMT – current transformation matrix – can be changed by OpenGL functions – 4 x 4 size Supported operations: translation, scaling & rotation – last two with the fixed point in the origin C  I initialization C  CT translation C  CS scaling C  CR rotation

OpenGL Transformation Matrices Most systems allow to set directly or load or post-multiply the CMT with an arbitrary matrix M , scaling & rotation – last two with the fixed point in the origin C  M loading C  CM post-multiplication

OpenGL Transformation Matrices OpenGL model-view (GL_MODELVIEW) and projection (GL_PROJECTION) matrices (actually their product) are applied to ALL primitives – we should consider them as one CMT matrix – can be manipulated individually using glMatrixMode function glLoadMatrixf(pointer_to_matrix); /* vector of 16 position – column first order */

OpenGL Transformation Matrices glLoadIdentity ( ); /* loads identity matrix */ glRotatef(angle, vx, vy, vz); /* f – float used */ /* specifies general rotation angle in degrees, v – specifies the vector – fixed point P0 is the origin */ glTranslatef(dx, dy, dz); /* translation */ glScalef ( sx, sy, sz); /* scaling */

Rotation about a Fixed Point 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); /* rotates objects about the vector (1.0, 2.0, 3.0) with the angle 45° */ NOTE: we need not to form the rotation matrices as shown recently – try to make it on your own

Transformation Order The sequence specified recently: C  I, initialization C  CT (4.0, 5.0, 6.0), translation C  CR (45.0, 1.0, 2.0, 3.0), rotation C  CT (-4.0, -5.0, -6.0), translation back in each step the CTM matrix is post-multiplied forming new CTM matrix C = T (4.0, 5.0, 6.0) R(45.0, 1.0, 2.0, 3.0) T (-4.0, -5.0, -6.0) Each vertex specified after the model-view matrix has been specified will be multiplied p’ = C p

Spinning of the Cube Three callback functions: glutDisplayFunc(display); glutIdleFunc(spincube); glutMouseFunc(mouse); void display(void); /* visibility made by HW – GL_DEPTH.... */ {glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity ( ); glRotatef(theta[0];1.0, 0.0, 0.0); glRotatef(theta[1];0.0, 1.0, 0.0); glRotatef(theta[2];0.0, 0.0, 1.0); colorcube ( ); glutSwapBuffers ( ); /* swaps the buffers – drawing to the display */ } /* theta vector – global variable */

Spinning of the Cube void spincube ( ); { theta[axis] +=2.0; if (theta[axis] >360.0) theta[axis] -=360.0; glutPostRedisplay ( ); } void mouse (int btn, int state, int x, int y); { if (btn==GLUT_LEFT_BUTTON && state == GLUT_DOWN) axis=0; if (btn==GLUT_MIDDLE_BUTTON && state == GLUT_DOWN) axis=1; if (btn==GLUT_RIGHT_BUTTON && state == GLUT_DOWN) axis=2; } void mykey(char key, int mouse x, int mouse y); { if (key==‘q’ | | key==‘Q’ ) exit ( ); } /* simple termination */

Loading, Pushing & Popping glLoadMatrixf(myarray); /* 4 x 4 matrix of floats -column first order from a vector */ glMultMatrixf(myarray); /* multiplies the current matrix by user specified matrix */ Sequence example GLfloat myarray [16]; for ( i=0; i<3; i++) for ( j=0; j<3; j++) myarray[4*j+i] = m[i][j];

Loading, Pushing & Popping Sometimes it is reasonable to return the transformations back after they have been applied to some objects. Instead of re-computation the stack mechanism can be utilized glPushMatrix ( ); /* local transformation specifications */ glTranslatef ( .....); ................ /* DRAW OBJECTS HERE */ ................ /* recover recent state */ glPopMatrix ( );

Quaternion’s A quaternion consists of Scalar part and vector part , Let a be the quaternion and is defined as a=(q0, q1, q2, q3) i.e., a = ( q0 , q) Where q=(q1, q2, q3) so, we can call Quaternion is an extension to complex numbers