Professional Documents
Culture Documents
References:
1. Andy Johnson's CS 488 Course Notes, Lecture 1
2. Foley, Van Dam, Feiner, and Hughes, "Computer Graphics - Principles and
Practice", Chapter 1
What is Computer Graphics (CG)
The generation of graphical images using a computer, as opposed to "image
processing" which manipulates images that are already in the computer. Creating a
frame of "Toy Story" or "Jurassic Park" is computer graphics; Comparing an image of
a face from an ATM camera against a database of known criminal mugshots is
image processing. Note that the line between the two can sometimes be hazy, and
a given task may require both sets of skills.
A.J.:
mathematics + computer science + art = computer graphics
rendering of images on a device.
rendering - creating images from models
models - objects constructed from geometric primitives (points, lines, polygons)
specified by their vertices
models exist in n-dimensional 'mathematically pure' space
o
n typically 2 or 3
Common Uses
Movies, such as Toy Story, Who Framed Roger Rabbit, The Hollow Man, Shrek,
Monsters Inc, Jurassic Park, & The Perfect Storm
Advertisements
scientific/medical visualization
CAD/CAM
multimedia
virtual reality
special effects
artistic expression
Software
Many application programs available to produce computer graphics, either as 2D
images, 3D models, or animated sequences (Corel Draw, Photoshop, AutoCAD,
Maya, SoftImage, etc.)
We will deal with the lower level routines which do the work of converting models
into a displayable form on the display device.
Several 'common' graphics languages/libaries/APIs (Application Programming
Interfaces.)
GKS
DirectX
Postscript
OpenGL
Clipping
Since we have a separation between the models and the image created from
those models, there can be parts of the model that do not appear in the
can clip analytically - knowing where the clip rectangle is clipping can be
done before scan-line converting a graphics primitive (point, line, polygon) by
altering the graphics primitive so the new version lies entirely within the clip
rectangle
can clip by brute force (scissoring) - scan convert the entire primitive but only
display those pixels within the clip rectangle by checking each pixel to see if
it is visible.
Point Clipping
point (X,Y)
clipping rectangle with corners (Xmin,Ymin) (Xmax,Ymax)
(the sign bit being the most significant bit in the binary representation of the
value. This bit is '1' if the number is negative, and '0' if the number is
positive.)
-----+------+-----
-----+------+-----
move left to right across the code to find a 1 bit -> the crossed edge
break the line segment into 2 line segments at the crossed edge
forget about the new line segment lying completely outside the clip rectangle
The full algorithm ( was? ) given (in C) in the red book ( ??? Edition ) as
program 3.7 on p.105.
The full algorithm is given (in C) in the white book as figure 3.41 on p.116.
if s is inside and p is outside the clip rectangle -> output i (the intersection of
edge sp with the clip edge)
if s and p are both outside the clip rectangle -> output nothing
if s is outside and p is inside the clip rectangle -> output i (the intersection of
edge sp with the clip edge) and then p
This algorithm can break a single polygon into multiple polygons connected
by edges on the boundary of the clipping rectangle for display.
The full algorithm ( was? ) given (in C) in the red book ( ??? Ediiton ) as
program 3.9 on p.114.
The full algorithm is given (in Pascal) in the white book as program 3.49 on
p.128.
4-5 : keep 5'-5 and clip 4-5' -> add 5' and 5
8-9 : keep 9'-9 and clip 8-9' -> add 9' and 9
the new vertex sequence is then checked against the Ymin edge and so on
through the Xmax edge and the Xmin edge
2 More Examples
Rasterisation (or rasterization) is the task of taking an image described in a vector graphics format
(shapes) and converting it into a raster image (pixels or dots) for output on avideo display or printer, or
for storage in a bitmap file format.
In normal usage, the term refers to the popular rendering algorithm for displaying three-dimensional
shapes on a computer.[citation needed] Rasterisation is currently the most popular technique for producing
real-time 3D computer graphics. Real-time applications need to respond immediately to user input, and
generally need to produce frame rates of at least 24 frames per second to achieve smooth animation.
Compared with other rendering techniques such as ray tracing, rasterization is extremely fast.
However, rasterization is simply the process of computing the mapping from scene geometry to pixels
and does not prescribe a particular way to compute the color of those pixels. Shading,
including programmable shading, may be based on physical light transport, or artistic intent.
Transformations[edit]
Transformations are usually performed by matrix multiplication. Quaternion math may also be used but that is
outside the scope of this article. The main transformations aretranslation, scaling, rotation, and projection. A
three-dimensional vertex may be transformed by augmenting an extra variable (known as a "homogeneous
variable") and left multiplying the resulting 4-component vertex by a 4 x 4 transformation matrix.
A translation is simply the movement of a point from its original location to another location in 3-space by a
constant offset. Translations can be represented by the following matrix:
X, Y, and Z are the values by which each of the 3-dimensions are multiplied. Asymmetric scaling can
be accomplished by varying the values of X, Y, and Z.
Rotation matrices depend on the axis around which a point is to be rotated.
Rotation about the X-axis:
F and N here are the distances of the far and near viewing planes, respectively. The
resulting four vector will be a vector where the homogeneous variable is not 1.
Homogenizing the vector, or multiplying it by the inverse of the homogeneous
variable such that the homogeneous variable becomes unitary, gives us our
resulting 2-D location in the x and y coordinates.