0% found this document useful (0 votes)
34 views19 pages

CG Lecture3 V

The document discusses two methods for raster scan conversion of lines: 1. Digital Differential Analyzer (DDA) samples lines at integer intervals in one axis and calculates the corresponding values in the other axis based on the slope. It handles different cases based on whether the slope is positive or negative and greater or less than 1. 2. Bresenham's line algorithm performs scan conversion using only incremental integer calculations to avoid rounding errors. Both methods approximate lines on raster displays by plotting discrete pixels nearest to the true line path. DDA is faster than direct calculation but rounding errors can cause drift over long lines.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views19 pages

CG Lecture3 V

The document discusses two methods for raster scan conversion of lines: 1. Digital Differential Analyzer (DDA) samples lines at integer intervals in one axis and calculates the corresponding values in the other axis based on the slope. It handles different cases based on whether the slope is positive or negative and greater or less than 1. 2. Bresenham's line algorithm performs scan conversion using only incremental integer calculations to avoid rounding errors. Both methods approximate lines on raster displays by plotting discrete pixels nearest to the true line path. DDA is faster than direct calculation but rounding errors can cause drift over long lines.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Lecturer:

Dr. Mohammed S. H. Al-Tamimi

3rd Class / 1st Semester / 2020-2021


Email: [email protected]
Picture Descriptions:
1- Raster:
Completely specified by the set of intensities for the
pixels positions in the display.
The shapes and colors are described with pixel arrays.
Scene displayed by loading pixels array into the frame
buffer.
2- Vector:
Set of complex objects positioned at specified
coordinates locations within the scene.
The shapes and colors are described with sets of basic
geometric structures.
Scene is displayed by scan converting the geometric-
structure specifications into pixel patterns.
Output Primitives:
 Basic geometric structures used to describe scenes.
 Can be grouped into more complex structures.
 Each one is specified with input coordinate data and
other information about the way that object is to be
displayed.
 Examples: point, line and circle each one with specified
coordinates.
 Construct the vector picture.
Digital Representation:
 Display screen is divided into scan lines and columns.
 The pixels positions are referenced according to scan
line number and column number (columns across scan
lines).
 Scan lines start from 0 at screen bottom, and columns
start from 0 at the screen left side.
 The screen locations (or pixels) are referenced with
integer values.
 The frame buffer stores the intensities temporarily.
 Video controller reads from the frame buffer and plots
the screen pixels.
 The converting a single
coordinate position furnished by an
application program into appropriate
operation for the output device in
use.
 In raster system:
o BLACK-WHITE: Setting the
bit value corresponding to a
specified screen position within
the frame buffer to 1.
o RGB: Loading the frame buffer
with the color codes for the
intensities that are to be displayed
at the screen pixel positions.
 A straight line is specified by two endpoint positions.
 Line drawing is done by:
 Calculating intermediate positions between the endpoints.
 Directing the output device to fill in the calculated positions
as in the case of plotting single points.
 Plotted positions may be only approximations to the actual
line positions between endpoints.
 A computed position (10.48,20.51) is converted to pixel
(10,21).
 This rounding causes the lines to be displayed with a stair
step appearance.
 Stair steps are noticeable in low resolution systems, it can
be improved by:
 Displaying lines on high resolution systems.
 Adjusting intensities along line path.
The Cartesian intercept equation for a straight line:
y= m. x+b
Where m is the line slop and b is y intercept.
 For line segment starting in (x1,y1) and ending in
(x2,y2), the slop is:
m= (y1-y2)/(x1-x2)
b= y1- m.x1
 For any given x interval ∆𝑥 , we can compute the
corresponding y interval ∆𝑦 :
∆𝑦 = m . ∆𝑥
 Or x interval ∆𝑥 from a given ∆𝑦 :
∆𝑥 = ∆𝑦/m
 On raster systems, lines are
plotted with pixels, and step
sizes in the horizontal and
vertical directions are
constrained by pixel
separations.

 Scan conversion process


samples a line at discrete
positions and determine the
nearest pixel to the line at each
sampled position.
 Digital Differential Analyzer (DDA):
Samples the line at unit intervals in one coordinate and
determine corresponding integer values nearest the line
path for the other coordinate.

 Bresenham’s Line Algorithm:


Scan converts lines using only incremental integer
calculations.
 Digital Differential Analyzer (DDA):
 A scan-conversion line algorithm based on
calculating either ∆𝑦 or ∆𝑥 using line points calculating
equations.
 In each case, choosing the sample axis depends on
the slop value.
 The unit step for the selected axis is 1.
 The other axis is calculated depending on the first
axis and the slop m.
 The next slides will show the different cases of the
slop:
 Digital Differential Analyzer (DDA):
Case 1: The slop is positive and less than 1.
 Sample at unit x interval (∆x =1) and compute each
successive y value as :
𝒚𝒌+𝟏 = 𝒚𝒌 + 𝒎
 K takes integer values starting from 1,at the first
point, and increasing by 1 on each step until reaching
the final endpoint.
 The calculated y must be rounded to the nearest
integer.
Example: Describe the line segment which starts at (3,3)
and ends at (23,7).

m = (7-3)/(23-3)
= 4/20
= 0.2
∆x =1 , ∆𝑦 =0.2
 Digital Differential Analyzer (DDA):
Case 2: The slop is positive and greter than 1.
 Sample at unit y interval (∆𝑦 =1) and compute each
successive y value as :
𝟏
𝒙𝒌+𝟏 = 𝒙𝒌 + ( )
𝒎
 K takes integer values starting from 1,at the first
point, and increasing by 1 on each step until reaching
the final endpoint.
 The calculated x must be rounded to the nearest
integer.
Example: Describe the line segment which starts at (3,3)
and ends at (7,23).

m = (23-3)/(7-3)
= 20/4
=5
∆x =1/m=1/5=0.2
∆𝑦 =1
 Digital Differential Analyzer (DDA):
Case 3: The slop is negative and its absolute value is
less than 1(Follow the same way in case 1).
Case 4: The slop is negative and its absolute value is
greter than 1(Follow the same way in case 2).
 In the previous 4 cases, we start from the left to the
right. If the state is reversed then:
 If the absolute slop is less than 1, set ∆x=-1
and 𝒚𝒌+𝟏 = 𝒚𝒌 − 𝒎
 If the absolute slop is less than 1, set ∆y=-1
𝟏
and 𝒙𝒌+𝟏 = 𝒙𝒌 − ( )
𝒎
 DDA Properties:
 A faster method for calculating pixel positions than
the direct use: y = m.x +b.
 Uses ∆x or ∆y to eliminate the multiplication in the
above equation.
 The Rounding successive additions of the floating-
point increment can cause the calculated pixel
positions to drift away from the true line path for
long line segment.
 Rounding and floating-point arithmetic are time-
consuming operations.

You might also like