RatnadeepsinhJadeja
2,114 views
11 slides
Dec 26, 2016
Slide 1 of 11
1
2
3
4
5
6
7
8
9
10
11
About This Presentation
Random Scan system, Raster scan system, DDA algorithm, Bresenham's Algorithm,
Size: 618.66 KB
Language: en
Added: Dec 26, 2016
Slides: 11 pages
Slide Content
1
Prof. RATNADEEPSINH M. JADEJA
Assistant Professor
Mechanical Department
CHAPTER 2.2: INTERACTIVE COMPUTER GRAPHICS
Mechanical Engineering Department –School Of Engineering
RANDOM SCAN SYSTEM
2
InRandomScanSystem,anelectronbeamis
directedtoonlythosepartsofthescreenwherea
pictureistobedrawn.Thepictureisdrawnone
lineatatime,soalsocalledvectordisplaysor
strokewritingdisplays.Afterdrawingthepicture
thesystemcyclesbacktothefirstlineanddesign
allthelinesofthepicture30to60timeeach
second.
Mechanical Engineering Department –School Of Engineering
RASTER SCAN SYSTEM
3
Itisthemostcommontypeofgraphicsmonitorbasedontelevisiontechnology.Inaraster
scansystem,theelectronbeamissweptacrossthescreen,onerowatatimefromtopto
bottom.WhenelectronbeammovesacrosseachrowthebeamintensityisturnedONand
OFFtocreateapatternofilluminatedspots.Picturedefinitionisstoredinamemorycalled
framebufferwhichholdsthesetofintensityvalues,whicharethenretrievedfromtheframe
bufferandpointedonthescreenonerowatatimeasshowninfigurebelow:
Mechanical Engineering Department –School Of Engineering
REPRESENTATION OF LINE AND CIRCLE
4
Mechanical Engineering Department –School Of Engineering
DDA ALGORITHM
5
(Xn, Yn)
(X1, Y1)
ΔX
ΔY
XK XK+1
YK
YK+1
X
Y
Y = MX + C
=f=
ΔY
ΔX
=
R
R
=
ΔY=
R
R
ΔX ΔX=
R
R
ΔY
Y
K+1= Y
K+ ΔY
X
K+1= X
K+ ΔX
Similarly
Mechanical Engineering Department –School Of Engineering
DDA ALGORITHM
6
CASE 1 = −Mi > aJ −a1
ΔX= +1if Xn > X1
ΔX= -1if Xn < X1
Nnechenlp∶
ΔY=
R
R
ΔX
Y
K+1= Y
K+ ΔY
X
K+1= X
K+ ΔX
CASE 2 = aJ −a1 > −Mi
ΔY= +1if Yn > Y1
ΔY= -1if Yn < Y1
Nnechenlp∶
ΔX=
R
R
ΔY
Y
K+1= Y
K+ ΔY
X
K+1= X
K+ ΔX
Mechanical Engineering Department –School Of Engineering
EXAMPLE
7
EXAMPLE 1: Generate a straight line connecting two points (1, 2) and (8, 6) using DDA algorithm.
X1 = 1
Xn = 8
Y1 = 2
Yn = 6
Estimation of increments
Xn –X1 = 8 –1 = 7
Yn –Y1 = 6 –2 = 4
−Mi > aJ −a1
and Xn >X1
So, ΔX = 1
and
ΔY=
R
R
ΔX =
g
–
= 0.571
Mechanical Engineering Department –School Of Engineering
BRESENHAM’S ALGORITHM
9
1.Input the two end points (X1, Y1) and (Xn, Yn).
2.Calculate : Xc = Xn –X1 and Yc = Yn –Y1
If Xc > Yc then slop is less then 1 so, ΔX = 1
3. Calculate the starting value of decision parameter P1 as P1 = 2Yc –Xc
4. If Pk < 0 The next point is (Xk+1, Yk) and Pk+1 = Pk + 2Yc
If Pk > 0 The next point is (Xk+1, Yk+1) and Pk+1 = Pk + 2Yc –2Xc
Mechanical Engineering Department –School Of Engineering
EXAMPLE
10
Example2:Generateastraightlineconnectingtwoendpoints(21,11)and(26,15)using
Bresenham’salgorithm.
Solution:
X1=21 Y1=11
X2=26 Y2=15
Xc=Xn–X1=26–21=5
Yc=Yn–Y1=15–11=4 (Xc>Yc,soslopislessthen1so,ΔX=1)
Point1:
(x1,y1)=(21,11)
P1=2Yc–Xc=8–5=3(P>0)
Point2:
X2=x1+Δx=21+1=22
Y2=Y1+Δy=11+1=12 (x2,y2)=(22,12)
P2=P1+2Yc–2Xc=3+8–10=1(P>0)
Mechanical Engineering Department –School Of Engineering
EXAMPLE cont..
11
Point3:
X3=x2+Δx=22+1=23
Y3=Y2+Δy=12+1=13 (x3,y3)=(23,13)
P3=P2+2Yc–2Xc=1+8–10=-1(P<0)
Point4:
X4=x3+Δx=23+1=24
Y4=Y3=13 (x4,y4)=(24,13)
P4=P3+2Yc=-1+8=7 (P>0)
Point5:
X5=x4+Δx=24+1=25
Y5=Y4+Δy=13+1=14 (x4,y4)=(25,14)
P5=P4+2Yc–2Xc=7+8–10=5(P>0)
Point6:
X6=x5+Δx=25+1=26
Y6=Y5+Δy=14+1=15 (x4,y4)=(26,15)
P6=P5+2Yc–2Xc=5+8–10=3(P>0)