Drawing Algorithms Rasterization Pixelization Scan Conversion - - PowerPoint PPT Presentation

drawing algorithms
SMART_READER_LITE
LIVE PREVIEW

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-1
SLIDE 1

Rasterization

Drawing Algorithms

Pixelization Scan Conversion Continuous Discrete

slide-2
SLIDE 2

DDA (Digital Differential Analyzer)

Line Drawing Algorithms

Line Equation:

(x1,y1) (x2,y2) Δx Δy

B mx y + =

1 2 1 2

x y x x y y dx dy m Δ Δ = = =

slide-3
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
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
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
SLIDE 6

DDA (Digital Differential Analyzer)

Line Drawing Algorithms

m <= 1 m > 1

Exchange the role of x and y

slide-7
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
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
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
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
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
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
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
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
SLIDE 15

Midpoint Circle Algorithm

(x,y)

2 2 2

R y x = +

slide-16
SLIDE 16

Midpoint Circle Algorithm

(x,y)

2 2 2

R y x = +

slide-17
SLIDE 17

Midpoint Circle Algorithm

(x,y)

slide-18
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
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
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
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
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
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
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
SLIDE 25

Ellipse Drawing Algorithm

E SE S SE

1 = b y + a x

2 2 2 2