SLIDE 1
Drawing Algorithms Rasterization Pixelization Scan Conversion - - PowerPoint PPT Presentation
Drawing Algorithms Rasterization Pixelization Scan Conversion - - PowerPoint PPT Presentation
Drawing Algorithms Rasterization Pixelization Scan Conversion Continuous Discrete Line Drawing Algorithms Line Equation: (x 2 ,y 2 ) y mx B = + - dy y y y 2 1 m = = = y - dx x x x 2 1 (x 1 ,y 1 ) x DDA
SLIDE 2
SLIDE 3
Line Drawing Algorithms
B x x m y B mx y B mx y
i i i i i i
+ Δ + = + = + =
+ + +
) (
1 1 1
DDA (Digital Differential Analyzer)
(x1,y1) (x2,y2) Δx Δy
SLIDE 4
Line Drawing Algorithms
1 1 if
1 1
m y y x x x
i i i i
+ = + = = Δ
+ +
DDA (Digital Differential Analyzer)
(x1,y1) (x2,y2) Δx Δy
SLIDE 5
DDA (Digital Differential Analyzer)
Line Drawing Algorithms
(xi, round(yi) )
y = y1 for (x = x1; x ≤ x2; x ++) { Writepixel(x, round (y)); y+ = m; }
SLIDE 6
DDA (Digital Differential Analyzer)
Line Drawing Algorithms
m <= 1 m > 1
Exchange the role of x and y
SLIDE 7
Midpoint Line Algorithm
Line Drawing Algorithms
M NE E Line
above below
Find on what side of the line the mid point is: If below then NE is closer to line If above then E is closer to line
SLIDE 8
Midpoint Line Algorithm
M NE E Line M’’ M’ P(xp,yp)
line above y) (x, : < y) F(x, line below y) (x, : > y) F(x, line
- n
y) (x, : = y) F(x,
SLIDE 9
Midpoint Line Algorithm
M NE E Line M’’ M’ P(xp,yp)
Bdx) c dx, b dy, (a ) , ( line Consider 1 m Let = = = = + = + + = + = < <= <=
- Bdx
ydx xdy c by ax y x F B x dx dy y
SLIDE 10
Midpoint Line Algorithm
M NE E Line M’’ M’ P(xp,yp)
E choose line, the above is M d if NE choose line, the below is M > d if ) 2 1 ( ) 1 ( ) 2 1 , 1 ( ) ( < + + + + = = + + = c y b x a d d y x F M F
p p p p
SLIDE 11
Midpoint Line Algorithm
Line M NE E M’’ M’ P(xp,yp)
dy a d d c y b x a d c y b x a d y x F M F d
- ld
new E p p
- ld
p p new p p new
= = = + + + + = + + + + = + + = =
Δ
- )
2 1 ( ) 1 ( ) 2 1 ( ) 2 ( ) 2 1 , 2 ( ) ' ( : E When
SLIDE 12
Midpoint Line Algorithm
Line
dx dy b a d d c y b x a d c y b x a d y x F M F d
- ld
new NE p p
- ld
p p new p p new
- )
2 1 ( ) 1 ( ) 2 3 ( ) 2 ( ) 2 3 , 2 ( ) ' ' ( : NE When = + = = + + + + = + + + + = + + = =
Δ
M NE E M’’ M’ P(xp,yp)
SLIDE 13
Midpoint Line Algorithm
) ( 2 ) , ( (division) 2
- dy
= 2 2 ) 2 1 ( ) 1 ( ) 2 1 , 1 ( : start At c by ax y x F dx b a d b a c by ax d c y b x a y x F d
start start start
+ + = + = + + + + = + + + + = + + =
SLIDE 14
While end y); (x, Writepixel end 1; = y+ 1; = x+ E; = d+ else 1; = x+ E; = d+ d if x2) < (x While y); (x, Writepixel y1; = y x1; = x dx);
- 2(dy
= NE 2dy; = E dx;
- 2dy
= d y1;
- y2
= dy x1;
- x2
= dx N Δ Δ ≤ Δ Δ
Midpoint Line Algorithm
SLIDE 15
Midpoint Circle Algorithm
(x,y)
2 2 2
R y x = +
SLIDE 16
Midpoint Circle Algorithm
(x,y)
2 2 2
R y x = +
SLIDE 17
Midpoint Circle Algorithm
(x,y)
SLIDE 18
Midpoint Circle Algorithm
(x,y) (y,x) (y,-x) (-x,y) (-y,x) (-y,-x) (-x,-y) (x,-y) 8-way symmetry: drawing in one octant is enough
SLIDE 19
Midpoint Circle Algorithm
Consider II octant
M E SE M’’ M’ P(xp, yp)
circle inside y) (x, : < y) F(x, circle
- utside
y) (x, : > y) F(x, circle
- n
y) (x, : = y) F(x, y) (x, point given a For
2 2 2
- R
y x y x F + = ) , (
SLIDE 20
Midpoint Circle Algorithm
SE Choose circle)
- utside
(M > If E Choose circle) inside (M < If F(M) Evaluate → →
Consider II octant
M E SE M’’ M’ P(xp, yp)
SLIDE 21
3 2 ) 2 1 ( ) 2 ( ) 2 1 , 2 ( ) ' ( ) (d E When ) 2 1 ( ) 1 ( ) 2 1 , 1 ( ) (
2 2 2
- ld
2 2 2
+ = − = − − + + = − + = = < − − + + = − + = =
Δ
p
- ld
new E p p p p new p p p p
- ld
x d d R y x y x F M F d R y x y x F M F d
Midpoint Circle Algorithm
Consider II octant
M E SE M’’ M’ P(xp, yp)
SLIDE 22
Midpoint Circle Algorithm
Consider II octant
5 2 2 ) 2 3 ( ) 2 ( ) 2 3 , 2 ( ) ' ' ( ) (d SE When
2 2 2
- ld
+ − = − = − − + + = − + = = ≥
Δ
p p
- ld
new SE p p p p new
y x d d R y x y x F M F d
M E SE M’’ M’ P(xp, yp)
SLIDE 23
Midpoint Circle Algorithm
Consider II octant
R R F Initial − = − 4 5 ) 2 1 , 1 ( ) 2 1
- R
(1, = point mid next point, start R) (0, Condition
M E SE M’’ M’ P(xp, yp)
SLIDE 24
Midpoint Circle Algorithm
Consider II octant
While end y); (x, Writepixel end 1; = y- 1; = x+ 5; + 2y
- 2x
= d+ else 1; = x+ 3; + 2x = d+ d if do x) > (y While y); (x, Writepixel R;
- 4
5 = d R; = y 0; = x
<
SLIDE 25