2.7 Applications to Computer Graphics

  • Computer graphics are images displayed or animated on a computer screen.
  • Applications of computer graphics are widespread and growing rapidly.
  • For instance, computer aided design (CAD) is an integral part of many engineering processes.

Most interactive computer software for business and industry makes use of computer graphics in the screen displays and for other functions, such as

  • graphical display of data,
  • desktop publishing, and
  • slide production for commercial and educational presentations.

Consequently, anyone studying a computer language invariably spends time learning how to use at least two-dimensional (2D) graphics.

This section examines some of the basic mathematics used to manipulate and display graphical images.

  • Often, curved lines are approximated by short straight-line segments, and
  • a figure is defined mathematically by a list of points.

EXAMPLE 1

The capital letter N in Figure 1 is determined by eight points, or vertices. The coordinates of the points can be stored in a data matrix, .

fig1 fig1a

In addition to , it is necessary to specify which vertices are connected by lines, but we omit this detail.


The main reason graphical objects are described by collections of straight-line segments is that the standard transformations in computer graphics map line segments onto other line segments.

Once the vertices that describe an object have been transformed, their images can be connected with the appropriate straight lines to produce the complete image of the original object.

EXAMPLE 2

Given , describe the effect of the shear transformation on the letter in Example 1.

Solution

By definition of matrix multiplication, the columns of the product AD contain the images of the vertices of the letter N.

The transformed vertices are plotted in Figure 2, along with connecting line segments that correspond to those in the original figure.

fig2


The mathematics of computer graphics is intimately connected with matrix multiplication. Unfortunately, translating an object on a screen does not correspond directly to matrix multiplication because translation is not a linear transformation. The standard way to avoid this difficulty is to introduce what are called homogeneous coordinates.

Homogeneous Coordinates

Each point in can be identified with the point on the plane in that lies one unit above the -plane.

We say that has homogeneous coordinates .

  • For instance, the point (0, 0) has homogeneous coordinates (0, 0, 1).

Homogeneous coordinates for points are not added or multiplied by scalars, but they can be transformed via multiplication by matrices.

Translation

In homogeneous coordinates, the translation can be computed via matrix multiplication:

Example 5

Any linear transformation on is represented with respect to homogeneous coordinates by a partitioned matrix of the form , where is a matrix. Typical examples are

fig

Composite Transformations

  • The movement of a figure on a computer screen often requires two or more basic transformations.
  • The composition of such transformations corresponds to matrix multiplication when homogeneous coordinates are used.

EXAMPLE 6

Find the matrix that corresponds to the composite transformation of a scaling by .3, a rotation of about the origin, and finally a translation that adds (-.5, 2) to each point of a figure.

Solution

If , then and . From Examples 4 and 5, we have

fig

The matrix for the composite transformation is

Homogeneous 3D Coordinates

By analogy with the 2D case, we say that are homogeneous coordinates for the point in . In general, are homogeneous coordinates for if and

  • Each nonzero scalar multiple of gives a set of homogeneous coordinates for
  • For instance, both (10,-6,14, 2) and (-15, 9,-21,-3) are homogeneous coordinates for (5,-3,7).

EXAMPLE 7 :

Give matrices for the following transformations:

  • a. Rotation about the y-axis through an angle of . (By convention, a positive angle is the counterclockwise direction when looking toward the origin from the positive half of the axis of rotation—in this case, the y-axis.)
  • b. Translation by the vector .

Solution

fig05

a.

First, construct the matrix for the rotation.

  • The vector rotates down toward the negative -axis, stopping at .
  • The vector on the -axis does not move, but
  • on the -axis rotates down toward the positive -axis, stopping at .
  • See Figure 5. From Section 1.9, the standdard matrix for this rotation is

So the rotation matrix for homogeneous coordinates is

b.

We want to map to . The matrix that does this is

Perspective Projections

A three-dimensional object is represented on the two-dimensional computer screen by projecting the object onto a viewing plane. (We ignore other important steps, such as selecting the portion of the viewing plane to display on the screen.)

For simplicity, let

  • the -plane represent the computer screen, and imagine that
  • the eye of a viewer is along the positive -axis, at a point .

A perspective projection maps each point onto an image point so that the two points and the eye position, called the center of projection, are on a line. See Figure 6(a).

fig6

The triangle in the -plane in Figure 6(a) is redrawn in part (b) showing the lengths of line segments. Similar triangles show that

Similarly,

Using homogeneous coordinates, we can represent the perspective projection by a matrix, say, . We want to map into . Scaling these coordinates by , we can also use as homogeneous coordinates for the images. Now it is easy to display . In fact,

results matching ""

    No results matching ""