Está en la página 1de 12

GEOMETRY AND LIGHT GENERATIONS

Basic Geometry
The smallest element which can be shown on a graph is a point. A point may be
illustrated as following figure.

As we can see, A point A has been positioned in XY-plane and (x1, y1 is the position of a point
A. This means that point A is at distance x1 in X-direction and it is at distance y1 in Y-direction
from origin (!, !. The ordered pair (x1, y1 is "nown as the coordinates of point A. The #alues
of x1 and y1 are the hori$ontal and #ertical distance respecti#ely of the point A from the origin.

Straight Line and Line Segment
Any two points specified in a plane will define a line. This means, to define a line one needs at
least two points. %n following figure, two points &1(x1, y1 and &'(x', y' define a line l1.

(ow, to define a line we need an e)uation*
A point (xi, yi is said to be on the line if and only if it satisfy the e)uation of line. The
e)uation of a straight line can be deri#ed with the help of slope of concept of a straight
line, which measures the steepness of it.
The slope is the rate at which an ordinate of point of a plane changes with respect to a
change in the hori$ontal coordinate. This can be measured by the ratio between the
differences of #ertical coordinates of two points on the line to that of hori$ontal
coordinates of those two points. +enerally the notion slope is denoted by m. Thus,
m,-ertical distance between two points . /ori$ontal distance between two pints.
Assume two points &1(x1, y1 and &'(x', y' on a line l1. 0or this line slope is,
m, y' 1 y1 . x' 1 x1
2lope of any line can be of four types* the straight line with positi#e slope, the straight
line with negati#e slope, the line with $ero slope and the line with undefined slope.
These types are illustrated by following figures.

To deri#e an e)uation of a line the concept of slope is used. The slope between any two
points of a line always remains constant. 3et us consider two points &1(x1, y1 and
&'(x', y' on a line and also assume point (x, y on the same line. According to the
e)uation of a straight line, the slope between any two points is constant. The slope is
m, y
'
1 y . x
'
1 x and also m, y
'
1 y
1
. x
'
1 x
1
y , mx 4 b 55 6)uation ('.1
The general form of a straight line is,
ax 4 by 4 c , !

Pie!s and "rame B#$$er
The pixel is a smallest addressable screen element. %t is the smallest piece of the display
screen which we can control. 6ach pixel has name and address. The name which identify
pixel corresponding to the coordinates which identify the points.
7omputer +raphics images are made by setting the intensity and color of pixel which
compose the screen. 8e draw line segment by setting the intensity that is the brightness
of pixels between starting pixel and ending pixel. The coordinate will be (%, 9 that gi#es
column and row of a pixel. 6ach pixel will be centered at the coordinate. 8e can place
the inter #alues of all the pixels into an array of our computer memory that is called as
frame buffer.
2o frame buffer is used to collect and store the pixel #alue for the use by a display de#ice.
Line Sty!es
There are four different types of lines*
1. Thic" 3ine
'. 3ine 7aps
:. Thic" 3ine ;oints
<. &ens and =rushes
%& Thic' !ine
A line or a line segment generated by the standard >>A algorithm is of a single pixel width. 3et
us assume that a line with a gentle slope, that is, a slope less than one. %f u need such a line
segment with a thic"ness of three pixels, you need to put there a #ertical span of three pixel for
each #alue of x. Thus a line with any width w, can be generated 9ust by putting a #ertical span of
(w.' pixels on both the side of the central line. 2ee below figure*

3et &
1
(x
1
, y
1
and &
'
(x
'
, y
'
be the end points of a line segment with width w, which is to be
drawn. /ere two parallel line segments will be drawn from a central line (x
1
, y
1
and (x
'
, y
'
at
distance (w.'.



As shown in abo#e figure, the coordinate of end points of the upper and lower line boundaries
are (x1, y1 4 wy(x', y' 4 wy and (x1, y1 1 wy(x', y' 1 wy respecti#ely. The #alue of wy is
gi#en as below.
w
y
, w 1 1 (2)rt(x
'
1 x
1

'
4 (y
'
1 y
1

'
. ' ?x
'
1 x
1
?

%n the abo#e e)uation, w 1 1 is ta"en instead of w. the reason being, on both sides the line
boundaries are drawn which are of 1 pixel in length. Therefore, from both the sides half of the
pixel width will be deducted to get the exact width w.

(& Line )a*s
There is an issue with the thic" line generated by the concept discussed here. 8hen the thic" line
is generated it ends are the hori$ontal or #ertical. This effect becomes e#en more prominent with
thic"er lines. To remo#e this effect, line caps can be used. There are : main such line caps used
in graphics applications. They are butt cap, round cap and pro9ecting s)uare cap as illustrated in
following figure.

The butt cap is one with which the end position of the thic" lines are ad9usted in such a
way that the line segment appears with a s)uare ends. The ends of such thic" line are
perpendicular to the original line segment.

=elow figure shows the construct of butt cap.

%n a round cap, the upper and lower line boundaries are 9oined by a circular arch or with a
semi-circle of diameter of width same as the width of line segment.
=elow figure shows the construct of round cap.

%n pro9ecting s)uare cap, the portion of line segment is 9ust extended to gi#e a line segment an
effect of s)uare.

=elow figure shows the construct of pro9ect s)uare cap.

+& Thic' Lines ,oint
8hen two thic" line segments are connected with each other, they create problems at the
9oining point. 8hen two thic" line segments are 9oined an angel is created at the 9oining
point, as shown in the circle of figure below, because of the thic"ness.
The discreetness that occurs while 9oining two thic" lines can be remo#ed from the polylines by
adding some additional portion to the 9oint as some specific type of 9oining process. These 9oints
are miter 9oint, round 9oint and be#el 9oint as shown in following figure.
The miter 9oint is one in which the exterior boundaries of two thic" line segments are
extended upto their intersection point-the point where these two line segments meet each
other, if they are extended.
%n round 9oint, the exterior boundaries are connected with a circular arch with a diameter
of total thic"ness of two thic" lines, which are 9oined.
The be#el 9oint is one where butt cap is used to draw line segment and the little triangle
that is created at the 9oint is filled with color of these two line segments.
The following figure shows the construct of abo#e three 9oints.
-& Pens and Br#shes
There are many graphics applications, which ma"e use of different pens and brushes of
different shapes. >ifferent color is also used with different shapes of pens and brushes.
2ome of the brush shapes are shown in following figure.
)haracter Generation
7haracter almost built into the graphics display de#ice usually as hardware but
sometimes through software.
There are two primary methods for character generation.
%& Stro'e Method
This method uses the small line segments to generate a
character. The small series of line segments are drawn li"e a stro"e of a pen to form a character
as shown in the following figure.






8e could build our own stro"e method of character generation by calling the -67+6( line
drawing algorithm. 8e could decide what line segments are needed for each character and setup
the calls to the -67+6( line drawing algorithm for each character we wish to draw.
The stro"e method itself changes the scale means if you want to twice a character length then in
simply increase the length of each segment.
(& Dot Matri Or Bitma* Method
%t is also called as dot matrix because in this method
characters are represented by an array of dots. %t is a two dimensional array ha#ing columns and
rows. An @ X A array is commonly used to represent a character as shown in the following figure.

/owe#er A X B and B X 1: arrays are also used. /igh resolution de#ices such as in9ect printer or
laser printer may use character array that are o#er 1!! X 1!!.
6ach dot in matrix is a pixel. The character is placed on the screen by copying the pixel #alues
from the character array into some portion of the screenCs frame buffer.
The dot patterns for all characters are stored in the hardware de#ice called a charactergenerator
chi*. The character generator chip accepts address for the character and gi#es a bit pattern as an
output.

A!iasing and Anti.a!iasing
8e ha#e seen the method bitmap which is used to draw the image. The bitmap method is a
method in which an array of indi#idual pixels is used. These pixels ha#e some shapes and
dimensions too. 8hen a line segment of an image is enlarged, the image is loo"ed with $aggy
boundaries as shown in following figure.

También podría gustarte