0% found this document useful (0 votes)
11 views15 pages

Matrix Transformations in OpenGL

This document discusses computer graphics transformations using OpenGL functions. It explains that all object vertices are multiplied by a transformation matrix to apply transformations. It describes the glMatrixMode function which specifies the current transformation matrix as either model-view, projection, or texture. It also explains the glRotate function which multiplies the current matrix by a rotation matrix to rotate objects around an axis by a given angle in degrees. Examples are provided to illustrate clockwise and counter-clockwise rotation around the z-axis. Rotation and scaling around arbitrary points are also discussed.

Uploaded by

asmaa soliman
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views15 pages

Matrix Transformations in OpenGL

This document discusses computer graphics transformations using OpenGL functions. It explains that all object vertices are multiplied by a transformation matrix to apply transformations. It describes the glMatrixMode function which specifies the current transformation matrix as either model-view, projection, or texture. It also explains the glRotate function which multiplies the current matrix by a rotation matrix to rotate objects around an axis by a given angle in degrees. Examples are provided to illustrate clockwise and counter-clockwise rotation around the z-axis. Rotation and scaling around arbitrary points are also discussed.

Uploaded by

asmaa soliman
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

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