0% found this document useful (0 votes)
20 views7 pages

COMP 321 ODELNotes Viewing

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

COMP 321 ODELNotes Viewing

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

1

6. O T H E R GRAPHICS CONCEPTS

6.3.1: INTRODUCTION
Note that two dimensional viewing involves transferring positions from
the world co-ordinate plane to pixel positions on the 2D view surface
(plane) of the screen, and clipping the scene against boundaries of the
view port.

Three dimensional viewing is more complex than two dimensional


viewing because there are various options we should decide on;
 An object can be viewed from various positions i.e. from the
front, from the back, from above, etc.
 There is an extra dimension i.e. the z-axis. The three dimension
(3D) object must be mapped into a 2D display device.
 The clipping boundary now encloses a volume of space.

Operations in Viewing
A series of three computer operations convert an object’s three
dimensional co-ordinates to pixel positions on screen. They are
transformations (modeling, viewing and projection), clipping, and
viewport transformation.

6.3.2: TRANSFORMATIONS
Transformations include modeling, viewing and projection
transformations.

These transformations are represented by matrix multiplications such


as rotations, scaling and translations. Combinations of these
operations are used to draw a scene.

(a) Modeling and Viewing Transformations

The camera analogy for modeling transformation is arranging the


scene to be photographed. The operations involved here a series of
translations, scaling and rotations.

The camera analogy for viewing transformation on the other hand is


setting up your tripod and pointing the camera at the scene. The
operations of translations, scaling and rotations are applied just like in
modeling transformations.

Modeling and viewing transformations orient the model and the


hardware relative to each other so as to obtain the desired image.
2

Note that applying modeling transformations on a scene is alternative


to applying viewing transformations.

Modeling and Viewing Transformations in OPENGL


We use the functions glTranslate(), glRotate(), and glScale()
described previously.

Note that most transformation commands multiply the current matrix


by the specified matrix, and then set the resulting matrix to be the
current matrix. It’s important in this case to clear the current matrix
and load it with identity matrix. This avoids continuing to work with
previous transformation matrices leading to errors. In OPEN GL, this is
accomplished by the following statement.

glLoadIdentity();

(b) Projections

Definition
Projection transformations are used to specify the field of view (e.g.
wide angle, normal, etc), what objects/portions of objects will be inside
the view volume (specification of portion to be seen), and how
objects are projected onto the screen.

Projections transform points in a co-ordinate system of dimension n


into points in a co-ordinate system of dimensions less than n. We shall
however limit ourselves to projections from 3D to 2D. In this case, we
thus map 3D objects onto 2D planes. Two basic projection methods are
parallel projections and perspective projection.

Parallel projections
In a parallel projection, the distance between the center of projection
and the projection plane is infinite as shown in the diagram below
whereby a line AB is projected into a line A’B’ from an infinite center of
projection.
3

Line AB
Line A’B’

Center of
projection
at infinity

Projection
Projectors Plane

In other words, co-ordinate positions are transformed to the view plane


along parallel lines.

This projection preserves the relative proportions of objects. It’s


applied in drafting to produce scale drawings of 3D objects.

The advantage of parallel projections is that they produce accurate


views of the various sides of objects. Their limitation is that they are
not realistic. We do not get realistic representation of the appearance
of a 3D object.

There are two categories of parallel projections i.e. orthographic


projections and oblique projections. Their difference is the relation
between the direction of the projection and the normal to the
projection plane.

Orthographic projections
The direction of the projection is perpendicular to the projection plane.

There are various types of orthographic projections.

Elevation projections are used to produce the front, side, and top
views of an object.

Plan view projections are used to produce the top view of an object.

Axonometric projections are used to produce more than one faces


of an object. An example is an isometric projection which can be
produced by aligning the projection plane so that it intersects each co-
ordinate axis in which the object is defined.
4

Orthographic projections are commonly applied in engineering and


architectural drawings.

Oblique projections
The direction of the projection is not perpendicular to the projection
plane.

Perspective projections
In a perspective projection, the distance between the center of
projection and the projection plane is finite as shown in the diagram
below whereby a line AB is projected into a line A’B’ from a finite
center of projection.

Line AB
Line A’B’

Center of
projection
Projection
Plane Projectors

In other words, co-ordinate positions are transformed to the view plane


along lines that converge at a point (center of projection).

Perspective projections do not preserve the relative proportion of


objects.

The advantage of perspective projections is that they produce realistic


views of objects. Their limitation is that they do not produce realistic
views of objects.

View Volumes
A view volume is a specification about the parts of the object that will
appear in the window. Only the parts inside the view volume appear in
the display, all the others are clipped.

In this case, the volume consists of four sides. These fours sides are
planes that pass through the edges of the window. The size of the
5

volume therefore depends on the size of the window, while the shape
of the volume depends on the type of the projection.

For a parallel projection, the view volume is an infinite parallel pipe


– with four planes.

For a perspective projection, the view volume is a pyramid with


apex at the center of projection.

A finite view volume is obtained by limiting the extent of the volume in


the z direction by using one or two additional planes known as the
near and the far planes (or the front and the back planes). This results
to a total of six planes for a finite view volume. For an orthographic
projection, the six planes form a rectangular parallel pipe. For a
perspective projection, the six planes form a frustum.

Clipping
All portions outside the view volume are discarded (ignored).

Projection Transformation in OPEN GL

(i) The glFrustum() function


It’s used for perspective projections. It has the following prototype.

void glFrustum(GLdouble left, GLdouble right, GLdouble


bottom, GLdouble top, GLdouble near, GLdouble far);

This function calculates a matrix that accomplishes perspective


projection and multiplies the current projection matrix (typically the
identity matrix) by it depending on the values of the parameters.

Illustration

right

top

left
Center of
projection

bottom
near
far
6

Note the shape of a frustum enclosed in six planes defined by the


above six parameters.

(ii) The gluPerspective() function


It’s also used for perspective projections just like glFrustum. It takes
the following prototype.

void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble


near, GLdouble far);

It creates a matrix for a symmetric perspective-view frustum and


multiplies the current matrix by it. The fovy argument is the angle of
the field of view in the x-y plane (its value must be between 0 and
180), aspect ration is the width of the frustum divided by its height.

height

width

Center of
projection

fovy
near
far

Aspect=(width/height)

(iii) The glOrtho() function


It’s used for orthographic projections. It has the following prototype.

glOrtho(GLdouble left, GLdouble right, GLdouble bottom,


GLdouble top, GLdouble near, GLdouble far);

This creates an orthographic parallel viewing volume.

top
far

left

right

bottom

near

far
Before a projection matrix is called, some preparations are usually
done. For example we need to specify that the current matrix is for a
projection transformation. This is done using the following function.

glMatrixMode(GL_PROJECTION);

6.3.3: VIEWPORT TRANSFORMATIONS

Definition
The viewport transformation specifies the shape of the available
screen area into which the image is mapped. This transformation can
be thought of as defining the size and location of the final processed
image e.g. whether it should be enlarged or shrunk.

Viewport Transformation in OPEN GL


This is done using the function glViewport() that takes the
following form.
glViewport(glint x, glint y, glint width, glint height);
This defines the origin of the available screen space within the window
(x and y), and the width and height of the available screen area, all
measured in pixels on the screen.

You might also like