Professional Documents
Culture Documents
65 Mohit Tiwari It2 CGM Assignment
65 Mohit Tiwari It2 CGM Assignment
bit 65Mohi
tTi
war
i
I
T2
CGMAs
signme
nt1
QUES1ForBRESENHAM'SLI
NEALGORIT
HM(Case-m>1)
,
Youhav
et oequatetheequat
ionsandde
terminet
hec
oor
dinat
esaswe
ll.
AnswerThi
salgori
thmisusedfors
canc onv
ert
ingali
ne.I
twasde v
e l
opedbyBre se
nham.
Itisane f
fic
ientmethod bec
auseiti
nv ol
vesonl
yinte
ge raddit
ion,subt
rac
tions,and
multi
pli
cat
ionoperat
ions
.Thes
eoperat
ionscanbeper
for
me dveryrapidl
ysoli
ne scanbe
generat
edquickl
y.
I
nthi
sme
thod,
nex
tpi
xels
ele
cte
dist
hatonewhohast
hel
eas
tdi
st
anc
efr
omt
ruel
ine
.
T
heme
thodwor
ksasf
oll
ows
:
As
sumeapi x
elP1'
(
x1'
,
y1'
)
,t
hensele
ctsubse
que ntpix
e l
sasweworkourmayt
otheni
ght
,one
pi
xelpos
it
ionatatimeinthehori
zont
aldir
ec t
iontowardP2'
(
x '
,
y
2 2'
).
Onc
eapi
xeli
nchoos
eatanys
tep
T
hene
xtpi
xeli
s
1.E
ithe
rtheonet
oit
sri
ght(
lowe
r-boundf
ort
hel
ine
)
2.Onet
opi
tsr
ightandup(
uppe
r-boundf
ort
hel
ine
)
Theli
nei
sbe s
tappr
oxi
mat
edbyt
hos
epi
xel
sthatf
allt
hel
eas
tdi
st
anc
efr
om t
hepat
h
bet
weenP1'
,
P2'
.
Gt
bit 65Mohi
tTi
war
i
I
T2
T
ochoosesthenextonebe
twe
ent
hebot
tompixe
lSandt
oppi
xelT
.
IfSischosen
Wehav ex
i+1=xi
+1 and yi+1=yi
IfTischos
en
Wehav ex
i+1=xi
+1 and yi+1=yi
+1
T
heac
tualycoordi
nat
esoft
hel
ineatx=x
i+1i
s
y=mxi
+1+b
Bres
enham'sL
ineAl
gor
ithm
Thedis
tanc
efromStotheact
uall
inei
nydi
rec
tion
s=y-yi
T
hedi
st
ancefromTt
otheac
tuall
inei
nydi
rec
tion
t=(
yi+
1)-y
Nowconsi
derthedi
ff
ere
ncebe
twe
ent
hes
e2di
st
anc
eval
ues
s–t
When(s-
t)<0⟹ s<t
T
hec
los
estpi
xeli
sS
Whe
n(s
-t)≥
0⟹ s<t
T
hec
los
estpi
xeli
sT
T
hisdi
ff
erenceis
s
-t=(y-yi
)-
[(
yi+
1)-y]
=2y-2yi-1
s
-t=
2m(
xi
+1)
+2b-
2yi
-1 [
Put
ti
ngt
hev
alueof
(1)
]
Subs
ti
tut
ingmbyBr e
senham'
sLineAl
gorit
hmandintr
oducingde
cis
ionv
ari
abl
e
di
=△x(s-
t)
di
=△x(2Br ese
nham'sL
ineAlgor
it
hm(xi
+1)
+2b-2yi
-1)
=2△xyi-2△y-1△x.
2b-2yi△x-△x
di
=2△y.x
i-2△x .
yi
+c
Whe
rec
=2△y+
△x(
2b-
1)
Wec anwrit
ethede c
isionv ar
iabledi+
1f orthene
xts
li
pon
di+
1=2△y.xi+1-2△x .
yi+1+
c
di+
1-di=
2△y. (xi
+1-xi
)-2△x (
yi+
1- yi
)
Si
ncex_(i
+1)
=xi
+1,
wehav e
di+
1+di=2△y.(xi+
1-xi
)-2△x (
yi+1-yi
)
Spec
ialCases
I
fchos
enpi
xeli
satt
het
oppi
xelT(
i.
e.
,di
≥0)
⟹ yi
+1=
yi+
1
Gt
bit 65Mohi
tTi
war
i
I
T2
di
+1=
di+
2△y-
2△x
I
fchos
enpi
xelisatt
hebot
tompi
xelT(
i.
e.
,di
<0)
⟹ yi
+1=
yi
di
+1=di+
2△y
F
inal
ly,
wec alc
ulated1
d1=
△x [2m(x
1+1)
+2b-
2y1-
1]
d1=
△x [2(
mx1+b-
y1)+
2m-1]
Si
ncemx
1+b-yi
=0andm=Br
ese
nham'
sLi
neAl
gor
it
hm,
wehav
e
d1=
2△y- △x
E
xampl
e:St
art
ingandE
ndi
ngpos
it
ionoft
hel
inear
e(1,
1)and(
8,5)
.Fi
ndi
nte
rme
diat
epoi
nts
.
Sol
uti
on:
x 1=1
y1= 1
x2 =
8
y2= 5
dx =x2-x1=8-1= 7
dy= y2-y1= 5-1=4
I1=2*∆y= 2*4=8
I2=2*(
∆y- ∆x )
= 2*
(4-
7)=
-6
d=I 1-∆x =8-7= 1
x y d=
d+I
1
orI
2
1 1 d+
I2=
1+(
-6)
=-5
2 2 d+
I1=
-5+
8=3
3 2 d+
I2=
3+(
-6)
=-3
4 3 d+
I1=
-3+
8=5
5 3 d+
I2=
5+(
-6)
=-1
6 4 d+
I1=
-1+
8=7
7 4 d+
I2=
7+(
-6)
=1
8 5
Gt
bit 65Mohi
tTi
war
i
I
T2
QUE
S2Mak
eac
ompl
etet
axonomyonT
opi
c–PROJ
ECT
ION.
AnswerPlanargeometri
cproje
cti
onsar
eclassi
fi
edbasedont
he proj
ect
ion
planeaswellascent
er
ofproje
ction.Apr
oje
ctoriss
aidtobea
li
ne pass
ingt
hroughapointi
nanobj ectandt
hec ent
erof
theproje
ct i
on.
Paral
lelproj
ecti
ons
Paral
lelproj
ect
ionformswhent
hecenterofthepr
ojec
tioni
spointi
ngtoinf
init
y.Allthe
proj
ect
or s
wi
ll
ef
fec
tiv
elybepar
all
eltoeachother
.Theimagesarenotre
ali
s t
icthroughthe
paral
lelproj
ect
ionwhe nc
omparedwit
ht hehumaneye.Thi
sisdi
videdi
ntotwot ypes:
Gt
bit 65Mohi
tTi
war
i
I
T2
I
T2
Ass
ignme nts
olut
ionsby:
Mohi
tTi
war
i
Batch:I
T-2
RollNo.65