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.

Slides:



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

COMPUTER GRAPHICS 2D TRANSFORMATIONS.
Computer Graphics Lecture 4 Geometry & Transformations.
Geometric Transformations
1 Computer Graphics Chapter 6 2D Transformations.
Chapter 5 Geometric Transformations
CMPE 466 COMPUTER GRAPHICS
1 Geometrical Transformation 2 Outline General Transform 3D Objects Quaternion & 3D Track Ball.
CMPE 466 COMPUTER GRAPHICS
1 Lecture 7 Geometrical Transformations: 2D transformations 3D transformations Matrix representation OpenGL functions.
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 Geometrical Transformation Tong-Yee Lee. 2 Modeling Transform Specify transformation for objects Allow definitions of objects in own coordinate systems.
Computer Graphics with OpenGL 3e
2IV60 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);
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
5.2 Three-Dimensional Geometric and Modeling Transformations 2D3D Consideration for the z coordinate.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Transformation of Graphics
Transformations Dr. Amy Zhang.
Computer Graphics Bing-Yu Chen National Taiwan University.
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 Transformation of Graphics
2D Transformations.
Lecture Notes: Computer Graphics.
Geometric Transformations Jehee Lee Seoul National University.
2D Geometric Transformations
Geometric transformations The Pipeline
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
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.
Computer Graphics I, Fall 2010 OpenGL Transformations.
Computer Graphics 3D Transformations. Translation.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Geometric Transformations
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
Geometric Transformations UBI 516 Advanced Computer Graphics Aydın Öztürk
January 19, y X Z Translations Objects are usually defined relative to their own coordinate system. We can translate points in space to new positions.
CS552: Computer Graphics Lecture 4: 2D Graphics. Recap 2D Graphics Coordinate systems 2D Transformations o Translation o Scaling o Rotation Combining.
3D Coordinate Systems o3D computer graphics involves the additional dimension of depth, allowing more realistic representations of 3D objects in the real.
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.
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.
Geometric Transformations. Transformations Linear transformations Rigid transformations Affine transformations Projective transformations T Global reference.
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.
CS380 LAB II OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
4. Geometric Objects and Transformations
Modeling Transformation
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Geometric Transformations
3D Geometric Transformation
Geometric Transformations Hearn & Baker Chapter 5
2D Geometric Transformations
Computer Graphics CC416 Week 15 3D Graphics.
3D Geometric Transformations
Three-Dimensional Graphics
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Three-Dimensional Graphics
Geometric Objects and Transformations (II)
TWO DIMENSIONAL TRANSFORMATION
Lecture #6 2D Geometric Transformations
Presentation transcript:

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 cases where h  1. h = 0 indicates a point at infinity (x, y, z)  (x h, y h, z h, h)(x h, y h, z h, h)  (x, y, z)

With homogeneous coordinates, we can express all 3D transformations as matrix multiplications. or

Translation (t x, t y, t z ) x y Translation Vector (t x, t y, t z ) z (x, y, z) (x', y', z')

Scaling x y Scaling factors s x, s y, s z Uniform scaling s x = s y = s z z x y z

Reflection Reflection about xy plane Reflection about xz planeReflection about yz plane

Shear Shear in xy plane about z axis x y z x y z

Rotation 3D rotation: Axis of rotation Rotation angle Looking along the negative direction of rotation axis, positive rotation angle produces counterclockwise rotation. Axis of rotation Right-hand rule: If right hand thumb points to the direction of rotation axis, then the other fingers point to the rotation direction of positive rotation angle. 

Rotation about Coordinate Axes Rotation about z axis: x y z  Use cyclic permutation to generate rotation equation about other axes:

Rotation about x axis: x y z 

Rotation about y axis: x y z 

Quaternion Quaternion definition Scalar part sVector part v = (v x, v y, v z ) Quaternion operation

Rotation with arbitrary rotation axis passing through origin x y z Axis of rotation  u  : Rotation angle u :Unit vector along axis of rotation quaternion for rotation: quaternion for point P (x, y, z): quaternion for point P' (x', y', z'): Rotation transformation:

Rotation Matrix:

Composite Transformations A sequence of transformations: M 1, M 2,..., M n can be calculated as P' = M  P where M is obtained by matrix concatenation: M = M n  M n-1 ...  M 2  M 1

OpenGL maintains three transformation matrices: Modelview Matrix, Projection Matrix and Texture Matrix OpenGL Transformation Matrices Transformation matrices in OpenGL are stored in column-major order, which is different from row-major order of standard C convention.

The effects of most transformation commands are accumulative. The matrix is post-multiplied to the current transformation matrix. Because of this, transformation specified last is actually applied first. A:Current transformation matrix before transformation command M: Matrix generated by transformation command B:Current Transformation matrix after transformation command B = A  M A sequence of transformations M 1, M 2,..., M n should be specified as: Transformation M n ; Transformation M n-1 ; Transformation M 2 ; Transformation M 1 ; Draw primitive;

General Purpose Transformation Commands void glMatrixMode(GLenum mode) mode:GL_MODELVIEW, GL_PROJECTION or GL_TEXTURE void glLoadIdentity(void) Set current matrix to 4 by 4 identity matrix. void glLoadMatrixf (const GLfloat *m) Set current matrix to the values stored in array pointed by m. void glLoadMatrixd(const GLdouble *m) Specify current matrix mode. void glMultMatrixf (const GLfloat *m) Post-multiply the matrix pointed by m to the current matrix. void glMultMatrixd(const GLdouble *m)

Geometric Transformation Commands Translation void glTranslatef(GLfloat tx, GLfloat ty, GLfloat tz) void glTranslated(GLdouble tx, GLdouble ty, GLdouble tz) (tx, ty, tz): Translation vector Scaling void glScalef(GLfloat sx, GLfloat sy, GLfloat sz) void glScaled(GLdouble sx, GLdouble sy, GLdouble sz) (sx, sy, sz): Scaling factors Rotation void glRotatef(GLfloat , GLfloat x0, GLfloat y0, GLfloat z0) void glRotated(GLdouble , GLdouble x0, GLdouble y0, GLdouble z0)  :Rotation angle (in degrees) (x0, y0, z0):Axis of rotation that passes through origin

Matrix Stack Manipulation For each transformation matrix, OpenGL maintains a matrix stack. The Modelview matrix stack has at least 32 entries. The Projection and Texture matrix stacks have at least 2 entries each. void glPushMatrix(void)Push current matrix into matrix stack. void glPopMatrix(void)Pop current matrix from matrix stack. The current matrix stack is determined by glMatrixMode(). Matrix stacks are useful for hierarchical modeling.

Normalize mouse position 1 y w h (x, y) 1 11 11 (x n, y n ) x Arcball (Trackball) Rotation

Map normalized mouse position to unit sphere (arc ball) 1 x y 1 11 11 (x n, y n ) x y (x s, y s, z s ) z Arc ball when r < 1when r > 1

Obtain rotation quaternion x y Arc ball  P0P0 P1P1 n P 0 Start position on unit sphere P 1 End position on unit sphere Rotation quaternion: