Bresenhems line Genration derivation for Mtech

123 views 11 slides Jan 16, 2024
Slide 1
Slide 1 of 11
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11

About This Presentation

Its a derivation with steps and some numerical that may help


Slide Content

Bresenham’sLine Generation
Algorithm
Dr. R. B. Chadge
Department of Mechanical Engineering
YCCE, Nagpur

Introduction
•Computergraphicsusethreedifferenttypesof
algorithmstogeneratelinesnamely:
1)DDALinedrawingalgorithm
2)BresenhamLinedrawingalgorithm
3)MidPointLinedrawingalgorithm

Introduction
•ThisalgorithmisnamedafterBresenham.Here,themain
taskistofindalltheintermediatepointsrequiredfor
drawinglineABonthecomputerscreenofpixels.
•Inthisalgorithm,everypixelhasintegercoordinates.
Apartfromthat,theBresenhamalgorithmworkson
additionandsubtractionoperations.
•Ithasmoreprecisionoraccuracyandthecomplexityof
calculationissimple.

Bresenham’sLine Generation Algorithm
•GiventhecoordinateoftwopointsA(x1,y1)and
B(x2,y2).
•Thetaskistofindalltheintermediatepoints
requiredfordrawinglineABonthecomputerscreen
ofpixels.
•Notethateverypixelhasintegercoordinates.

Bresenham’sLine Generation Algorithm
•Examples:
1. Input : A(0,0), B(4,4)
Output : (0,0), (1,1), (2,2), (3,3), (4,4)
2. Input : A(0,0), B(4,2)
Output : (0,0), (1,0), (2,1), (3,1), (4,2)

Bresenham’sLine Generation Algorithm
•Belowaresomeassumptionstokeepthealgorithm
simple.
1.Wedrawlinesfromlefttoright.
2.x1<x2andy1<y2
3.Slopeofthelineisbetween0and1.Wedrawaline
fromlowerlefttoupperright.

Bresenham’sLine Generation Algorithm
•TheideaofBresenham’salgorithmistoavoid
floatingpointmultiplicationandadditiontocompute
mx+c,andthencomputetheroundvalueof(mx+
c)ineverystep.
•InBresenham’salgorithm,wemoveacrossthex-axis
inunitintervals.

Bresenham’sLine Generation Algorithm
•Wealwaysincreasexby1,andwechooseabout
nexty,whetherweneedtogotoy+1orremainony.
•Inotherwords,fromanyposition(X
k,Y
k)weneedto
choosebetween(X
k+1,Y
k)and(X
k+1,Y
k+1).

Bresenham’sLine Generation Algorithm

•Wewouldliketopicktheyvalue(amongY
k+1and
Y
k)correspondingtoapointthatisclosertothe
originalline.
•Weneedadecisionparametertodecidewhetherto
pickY
k+1orY
kasthenextpoint.
•Theideaistokeeptrackofslopeerrorfromthe
previousincrementtoy.
Bresenham’sLine Generation Algorithm

•Iftheslopeerrorbecomesgreaterthan0.5,weknow
thatthelinehasmovedupwardsonepixelandthat
wemustincrementourycoordinateandreadjustthe
errortorepresentthedistancefromthetopofthe
newpixel–whichisdonebysubtractingonefrom
theerror.
Bresenham’sLine Generation Algorithm
Tags