13.003 Computational Geometry and Visualization

Viewing Transformations


The default OpenGL viewpoint is located at the origin, looking down the negative Z-axis. The geometry that we wish to view must either by moved to a position from which it can be seen from the default viewpoint, or the viewpoint must be moved so that it can see the geometry.

Note that the modeling and viewing transformations have an inverse relationship: rotating the model geometry in a positive direction about the X-axis is equivalent to rotating the viewpoint in a negative direction about the X-axis.

It is possible to build a viewing transformation by concatenating a series of translations and rotations, however, this can be quite complex. Instead, OpenGL provides a simplified function to define the transformation.

    double eyeX, eyeY, eyeZ;         /* viewpoint */
    double referX, referY, referZ;   /* reference point */
    double upX, upY, upZ;            /* view up vector */
    gluLookAt(eyeX, eyeY, eyeZ, referX, referY, referZ, upX, upY, upZ);

where (eyeX,eyeY,eyeZ) is the viewpoint, (referX,referY,referZ) is a point along the desired line of sight (if the point is at the center of the scene being looked at, it is usually referred to as the reference point), and (upX,upY,upZ) is the view up vector.

The view up vector is necessary to correctly orient the viewing with regard to rotation about the viewing direction. The coordinate system defined with the its origin at the viewpoint, its Z-axis pointing from the viewpoint to the reference point, its Y-axis in the direction of the view up vector, and its X-axis as necessary to complete a right handed system, is called the eye coordinate system.

Strictly speaking, the gluLookAt function is not a part of OpenGL. It is in the OpenGL utility library, a collection of useful utility functions. To use this function, remember to add the following line in your source file:

    #include <GL/glu.h>


On to "Projection Transformations"
Back to "Viewing and modeling transformations"
Back to "Lectures on OpenGL and Computer Graphics"