Navigation: back up next notes exercises
For line, triangle, and polygon drawing also see this.
To define a polygon:
glBegin(GL_POLYGON); /* defining a simple, flat polygon */
for each vertex i
glVertex3fv( vertex_list[i] ); /* ith vertex */
glNormal3fv( normal_list[i] ); /* normal of the ith vertex */
glEnd();
There are several things to note:
M can be setup as follows:
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef(2.0, 1.0, 0.0);
glRotatef( -3.14/2.0, 0.0, 0.0, 1.0);
glScalef(2.0, 2.0, 2.0);
...
which produces the matrix M = trans(2,1,0) rot(z,-90) scale(2,2,2) ....
Another way of loading M is to use:
glMatrixMode( GL_MODELVIEW ); glLoadMatrixf( M );
modelling transformation |
glTranslatef(...) glRotatef(...) glScalef(...) |

A teapot modeled using triangles (Courtesy http://www.siggraph.org)
to be written
Also see 2D Transformations
A transformation which preserves the parallelism of lines, but not necessarily angles or lengths.

In homogeneous coordinates, each cartesian point (x,y,z) is represented in a redundant manner by 4 coordinates, (hx,hy,hz,h). Setting w=0 can be thought of as a point at infinity or, more simply, a direction.

Note: A positive rotation about the z-axis is defined as one that rotates from the positive x-axis to the postive y-axis. We can similarly define rotations about the other two axes. These definitions hold for both RHCS and LHCS.
| translation | ![]() |
| scaling | ![]() |
| shear | ![]() |
| rotation | ![]() |
The transformations defined above can be rewritten using 4x4 matrices and homogeneous coordinates. The general form of the matrix is:
The expressions derived earlier correspond to the following transformation matrices.
A series of transformations can be accumulated into a single transformation matrix. Suppose our object is defined as follows:
Suppose we wish to place the object in our scene like this:
This can be accomplished in several ways, one of which is:
Substituting (1) in (2) gives:

Find the transformation that rotates by an angle theta about a point P(x,y):

Let's choose to describe all transformations w.r.t. a fixed set of axes:
|
|
T = trans(2,3,0) rot(z,90) trans(-2,-3,0)

Overall Transform = trans(P0) rot(x,-alpha) rot(y,beta) rot(z,theta) rot(y,-beta) rot(x,alpha) trans(-P0)
There is another way of looking at transformations which can let us construct transformations between two coordinate systems directly, without having to express the transformations in terms of one or more rotation and translation operations.
Suppose we have two coordinate systems, CS 1 and CS 2, having coincident origins, but having different orientations:
Let i,j,k and m,n,o be unit vectors as shown. These are called basis vectors. The transformation between the two coordinate systems can be obtained as follows.

The elements of the top-left 3x3 portion of any geometric transformation are really the basis vectors of the local coordinate system expressed in the coordinates of the new coordinate system.
How many floating-point multiplies, additions, and divides does it take to transform one vertex to device coordinates? Assume that the modelview and projection matrices could potentially have 16 non-zero elements.
How many vertices need to be transformed in order to render a set of 10 triangles using a triangle strip such as obtained when using GL_TRIANGLE_STRIP ?
Vectors only define a direction, not a position. A simple method of transforming vectors exists when the transformation involves only translations, rotations, and uniform scaling. This can be accomplished by transforming a vector much like we transform a point, except using a different value for the homogenous parameter, h. What value should be assigned to h for vectors?
Hint: Transformations are applied to points by augmenting the three-dimensional coordinate with a fourth homogeneous parameter, h=1. This allows for translations and rotations to be combined in a single 4x4 transformation matrix.
We will now determine a method for transforming normals which works for all types of transformations. To do this, we will write the plane equation for a polygon and determine the transformed plane equation. Write the implicit equation for a plane. Rewrite this equation as a dot product between a vector containing the plane parameters, N, and a point in homogeneous coordinates, P, namely NTP = 0. If we apply a transformation M to any point on the plane, e.g., P' = M P, we need to apply an unknown transformation matrix Q to the vector N, e.g., N' = Q N. Solve for Q as a function of M.
Consider the point P and the three coordinate frames O, A, and B below:
Notation: MRS is a 3x3 homogeneous matrix, and PR=(x,y,1) is a homogeneous point in coordinate frame S, such that
Write down the 4x4 matrix for scaling an object by 35% in all directions.