Upload
sriram-murthy
View
221
Download
0
Embed Size (px)
Citation preview
7/24/2019 Mod 2 Dda Line Drawing Algorithm
1/20
Line Drawing Algorithms
7/24/2019 Mod 2 Dda Line Drawing Algorithm
2/20
Rasterization-Process ofdetermining which pixels give thebest approximation to a desired lineon the screen.
Scan Conversion-Digitizing apictre definition given in anapplication program into a set of
pixel intensit! vales for storage inthe frame bffer.
7/24/2019 Mod 2 Dda Line Drawing Algorithm
3/20
7/24/2019 Mod 2 Dda Line Drawing Algorithm
4/20
Points-Point plotting is accomplished b!
converting a single coordinate position in
an application program into appropriate
operations for the otpt device in se.
Line- Line drawing is accomplished b!calclating intermediate positions along the
line path between ( specified end point
positions. )he otpt device is directed tofill these positions between the end points.
7/24/2019 Mod 2 Dda Line Drawing Algorithm
5/20
0 1 2 3 4
0
1
2
3
4
Scan Line
nmber
Pixel Colmn
nmber
7/24/2019 Mod 2 Dda Line Drawing Algorithm
6/20
7/24/2019 Mod 2 Dda Line Drawing Algorithm
7/20
7/24/2019 Mod 2 Dda Line Drawing Algorithm
8/20
7/24/2019 Mod 2 Dda Line Drawing Algorithm
9/20
7/24/2019 Mod 2 Dda Line Drawing Algorithm
10/20
x* x(
!*
!(
Straight line segment with + sampling
positions along the x axis and ! axis
7/24/2019 Mod 2 Dda Line Drawing Algorithm
11/20
)he Cartesian slope intercept e,n for
straight line is ! m x b
/x*0!*1 2 /x(0!(1be the two endpointsof the line0 then m/!(-!*1%/x(-x*1
b !*- mx*
i.e !* mx* b
!( mx( b/31 4/(1
/ !(-!*1 m /x( 4 x*1
m/!(-!*1%/x(-x*1 ie 5!% 5x
/(1
/31
/*1
7/24/2019 Mod 2 Dda Line Drawing Algorithm
12/20
6or an! given x interval 5xalong a line0
compte the corresponding ! interval
5!as 5! m5x
Similarl! the x interval is obtained as
5x 5! %m
)he above e,ns form the basis for
determining deflection voltages.
7/24/2019 Mod 2 Dda Line Drawing Algorithm
13/20
Lines with slope magnitde 7m7 8*0 5x is setproportional to a small horizontal deflectionvoltage and the corresponding verticaldeflection voltage 5! is 5! m5x
5x9 5!
Lines with slope magnitde 7m7 9*0 5!is setproportional to a small vertical deflectionvoltage and the corresponding horizontal
deflection voltage is 5x 5! %m
5!9 5x
P*
P(
P(
7/24/2019 Mod 2 Dda Line Drawing Algorithm
14/20
Digital Differential Algorithm(DDA)
Scan conversion algorithm based on
calclating either 5x or 5!. Sample the line at nit intervals in one
coordinate and determine the corresponding
integer vales nearest the line path for the other
coordinate.
Case *
Line with positive slope less than or e,al to *0
we sample at nit x intervals /5x*1 anddetermine the sccessive ! vale as
:$* :$ m5!m 5x
:$*- :$ m 5x
:$*- :$ m /5x *1
7/24/2019 Mod 2 Dda Line Drawing Algorithm
15/20
$ ta$es integer vales starting from *andincreases b! *ntil the final point is reached.
mcan be an! nmber between ;and *.
Calclated !vales mst be ronded off tothe nearest integer.
6or lines with positive slope greater than *0sample at nit ! intervals /5! *1 and
calclate each sccessive x vale asx$.* x$ *%m
)he above e,ns are based on the assmption
that lines are processed from left to right.
7/24/2019 Mod 2 Dda Line Drawing Algorithm
16/20
Steps
P* / xa0!a1 and P( /xb0!b1are the two end points.
(. =orizontal and vertical differences between the
endpoint positions are compted 2 assigned to
two parameters namel! dxand d!.
3. )he difference with greater magnitde
determines the >vale?of increments to be done.
)hat means the nmber of times sampling has to
be done. )his vale is assigned to a parametercalled >steps?.
7/24/2019 Mod 2 Dda Line Drawing Algorithm
17/20
@. Starting from the *stpixel 0we determine theoffset needed at each step to generate the
next pixel position along the line path. Callthe offset vale as xincrementand !increment.
)he starting points are xa and !a.
Assign x xa and !!a
x x xincr 2 ! ! !incr
+. Loop throgh the process steps times0 tillthe last point xb0 !b is reached.
P*
/xa0!a1
P(
/xb0!b1
7/24/2019 Mod 2 Dda Line Drawing Algorithm
18/20
Step * Accept as inpt the ( end point
pixel position.
P*/xa0!a1 P( /xb0 !b1
Step ( =orizontal and vertical
differences between the endpoint
positions are compted 2 assigned totwo parameters namel! dx and d!.
dx xb 4 xa d! !b - !a
Steps for DDA Algorithm
7/24/2019 Mod 2 Dda Line Drawing Algorithm
19/20
Step 3
7/24/2019 Mod 2 Dda Line Drawing Algorithm
20/20
Advantages
DDA algorithm is a faster method forcalclating the pixel positions than the direct
se of line e,ation.