Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Computer Graphics Week9 -3D Geometric Transformation.

Similar presentations


Presentation on theme: "1 Computer Graphics Week9 -3D Geometric Transformation."— Presentation transcript:

1 1 Computer Graphics Week9 -3D Geometric Transformation

2 We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations to view our 3D models effectively. Let us look into 3D transformations in more detail. 2

3  Just as 2D transformations can be represented by 3 x 3 matrices using homogenous coordinates.  3D transformations can be represented by 4 x 4 matrices.  3D homogenous coordinates are represented as a quadruplet (x, y, z, W).  We discuss the representation of the three most commonly used transformations: translation, scaling, and rotation. 3

4 1-Translation The translation matrix T(Tx, Ty, Tz) is defined as: so any vertex point: 4

5 5

6 2- Scalling Scaling is similarly extended to be defined as: 6

7  Recall from Lecture 3 that scaling occurs about a point. This point is called the pivot point. The scaling matrix defined above scales about the origin.  You can define models to have different pivot points by setting the transformation stack appropriately. 7

8 3-Rotation Rotation matrices are defined uniquely based on the axis of rotation and the pivot point. The axis of rotation is a normalized vector defining the axis in 3D space along which the rotation will occur. 8

9 (A 3D vector will simply be the triplet (x, y, z) defining the direction of the axis). The 2D rotation we saw earlier is a 3D rotation about the z-axis (the vector (0,0,1)), and the world origin (0,0,0) and is defined as: 9

10 Similarly the rotation matrix about the x-axis is defined to be: and about the y-axis as: 10

11 Just as with 2D transforms, 3D transforms can be composed together to provide desired effects. The order in which the transforms are applied is important. Recall from our previous section that the OpenGL commands for matrix operations 11

12 sets the current matrix to be the 4 x 4 identity matrix. sets the matrix passed in to be the current transformation matrix. multiplies the current matrix by the matrix passed in as the argument. 12

13 Additionally, OpenGL provides three utility functions for the most commonly used transformations. multiplies the current transformation matrix by the matrix to move an object by (Tx, Ty, Tz) units 13

14 multiplies the current transformation matrix by a matrix that rotates an object in a counterclockwise direction by theta degrees about the axis defined by the vector (x, y, z). multiplies the current transformation matrix by a matrix that scales an object by the factors, (Sx, Sy, Sz). 14

15 All three commands are equivalent to producing an appropriate translation, rotation, or scaling matrix and then calling glMultMatrixf0 with that matrix as the argument. For example, Let us apply some transformations to the famous pyramid that we created earlier. 15

16 We rotate the pyramid about the y-axis and use double buffering to display the rotation as an animation. 16

17  In lecture 3, we saw how to map a two- dimensional world onto the two dimensional screen.  The process was a simple mapping of 2D world coordinates onto the 2D viewport of the window.  Model positions are first clipped against the 2D world coordinates and then mapped into the viewport of the window for display. 17


Download ppt "1 Computer Graphics Week9 -3D Geometric Transformation."

Similar presentations


Ads by Google