Documente Academic
Documente Profesional
Documente Cultură
1
Problem with approximation Basic line drawing algorithm
Slope of a line
2
Example: (x1=1,y1=1)&(x2=6,y2=5) How the algorithm works?
= 0.2
x = 4, y = 3.4 ≈ 3 3
2
1
x = 5, y = 4.2 ≈ 4 1 2 3 4 5 6
3
DDA algorithm DDA algorithm (contd…)
Digital Differential Analyzer. Substituting (1) & (2) in m = ∆y/ ∆x, we get:
Incremental line generating algorithm. yi+1 = yi + m.∆x
Concept: perform calculations at each ∆x = 1
step, using the results of the previous yi+1 = yi + m _______ (3)
steps. xi+1 = xi + ∆y/m
At step i: (xi,yi). ∆y = 1
At step i+1: (xi+1,yi+1), use m = ∆y/ ∆x. xi+1 = xi + 1/m _______ (4)
∆y = yi+1 – yi _______ (1)
∆x = xi+1 – xi _______ (2)
4
Advantages & disadvantages of DDA