university of missouri at columbia 2d scan-line conversion university of missouri at columbia

Post on 21-Dec-2015

222 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

University of Missouri at Columbia

2D Scan-line Conversion

University of Missouri at Columbia

University of Missouri at Columbia

2D Scan-line Conversion• DDA algorithm

• Bresenham’s algorithm

• DDA algorithm

• Bresenham’s algorithm

University of Missouri at Columbia

DDA algorithm• The simplest algorithm.

• Named after Digital Differential Analyzer.

• The simplest algorithm.

• Named after Digital Differential Analyzer.

(x1, y1)

(x0, y0)

dy

dxmySo

xxmy

m

dx

dy

xx

yym

,

1,

1001

01

University of Missouri at Columbia

DDA Algorithm

University of Missouri at Columbia

DDA Algorithm

University of Missouri at Columbia

DDA Algorithm

University of Missouri at Columbia

DDA Algorithm

University of Missouri at Columbia

DDA Algorithm

University of Missouri at Columbia

DDA Algorithm

University of Missouri at Columbia

2D Scan-line Conversion• DDA algorithm

• Bresenham’s algorithm

• DDA algorithm

• Bresenham’s algorithm

University of Missouri at Columbia

Bresenham’s Midpoint Algorithm• DDA is simple, efficient, but needs floating points.• Bresenham’s use integer addition only.

• DDA is simple, efficient, but needs floating points.• Bresenham’s use integer addition only.

(x1, y1)

(x0, y0)

dy

dx

University of Missouri at Columbia

Bresenham’s Midpoint Algorithm• To choose from the two pixels NE or E depending on the relative

position of the midpoint M and the line.

• Choose E if M is above the line,

• Choose NE if M is below the line.

• To choose from the two pixels NE or E depending on the relative position of the midpoint M and the line.

• Choose E if M is above the line,

• Choose NE if M is below the line.

M

E

NE

(x0, y0)

University of Missouri at Columbia

Bresenham’s Midpoint Algorithm

M

E

NE

(x0, y0)0),(

so line, theon is ),(point Since

0),(

:formImplicit

:equation Line

0000

00

dxbydxxdyyxF

yx

dxbydxxdyyxF

bxdx

dybmxy

• Choose NE if d is positive,

• Choose E if d is negative.

• Choose NE if d is positive,

• Choose E if d is negative.

University of Missouri at Columbia

Bresenham’s Midpoint Algorithm

M

E

NE

(x0, y0)

dxdyd

dxdyyxF

dxdyyxF

d

2

2),1(2

),1(

: variabledecision the

of value theon depends choice The

1

21

00

21

21

00

• Choose NE if d is positive,

• Choose E if d is negative.

• Choose NE if d is positive,

• Choose E if d is negative.

University of Missouri at Columbia

Incremental Calculation of the decision variable dnew

dxdyd

dxbydxxdy

yxFd

NEif

dyd

dxbydxxdy

yxFd

Eif

dxbydxxdyyxFdSince

old

new

old

new

22

2)(2)2(2

),2(2

, choose

2

2)(2)2(2

),2(2

, choose

222),(2

23

00

23

00

21

00

21

00

M

E

NE

(x0, y0)

University of Missouri at Columbia

Bresenham’s Midpoint Algorithm

M

E

NE

(x0, y0)

NEfxyd

Eifydd

old

oldnew choose ,22

choose ,2

top related