You are on page 1of 15

Computer Graphics

IT221- Computer Graphics Lab (5)


Transformations
To make a transformations in an object all its vertices is multiplied by the
transformation matrix :
glMatrixMode
• Specify which matrix is the current matrix.
• Syntax:
void glMatrixMode(GLenum mode);

• Mode specifies which matrix stack is the target for


subsequent matrix operations.
• Three values are accepted:
• GL_MODELVIEW,
• GL_PROJECTION, and
• GL_TEXTURE.
• The initial value is GL_MODELVIEW.
glRotate
• multiply the current matrix by a rotation matrix
• Syntax:
• void glRotated(GLdouble angle, GLdouble x, GLdouble y,
GLdouble z);
• void glRotatef(GLfloat angle, GLfloat x, GLfloat y , Glfloat z);
• Parameters:
• angle: the angle of rotation, in degrees.
• x, y , z: Specify the x, y and z axis coordinates of a vector,
respectively.
Example

Rotate by 45o
around the z axis
(counter-
clockwise)
Example

Rotate by -45o
around the z axis
(clockwise)
1. Rotation around a point
• Example: The point (x, y) is to be rotated
• The (xc yc) is a point about which
counterclockwise rotation is done
• Rotation of (x, y) about the origin
Rotation around a point
Rotation around a point
1. Scaling around a point
• Example: The point (x, y) is to be scaling
•The (xc yc) is a point about which scaling is done
• scaling of (x, y) about the origin
Scaling around a point
Scaling around a point

You might also like