Download as pdf or txt
Download as pdf or txt
You are on page 1of 154

Y=Mtb

2-4
(a, ) ( Y)
-6)

(2) 2-8)
b Y-'m

An=

a Scam Comrey cin lime alaorith mb ased


Calcula fing ether dy a by:
ie Samble the ine at umit imevals in One Co oroinate
Cmd dtermime Correspomolimg imteger yaluus men vert the
ine þortb fa the other co oroi mafe

Vinod kumay COAC


Neic
itBy +X
=

LILIILlLLLLLLLLLLL
Nej
CAAt kumay W1mod
fm)
>4 Ay=-)
(-)
Nepativeclbpe
An=-+
torisut
Left mi>
utt
toright
þositive
sloþe(+)
Left
tovi
aht
Ay=|
Yk+=Y+n
Neics CAC kumaY Vimod
Repeat
M+increont n=
Colr); (n,y, xel piPut
met incre
ay) a(bs steh
else
CalAycalot
(M,)(,ts) þoir)s end too Read
ritbm Algo
84. Cale ls te, the biel þositions albng, a
between AI )om &(20 26) Diny strogat ime
H10, l) (n, 12:9) (2,136) (13 4y) y19
19:2)
(2, 2t)

Aa Galeals le the pìxel bostlons aleny a stragYt ine


beB een Al20, 2) omol B(1 1-) Vcng
Any (20 20) 19,19) (18 1949 ( ,t6) (0b 19

ComsiouY the ine tom( ) to (s 6) Uie gbH


algorithm t rastevi2e ls ne.
Am () trg2) (2b, 3) (39, ) (2,5) (!9
Ars
Consir he ineom oo) to (-b-i) Use the

oo) -) (22) 3-3) Ey-y-s) -6-)


Gs Calela t the birael bostions al ong 4straig st Aine
bot bten A(18,2) crdl B\ 2g I2) ving PA- algori

66 Calculs e tne Pixel bos fns along qtnug4t ine betutey


AlI24) cnl B(2920) uing hNA algeitn
Ars (2,0) (2d, i) (r94, 12)(144, ) (5:2,14) (ho, 1) oss,)
(4 2) li64, 13) /14-2, 19) (20,20)
gmplits macl

patbfa eea bgi file


Aipliug þixel
pat pi xe( x,Y )
vole.
Co ucinak bosiion
pixet
6T Calcaute t de biael bx1Hong qlor astragit int
be}ween A2 20) nol B(201o) ui sDA
(2, 20) (28 9) (136, 8) /14.4,17) (15-2,l) (s, 15) (164,4
(76, 13) (18-4, 12) (9.2 , ") (20, Jo)
Midpoint Algorithm -Notations
(xy+l. y-1), Line
Candidate Pixels

Midpoint
Current Pixel
( k: Vik)
(X7+1, yk)

Coordinates of Midpoint - (x+1, 'k+(1/2) )


Micpoint Algorithm:
Choice of the next pixel

Midpoint Below Line Midpoint Above Line


"If the midpoint is below the line, then the next
"If the midpoint is above the line. then the next pixel is (x+1. y+i).
p0xel is (x+1, y).

Vimd Kynay CoAC NOjd


Midpoint Algorithm:
Regions below and above the line.

Fa,y) 0 Fx,y) = 0
(for any poimt above line)

F(x,y) >0
(for any point below line)

Midpoint Algorithm
Decision Criteria

f,y) =0 FMP) <0

O F(MP) >0

Midpoint below line Midpoint above line

Midpoint Algorithm Story so far.

Midpolnt Below Line Midpoint Above Line


F>0 F,<0
Yk-1= Ykt1
Next pixel - (x+1, ykt1) Next pixel - (1+1, y)

Vime Kumay CoAC


Neid
Mid britkime,
i=,mm-bth Aragithm
i = mai)+b-) cli m+b}= t ) Mid pornt=4
1 (i )+ b-(it)
AY (Mit) +07.b- 4li+h)
=Ay()+ 8y +
Aab-itk)

then Yi =
23

VImod kumay coAC NOd


-Anbn

o
T
n2b-) Ay+ (=& bhere
b-24k+2
| 2n+)- oa-g
aioms
ic tlo these between oiHerm the
2
+bYk m(a+1) =
t m\)+b
md()MH,
ye) yonp
posit(M biatyels, the are ces choi CuY
mlAyonthm'
St M
LiAonha»
ne
But

PiNel
seleBe

Piel
(2, Ye) solhetey
, qt

qt

q=o
+Qy+ An b
SOAN- (ONVERTING A CIACLE
Acivde ih a symmetvical figuxe
my Cick-qenevo ting algorithm Can take advantage t
the civcle's Symmetryto blot eight þoints for ea Ch
Valu that the atgorithn calealtes
tigkt-ay Symmetvy iAvsed by redcing each Calcala tec)
þoint arou each4 s a
the þoimt (X,) on the circle, them we cam
Comm put seven other þbimtsmthe eicle: as' triviay

Eight ay Symmety a
Circle

- Therefore 9e meed
mee to Compute
Compyte omly 4s° oegree arc
to oe termjme the cì vcle Com þletely.

etining a civcle: +here ae two samorol


methoce me th ematicaly
dufininf a crcle. cemtereo at the origin:
1' PoLyNOMIAL METHO0- The first me thoc oltinea
oe
CiYcle with secend-orcley
bolymonjal equato)
here = +he - Co-oYolinat
t= tht 4- co-o Yeinata
Y= the ciYcle YaciuA
TO a a Circle we have

inthe Sector from


- 101h tis methed each n cotoyoint
x/n mo
q to4s° i feum o by stebking ntrom o to jor
each -coi coroimate is foumo by evaluatin y
tP{,Y)
each ste

One þro blen ith this Metboc thA thact it invoeA


time- Consuming Mutikieatio omol square- Ycot
Cþeyation at edch steb. the sþacing betleen
Þlottec PÌxe) þosiinA WiI| not be umìtorm
2: PARA METRIC METHO; T he Second tethe o
dafiming a cincle makes uic 57
trigomometric fmctioni
.
ohere - CuYYent amge
Y circle vaois
n= n- Co-orclinatk
t-t- Co-oroinat
-B4 this metho ei Ste Þbec fromoto ycm o etch valu ot

Com þs ta tion st th Valuy t sim8 om c s is even more


resuireal bt
time- Conumig than the ca clatibnA
+he ti rst ne t h o .
3Yesen ham's Civcle Al gorithm -This algorithm is btter
than the toalgornthr
CPolynomial 4 Parametrie methec ) because it avoida trigon
metric nd squam Yoet calculation by acoketing only
Jnte ger oberation invalving squares the Pisel
Sebaratit otamceA:
-The bes t
abþyoimation d the tyye cixcle will be oiseribio
those Pixels in the vastex thot fall the least oistano
from the trye circle
genevatel from qo om 4s ench m
pÓint closest to the trye circte Cam be founcl bt
taking either t acibma
() Move im the oiYecon One unit
() Move im the recion ome unit md Move
in the negative y arechon dne umit
Assume that (i.) au the co-oroi natyA o the
last sC am- Comverteo Þixel Uþon entering s teþi
Let the olistance from the orig1n to pixel T
Squaneol mìmus the olistameu to the trye ciycle Squarel
D(T) then the Aistanu trom the oxigin to
þixels
Squaeol mimus the distamte to the ty4e circle
Squarec) = D(s),
the co-oolimatis Tau(+, ¥) omol those
aru ( myt)then
D(T) =(y++
D(s) = (+)+|-r
thys funetin rov j dus a nvelative measuvememt
o1 the Sistamce frm the centey apixel to the
true eiYcle.
8 A) oill dlyay %be bositive (Ti0utsicla the true
\9 will alsaa be egaive(sis insidl thetre Ci
A Decisiom variable cl; May be oufimtol aa
dli DT)+ D(s)
He1c
dli= R(++ +%-y2y-0
)
Nuy)(y

uhen ci <o Je have D(Tk J o()| omd Pixel TiA


-Chteg. Soleete
have IDT))>\0s)| and Plel si7 selcte
hen lio. be
9e cisidn otànble oiu fr the
e Can also write the
nert steb:

di-d;= 2(1i4+)+ + ( i ) " ( )

Simu Xi
Mit M;+! We hawe
1
2
di+2{x+ 44*i+4) +Yi +(-24;-().
-Y-(+1-2%)
2

-;-t
2:

4 TiA the selectecl Þìxel ( di <o) thtn Yi i


oi oi+4; +6
4 si the selecteol Þ}xel (oi>) then
YiY-I
oli = a;+ 4;+ a -2-} 2(y+6
oi4 di+4xi+ 2-44t2 +6
i
Henu
di+4(Xi-i)+10
be have
oli + 4x; +6
olis
c; + 4(;-) +l
it
oli0
we set (,r) to be the
startiy þìel Co-orohet
ol= 2 b+1)4Y-yy
3-2
(
The algoritbm fo generating all he hizel te orelirzty
SCom- (onvertn a civcledvadisa
Imt =0, r, o=3- 2Y:
wile (ne=)
set bìxel(, ))
o= d+4n+6

A
Nueicalemblel
O calcula te the boind s to draw acirele hviy

Sol

3- 5

got biael (os)


oio then
d=d+Vx+8 o = + 4 46
d -+61

set þikel4,5)
d= -) 4+6 = 9
d= 944 I-s)+lo
..

get biqell2, 4)
d=34{2-4)
3H-8+0
+10
Y= 3 1

Sot pìxel(3)
s
o s 2,4 3,3
2- 3 -3

D,S l s ,4-3 3
50S S, 2 3.3
Y-xS, 0 s, |4 -z]3 ->
-3
-4-2 3-3

at t o)
Vsg miol pojt algorltrm

(2,8)
-6
(4)
2 (S6)
taid þeint circle
Drasing Algori thm
the mìa poimt circe
eight -ay symmet} o olraing
the cmclealgoritb also
to genevate itVes th*
Jt plots Ys
TO
fart
naw hs part a circle e take unit stebs in
he þoitive x aiyt etion md
to datermìme atch mate
mgke uesy dacisibn pranet
I close he tus þosc) ble 4 þo
tthe circle at ot eqth ste sitions
Pling þositon 41
hove to
-Theretore, ^atermìne whethe the pìxel at

þosition(+) a at positon+,
eloser 4o the crcde fa tis þurrpase
þarameter i ec:
)
ociaron

1
nid þeint circle
asing Algo7i thm
the mid point cicle
eght
-aSymmet} olroig
the ciTclealgoritm
Jt plota a to genevate it
fart sj the cicle e. from ó
To daw a be þart o t us':
A ircle be take Unit stebs in
he þosiive
olireetion cnd make Uue acis bn Pnramat
to determi ne atich
4he tuo ossi ble po
+o the circle bat ot eath she: sit0ns
-The tu presi ble þositsae
Sam plimN þsiion i . t;md)at
have to
-Theetore, e^atermine uhethe the pìxel at
þoeiton (M;+ 4) a at positonM;+, ) iA
closer to the chrcle- fa tùs þursase
þarameter iA we: oucison

()
+|
ee the tocast boundy,
chd erde
oothe outolea sifon
A þomld the dio,
Cirele totho ser clo iA 4;ine scom the Phael
on
((-)-y
-4tcivele(t
) , di
olapemolit

ioi+
di a(ni)+I-2
·in f(9 Cenbe

t initd Kau H ducì sby anqnt-ta Con be


ob}aim bg evalcti circde funeon att
Algoitm
J Read the moli ()
othe Circle

Q Plot a circle vai mio


do pormt crcle algcrithm whe
naciuy 0 Uts
plet)
(4,) (S,9) (6 0) ()
Q2: Plot o, enole bciNMid
pojnt algo tbm shese
radiy omd Cen ter is
else b (03) (43) (22)
(2
poimt cirole methd yhaoe
o==d+2n radiy -& Omo Ceoter i
+94 +/ at to)
(o 6) ,9) (28) (3 ty
(4,9) (5,6) (&)
ymmet bolats
igonometvic methocl ot Defini am
Th to loloig equaHons dafime tn elti se
mod
trigonometzicalb
: bsino +k
(4) - thu cyet covoli nats
(acaso +, bs

b sng h minor aA
th.k) Cyrnt angle
= eibse
Center
Trigonometrie
tton tt
odasci)
an ellibse
vaied from o to rf
T¦s a tbtd is aso imeieat

our stating bolmt Aa - (o b


we selict ei
theyT(+)
to be tRe met Pixel S(xyt,y)
The mio pojmt/ ta
verHcal ime commerHny T
Crid s is uyecl to olain
pchaeo folloaif decison
Mid pennt Else Algovithm

b
-atb=o
Pant

Pant

ast
iast Scan-Conve
bbose 4hect
SuÞbose tka
thattha We a to
Poii o,b), sa
stantm enteyif stebi On(Mi, i) be thu next
yteol ìxel bun S(j + -9 to
) w ctf Tonc S
Seuct e her T(+, Conme
Pixel thi verical i e barametey
mi bont o cacisiby
The the tolioLoj
"ALsee) to cutine blj)&)_tt
y;-) =
Pi= flM; +4, isinsioa 4he cuY ve mc! we chase
4k mìc) þermt
CuYve amd we chese
n the
Ast sice oY
ho mid pint
foy th mext steb.
fixei s . DecIsiDn Þgyamete
wtE the
Nti e Can

X; + we hane
Simu MiPia-fi= Bl(Mi))+l(i))

hane ti.,=
NoL we due u simi lay fomula t r part 2 tt tte c
SOPÞOk Pixel 4; 9) u ust been scom - Chw vev teol u pon entern

The mìd bot tu hori2on tal jme conn eei UOmd v io Ujed
Lo odee He oucision payametey
(j+*,Y:) =b(j+):-¢8
<o thi m bdint insida the cuYve onc vig chosen.

Sinu We hant

(39
)
th inital valy is cembuteal Usim tu originef elafimi t ai

mt Snt6
UNIT- |V

Tymsfoy ma ion iA dès cyibel n tuo categories:


i) Gheometric
Tyamstoy ma tion
(i) co- oYeinat Trams
forna on:
When 0bject itself in movecl rela Hve to qstati onary
Co-0rdmate System oY back gr04nd, YeterYeq a/
eometyìc trams formatom
The co- oroi nt system is moved yelatve to the
bbject cmd object ia held stasti omary then thK
Priesster mec co-OY inat tramsfcoY
maHom:
J- ieemetric TYansfoy mnations
Obj'
.:.

()TYamslati 0m: gm.t rqm sla om,am object


0s ousp la re agiven oi stam
qmd olirecHon fromitA original Posi tiom af +e
isblace memt i6 given by tt vectoY V= tn+ty J
THe mew objeet poimt play C am be fond
bt abbyin th transfoymaon Ty to PCx
matiy form
Tv
t

)Rotation a bot the origin


object i Yotated g
abot the ori gim The reetio o yotaion is Coumtercloc
wise it 8isa Positive amgle onñol clock
angle
wise if o is a Megahve
The trqns foy matiom t yota tHom Re i

YSIm (+9)
RiYsima,

Y COA Ca+0)

SImu YL=

h
3I
Re - SinO

we cqm rebyese ned im


-Sino
homogemou4
SIMe

Scali ng oith Res bect to the origin ; - Scaling i6is itku


£x þamding or Pyoss
Cbject There comþyessimng the dimemsioms ofan
u t o factors ao vsed in
tyans foY maHon ine: Sn omd Sy wheYe Syc IAscaiScala'
n

to0Ydinat

ung cestant greater ttam one incirat+;


Scaing
am Expamsien tt length: nc less han one,

The
Scaling trans fermatiom SSx, Sy
SSa,s,(P)
where = S nl
Sy't
Ssa, sy
n the hemegenecus Co-oy di natus
Ss,st Sy
t.
Scali ngy Trama for mation
MiYoY Retleci0m about qn Axis
YL.oY
tyeated asamiYYOY, +h obiet has a mirrYimae
CY Yetlec tim:
’The reflectin p'cj an object Poimt Pis located 4he
\ame distam fyem h mirYDY aA p The m1YYoY
yeflecion tramsfeymativn Ma asout t h Lazis is give

where x= n md g'=-t

6Y

Similayly,the mivvoy re flecHon about

p!

wheve a'=-x amd y'=y


S
Imverse heometric TyamsfoY ma tiom s
Each eometyic tramstor maHon has qn invexse wick
IS cescibed b 4ke obboSite ope vahon berformed by
the tyamstormaio

Tyanslationy T = Ty.
T, oY trans la tioninti opbosite
oi recjon
Rotati om, =R oYrotatiom /n he opposite
ciyecibn
Scalin Ssy= SVssy
Miroy vetlecion,
CO-CYmate TYqms fcy mation We kytli tat

tyans for maiom co-oycimate


am ob jet id made SystemiAtransfoY
stationary.
m

o'

OTYqms la tHon,-, J4 the y


n coovdinat system i
dis b
44e aiecon cm cB ous laced to a new Posi Hen, here
tame ot the oisblace memt
given by tha vectoy V=
s aPoimt in mew
tx1+ ty T, +h Co-oro má
Posi Hon is given by follw
Relgtion:
shere n'= n-t Omol

-Rotatiom qbout tu origi The n4 Sy stem i


(Yigin: Then the Cooyoimates otYotatec ' qbout the
a Poimt in both
Systems asu relate b +he ycta Hom tyqnsforma tHon Re
(,8') Re(g)

Ro

Pveof: Px)

(d-9)
tsino

7- Ysim (a-0)

ycoAo - nsin

Ro
-sim

scoling 0 dh Res hect to the OYigIm

Co-0yoy mate system is foy mel b leaving the Cign


qmo c0-oycumate axes Umchan geol, but htroduci
ci jeret umtb ot
measurememt aleng the n Cmdy axes.
J4 tta mew umits ar obtane 4rom the olol
mits
o a scai ng oy's Umits albng the naiA omcl Sy Umita
aleng the yarts ap followA

)
w
S and y
(2,1)

2 2

(a) old unit%

eo-rdinafe ccali trmtagtlon vei ccainf faete Sa2


Onol
factoy Sa=2 cmol sy ,

MiYoY Reflection qbout qm Axis

Hig the olal system about either n o asis, 1kt


Yelatiomsub between cooYcatis iB 4iven.by th
Ceovcin transto07 malioms M om d my
- For Retlecio abtt the naris- ('g)=b,

- Por Reflection about 4he azih

(U,-) (-,)

(a)
9
Jmvexse Co-ordi mate Trams formations!

translaticnim 1h obbos1Be
() TyanslatHon: = Ty OIYe cHen:
oþþosite Diyeeion
(H» Rota+iom; XA = R_Rotationim1ke

(iv) MirroY Relechon: - Momd ;= My


Comþosite Tyamsfor maions; tMoYe Con ples
eometric om d
Ct-cru nate tr ans foy matiens cgn be bilt frem t
basic tyms ttY MmuHe)6

ahout 4ne cther tha u ares cay he constructe tr

SoMe &%0mple:.
(ay inc the matrix that yebyesents yotate
an pbject by 30 about the origim

poimt P2-4)
CCS 30

(a)

- (b)
Com be focmel b'}
p'= Ro(P)
()= k() 2

Sescibe the trans toy maion that votats ar


object Point sW dagees about a fized
Cemter ot rotation
6 e oetey mjne the tronsfer mation Re.p in thre
steps
() trams late. sthat thu centeY o Ýotaticn pi at
....

(2) Pernfoym. ar etaton bt sdgrees about the eri g1n


3) trms late thi o 1 b ack to p.
2
2 1

im revexse- ovcley'
wite +te general form the matrì toY Yotaon
about a Point p(hi k)

Ro.p = COAO

COAD - Sim0 -hcoAD +ksinoth)


Sin.
-Pertorm a 4s rotatibn o4 triangle A(0,0)
,8(1,),C(S,
a) about thi oYigim ono
om
(b) abod th P-,-)
Matris for
A
tiangle-,
2

(Q The matrì
trotat4om 6

Heme A'= (o,0),o'= (0,5),amdl

Keys,p. = Rus Ty
nl2 -h/2 0
o
[a'o'e'= Rui[na) =

(7-) (25-)(-)

imd the transtormation +hat scales b


a umits in the oiteetion
(b) bumits im the yolireehon
) Sim uitameouçly aUmit mthe ojrecien
(md b Umit im the y ureetom
@). Tha Scaling tronstoymaHon abp\jeat to a bai nt Pw
Sa,-P. -

(G0() =()
(b) SLhP HeNU
PrP
(3)()=)
Sa,h P

(: B))=()
13
wite thu gemeyl form t ascaling matrid wit,
0ie
vespeet toa i edl Poimt P(hJ

Sab.p= TySa.h T-y


0 k 0 bo 0I-k

b
'-bk t k
(

t Maymity the triam gle 1oith veytices A(0,0).


B1,1), Omd c( s.2) to toice its size while
Keeping c(6.2) 4iyed
S1+2J

20-5
0 2-2

S2,2c o 22-2

S2,2, <B- 0-) 1


2 -2.

2
S2,2 'C.= -2
Dd metho

2 0-S
0| 2
--3
2

(9 escYibe the tramsfor maion Mwich Aeflecta


am objet abot a Lime .
- Lat ine have a yineycebt (0. b) Omcl qn
argleot incnatonguitb Yespect to th 94)
l Tyanslate the Inteys ecHen Points te the crigin
2 Rotate bË -0".so. that me
ineL align7 1wjth
3 MiyYtr -ye fect gbout the aAA'
4 Rotate back b4 9'
S: Tydmslat B hack to l e,b)
Hena tML =T, RoMh-T-y
ReMah
whh =bJ
ind th torm ot the mat rì foy reflecHon qbout
Lime L with slabe m omdy imtercebt (0, b)
V= bJ

C
Sjm

C C

m m4
/Jm+1
- bm
m+
b

ar
Retect. the diamomcl-sh el þoly gon ihose verieej
A ) B(0,), c( L,o) omd DCo,2.j about
(a The hori zenta ime y=l.
(b) the vey i cal ine =2 mal

wereprejent
mahi
homogne ous co- ormate
-2
-|
inet =L has t im ter cebt (o, 2) omol angle t
0
ML

methoc

- bn
m41.

m "yi+1

-|

MLV 0 10
0 -202 6 4 2

V=2.

Soltiby Htrs
0

- ho

.
iogle
abot ogin in ontielock oie ditchlo
Singo
Ro
singo

4ls o

owe that successie 20 rotaon s re qololiti


iTHREE- Dimension Gyabhics tyansfor nats

Geometyic tyans foymationk


an object obj iA Comsioloyed aA a set oy potA

J{ 4e Obyect move
Plx.)}
to a mew
Pos1tiom tten ne
tbjet obj' al ö uhose co -ovdinat Pointe p'( y J
Cam be obtaim el fyam e originl Points Pr.g.2) cb
thYough 1u abbieation at a qeom etric trmsfor mation
O Tyamslatiom
An objet iA cirbla cecl a givem
Distame cm Dixecio fxo YmitA
Disblacemet o tu Ggiml Positi o): The iYec i on cmc
tramslation iA given by avectoy
..
V.=.QI + bT+ Ck-..
Ne' c0-0ydimat s o tramslatec Pojt Cam be obtaine byt
equatiom
p'y2') = T[CX .2))

t b

The re_ures omogene eUs matrixtrnstor ma tiog cqm be


ExbreSsed as' C

Ty = 1
C b
Hemte from euntion )

@ scalingr The Prousr o com bressing nd


Ei panding omy ob jet cy tte Prouss
chamging tte bimensions of am object, is callsd scaling.

hagmificahin
scale facterA S= Sy
=S)s<).1henscing ia
The þoi ntA after
Scaing L01th res
calculated by 4ta followi ng relatio1
þe ct to oYigin canbe

P ' } : SP9.2)

tatri fom i

2.
where S=

S
Rotatiom about the oigin;
Rota Hoy about origim in turo
have comsideyeal
To tati om. Qut in Qm ang le st
dimensioal geom etry e
4hree rotatio om ol a centre
the angle o Aimemsional we hote Comsidr
Yotaton om ol an
theve may be three aXA ot Yotatio theretore
1
Cases -
Rotation about
2. Rotai om
- axis
abot
3: Rota i om about
-aais.
Rotati y abowt -axiB
-

z'=[simlt)
Re.j =

the matrìa tram sformati on iA


Roi =
sino

the bojnmt atter votation can be calculate by the tollosiy


equatte
p'x,g.) = Roi P(8,2) --D
Hemce from

Rotatiom about yaxia

= [sim (a+8))

coA-YSjma. sim9
2l Y oA
the tans tormation matrìa i
Sim o
Ro,j =

the þoint atter yotai om ana given by thefolloa. eyy


sim

otati on ab out - axis


Re,k =

Hmee the transfor matio matrl is


Rok= - sime
sime

point aftter otaton ans given ky the fllosiyegua tem


Co
6)
Rotatiom about any Axbityavy Axis im
To Þerform rotation ab out a lime
sþace
that is not
Pavallel to ome 6 the Ch-oxolimate axes 10ewe
Meeed to align the ime ith one f the first
ases thr ou~h soSome intermediat Corordi moe
trqmstormaHon.
ket am axis t ro tation i& sþecitied bt given
ume L whose Airection vecto 0SV
ond passi
through the þoint p the vequved tramfovmatio
imcludis the followin stebs'
Li Tramslate p to origin
2 Aign V with the mormal vectoy i.ek
3' Rotate byo about k

Hena Re.L= TpARe.AvTLp

be ean ind the alignmtnt vector as follogn


- þevform apbroþriate votatioms to mate the
ai stYotatiDm coimcidant witb the 2 axis
with any
Jn fact e Can.align the rotaton axia chaice
ur
64 the three Co-ovolna a weA Here
}z ai A0B arbitrary m emeral,making an
arbitrary axis þassing through the origin
co-oyolinati axes
Coim cioe with one t the
reswr two Suceessive rotatiom about the
nther two Co rorolima axes :
a Heve firut berfom Yota tËon ab out x axi Umtth
Yotatiom axiA IA In the zx plame
b" then þero mro ta tion
about y ai% Umtil the ro
axIA Coimcjoles ith the 2
axi:

eta,b,)
V= Qi+bj+ck

Ca)
*o imblementing steb a
fron triangle opB
Sim9= b
+he vequveol rotationiA

Ro,i b
abt x -ais
b

No
imble menting stet b trom fig ) We see that arotatin
ougrees iA Yequired omod so from triangle 099
Sim (-&a)= - Sim Q2 Om o
Cos(-Q) CoA8B+
them

abot
y-ayis

Sinte ivi=Ja-tte, amdimtroduei the motati on


\2=+c, e.fimd R-e,,j x Re,i.
Av = R-s Rai
-ab
2

Iv|
we caleulat the in vexse trams
vectoy k witb the vetoy V tomati on tnot gms
Ay
a
A = ~ab

-b'
2lv

ia
Patting togeth er all these stebs the Complet tramsformation

Re,L = Tp AyRekAyTP

oletime by the Co-oTolinats AlD,90)


B oThe Þyvamid omo o( D, o,1) iArotateo q q bout
B[1 ). o o) ctiom vector v= i+j+k
oie
the ine L thot has
thrognth origin: Pimdl the
Onol passing thevotated fi yre
Co -tYcimat

Ro,t = A RoAv
J

AY

3 3

3
1 Shear'-At -H tranu frmition hat s lants the shabp 7 qn 0 bject
I Calbo! the sheav trans fov mgtion:
Ttso Cmmon Shearing trans foy na Hons aYe Useol 0ne shifts
Ce eymate v alw nnd hev sitt y. coo oli nste vauy Howele
|1 both the Cases
C0
omy one
notes amd they bre seY ves it valu

4he XShear þreserves dhe Cooroli nstey but changes


he x valuy oich Cau ses yer ti cai ines to tilt right o
le ft as sho in boloy i gure

oYiginal object

objed afte -sher


s
1
shear- the hea þre seyves 4he - 0oYoinste but charges +he
wolus ytich ccues hori20ntal ine s fo transtorm imtt dnes
Wuph sloþe upa Don a shoym in the figue
belbw

Yiginal objeet

object atter shear


the tramsfe-mstion mstria fa t
sheaY is iven as

=x Omd '=+shy
shearing Relstive to bther Rateyenca Aime
-
e Cam ap Ksheara-sheY tramtor ma tions
to otheY etevea imes vels ive
Jn shear t rnsfor mtibn
Onch n 4-sheaY e can v.se
trouforme 4iby
tion msties refeventa lime he
fafe both Cu
Qu ai ven belas
(u)
shea with y yete vent sh, -shint
ine

t-sher with a vefevent1 dine


shy

A
PP he
Shearing tromtor mgion to Sjuare sith Alo o)
3(40) c{)l D(o) as
) given bela
shear þ07 meter vauu
valu o 0-s relstive tothe ine tr#
b)) sheaY Þarameter male or -l
relstive tathe kine Xnt =-)

sha -shSh r](o

)
þihelin
inde syslem( wcs) wcs is th rignt
Hamch artesian CobYdimat 8yslem ateh Coordi nas
drscri be 4h Picture 4hatIa to be dis blaye:
The bhysi cal Devico CooYolinati system:(PDG)!- pocsith
}- cooy
Co di nati
yemthat cevresbomds to tha cdeie or korkstation where

4T he NOYmaized Devis Co-oyc nai syste:(HDCS)N D(3


Is th vight-handad eo-oydi rt system in ubich th Aistlay
Gthe viua isplay levie ceY YespomdA to the unit
CIx)8quau hose lower etthamd CoymeY e at t

VIEWI NGTRANSOR mATION

The viewi trms foY matjon wichmabs PictuYe ceovdna


tes n thu wcs to isblay co -oyointsim thi Pcs iA
-formecl by 4h folbsim trqms fY mahom s
NoYM aliz atiom trdn sfor mation (N)
dunats,
eeoY dinati cus4en to NoYmalizeol Device CooY
worK Stgon tr ansfor matiomlwJ! abs mornaize
Deviet cDoydimatsto
physical ddavi es c00x di nag Hemee
yiewing tramsfor mation(w) e given as
Aþle eom for lergtb
umit sical phy Cny
measuY
ed
spa bject Calleol situatecli
objeet
is here sbauw the sbau! objeet
tor Momi Mentarl
viewport Ws Viewþort wS
wìmalo
vjewbot
sþau NoYmall
zed
nCoovol
at i vising windo
dsblaye be to
itis ohere etimes viewbort 4n
caleol
a vectangularmapbe
i WIndi A a
Hene aePort: view
devie
to Bisblay thu omWua
wtih
Hemca wjmdooin Callud draw0
ng a
Porfolmginy emseleeting
dn
dl mathod
for thoimela)
e Q
',csy Aisbay Seloctedl
for
natCooyoi Liorld A poytswindows"omd
vieo
vídec be to what' mes dui window
is 4t4 Henee
V- nsjou
h-insjo
Sare o Lave

V- ins joy

Sare Swre
ngthing
On ce al erces qre broceeafe One c b oinelb
boumdar,
+he negt
+he outat tist ot rertites is c Ppel aganst
windL bom dart
Going thnagh absve tor Cases we can
thot there are tso Jeey eatjze
þroceses in his agoritbm
vertRa (in siou- Dtslole test anol
2 Qeter mì nìng the inteYLece n the Þolygon
ecge Oml he ci in plame
ciþin: þolyaom Atheton -omd heiler
aty separ bol.gon conved eaphproeessin Omd
caVe Con
seþara b} slve tuo
algoithm nt 90rn boly
PPry beCam
gcon boly ran geocl qmd- sother1 bulinygons
onCave Cfe ime extame
ow ble5m fro the -
ti shon
in dsextmeoy
ines ith
layel bemay balygo cibbed gons boly Cave COn
0case in bt
ectly, coTY 30ns buly covea cps
thm agori pbig olciygon odgeman sutheland
-H the -
Algoritln ppinA gon þoly adgemam lano- thtr Su
<ss)

1nt cipPolva on (dcpt wNin. dcPt wax, int n wr2 pIn. et2 pOut!
hrst ' holds pointer Lo first point prores ted against a clip
edge s holds most recent coint procesed against an edge
wePt2 hrstL||N EDGEJ : ( ). 0, 0, 0 )
s(N_FDGE:
Cn 0

tor (i 0: in, i4)


clinOint (pia|i) Loft wMin, Hax, pOut first. s)
coseClip (wMin, wMax pOut, &cnt, hrst, s!
return lcn

Convex polygons are correctly clipped by tha Sutherland-Hodgeman algo


"rithm, but concave polygons may be displayei wi!h eatraneous lines,as denior
strated in Fig. 6-24. This occurs when the clipped polygon should have two or
more separate sections. But since there is onl,one otput vertex list, the last ver
tex in the list is always joined to the irst Vertex. There are several things we
could do to correctly display concave polygons. For one, we could split the con
cave polygon into two or more convex polygons and process each convex poly
gon separately. Another possibility is to modity the Sutherland-Hodgeman ap
proach to check the inal vertex list for multiple vertex points along any clip
window boundary and corretly join pairs of vertices Finaliy, we could use a
more general polygon clipper, såch as either the Weiler-Atherton algorithm or
the Weiler algorithm described in the ne&t section.

Weiler-Atherton Polyg:nClipping
Here, the verlex-prucess1ng procedures for window boundaries are modihed su
that concave polygons, are displayed correctty. Ttis clipping proced ure 'was de
veloped as a method for identifying visible Surfaces. and so it can be applied
with arbitrary polygon-clipping regions.
The basic idea in this algorithm is that instead of always proceeding around
the polygon edges as vertices are processed, we sometimes want to follow the
WIndow boundaries. Which path we follow depends on the polygon-processing
direction (clockwise or counterclockwise) and whether the pair of polygen ver
tices currently being, processed represents an outs1de-to-inside pair or an inside

Window

Figure 6-24
Clipping the concave polygoa m(a)
with the Sutherland- Hodgernar
a)
elipper produces the twu cunneted
areas in (tb).

242
Sertion 6-8
Polvgon Clipping
umel,l,
resu
(stop)

(resume

(b)

Iiqurr 6-25
Chp
Clipping a concave polygon (a) with the
Weiler -Atherton
algorith generates the two separate polygon areas
in (6).

to-outsidepair. For clockwise proccssing of polygon


ing rules: vertices, we use the follow
" For an
" For an
outside-to-inside pair of vertices, follow the polygon boundary.
inside-to-outside pair of vertices,. follow the window boundary in
a clockwise direction.

ln Fig 6-25, the processing


direction in the Weiler-Atherton algorithm and the re
sulting clipped polygon is shown for a rectangular clipping window.
An improvement on the
which applies constructive solidWeiler-Atherton algorithm is the Weiler algorithm,
against any polygon-clipping region. geometry ideas to clip an arbitrary clygon
this approach. For the two polygons inFigure 6-26 illustrates the general idea in
this figure, the correctly dipped
is calculated as the polygon
intersection of the clipping polygon and the polygon object.
Other Polygon-Clipping Algorithms
Various parametric
cipping And they areline-clipping
particularly
methods have also been adapted to polygon
well suited for clipping against convex poly
gon-clipping windows. The Liang-Barsky Line Clipper, for example, can be ex
tended to polygon clipping with a general approach
land-Hodgeman method. Parametric line representations similar to that of the Suther
polygon edges in order around the polygon are used to process
dures similar to perimeter using
those used in line clipping. region-testing proce

Figure 6-26
Clipping apolygon by determining
the intersection of two polygon
areas.

243
Poly gen nd cbping kinded shblo n in fia
"betew give ht it y vefices a t earh
cliki brunclhy
Vy
cipbif oindlo)

V
Ovgimed polygon verticer ae
t ter ciPig each boudgthe mes veri(es
are en ay
* A Suface
balygon
otchiq closed one amd boum b a
StYaght
TAe lime
ine segme nta i kmown aA
Þoly gom
liay that ensegment
in a ployg01 aa þ\ace
in Such a
co-ovoi natea o ome Segment iAis the
Stayti ng Co-oYoi nate o the
At least three ine segment mext segme nt
shoulol not be inegr
+ the Doly gon cam be
olivi ded i nto regulaY Þoly e
md ire gular poly gonA:
Regualar polygona au those Þolya0nA Whtie lergtb of all
efual no inter nallexternal angte betleen
Any turo Comneec edg an
came.
IrregualaY ÞolygoA a those Þoly gory otich have length
edge oli tterent omo the amgles bet ween my to
Conmected edei aru Bame
AmotheY classiHcaton t þol &0opne Covex on
Con cave bolj gona
() Con vex
Þol0mH the line CommecHng t
/mtevioY Þojnta 6, the Þlen
lie Com bleteljmsi oe the polt0n iA saio t be

Conveg

Twnggecquare, eetanle ou te xg mplea


A alygon
Surface ofichi q close one and bouno b a
St vaght ine sagme nta ia k
The lime Seg menti a ploygom nown aA Þoly go
liay that eno co-oyi nates aa lace im Sucn a
Stayti ng co-o Yoi matea 6f ome sogment is the
the next Segment
At least +hree ine sementa sheuol mot be ineqr
+ The Doly gon Cam be oi vi ol i
Om
nto regulay Þoly ge nR
IYYegula þoly g0mA.
k*qualr Polggona anu those poltgon4 Qhtse length al
egeA an eual on ol imter nellerernal amgle beteen
dnt t Con meeded edgs and
same
IYregua lar Þolygon an those boly g8ny totich have length
4 edge oi tterent Om o the amgles betoeen my turo
Conmecte ed ge aru 6qme
Anather classi icatibn poly 8gons one Con ver on
Con Cave
(h Comvex
Þolg0m the line Commeching to
/nterioY Þojnt 6 the
the Þal 9en
bletely imsi ou the Þolgg0n, iA &aio t be

Conve poly gon

Taingesauqre, eetangle u the EagMPlea


ci) CÑnCave þolyg0n'- he polyon 4hgt onane net
CoyVex CalnCave

oly gom ie, lime Joini ng any tup in teyio þoint


7 the Þoly gon iA not com ble tely¥ jn sios the polyg0n
below i guy hiA tybe poly sn plays am imbor'amt
yole im repre sentatom,shacin þatt eyn illing¢ þoly30y

A
A toB

Concave þoly 0n
AN IN S) DE AND OUT SI DE TEST

There ae thro metbode toY in ir out whether a


þeint i nsi oa the þoly g0n outaio the Polyg0n

n4 mer Metho
4. Eve - odd Method- * Jn
Jm tis vule we take qny
yetere
out sioe the þoly 90n by Com si oaYi ng A(M,) i

we aline seq ment beweem the þoint iy


ques io andl a vetren þoint kodh e
wtich i oud sio 4he poly90n:
Jmter sec Hon be wee n the edg8o th
þolygo n om o the ime
t 4 he Þoimt on he edg to be calld Qa iasioli botmt
þoimt
d t0 get 4 he qeruyate count edgA;-we
e sheul
chtose the þath that ol0ea not interse et th
þoly go vert itea
hen ine seg mext inierse eta e vertea 57
Þoly on thtn tht Coumting is Consioli ret the
tolloy
(oumt ì even i} the other endpointa the tus
segment hat meet at the intersecHinq vertee.
opbos1 te sidea o1 the Comstruceod line.

Rulu

odd count
Even Count

Co utr ver fe te see


Loimoung Nymber Rule
* 1winoimg Nyy mbex i an ltermative metod to
olaineintevioy
we coy nt
eqion.
how mamy ny mber o7 4imep the Þoyn
egeA wind aroumd 'a poy ieulay bojnt im t coynter
clckwlse iyeeHo9 omd we give each boumdy ine
CYosse a o yecHom nym ber Omd we sum th

oieot om um ber moi cate the irecHonthe


h
sgmi
Poggom eolge Bag dra nyelg Hve to the ine
We Comst rurted fathe tost
t there au tl says or a sioe to Crst the sid
Co uld be drown sartr belo te ine, crsIt; on
en od above the ne.ntà C C ,we g've the olirectr

Y
belo i t , Jn ti et we aire the a're ct0n

f m t direHom namber s o th sios that


tha Sy m
CDs tha Comstruetehorizomtel ime
Sef ment yielda thu wim ding numbev tth
boint

imolirg
boj nt is imi evìor otheroise
egiol
1
helse in
exterior yglon
rqlon:

edgea"haing
mborg ,
oyrecom
veabety

bichA mon-2ro Hene þolnt

Line
oi recliin mbe , .-) yes
beeivaytha
bjimling
S Aicat the Jnteio
even- d methoe yegiora Pl}o)
Basically lbe have t un ty e of res o
mork the
Boumoay- oletimed yegibn piycls that
otline +h* Yegion hav e. a unige.
heum
beym olary a
(oloY thal iA ot same aA the Coloy the
JnterioY PIgel Alg0th ns that as yse

boumdar-fill Alg0 rith ma

2 3 y S6 705

t Sn tev) Dy - tined'terior- cletinesqmreg0niA


a collectiont
-* pis elo &xtesior t yegio hme iterent ColovA.

2
JmteoRuqbn
cormplaed
Rely an 4 Conne ded o 8connted method o
oots bouror!loor
4- Corneted
hlow, abuk

pel n
pireli
betb.
*these cgorthma t also callcd Seed-4ll g n

Oe ant aseedtho bìxel )here We sterrt) Cmcy


YecoTsvely moye chn more sec da ae btan feo)
CoYrect color E ach ynt Seed Ares þonstble
ta colorig th þì xel at ita Þositio, Gn
+esin ta mes pixela gyoumdit tare- that
have to be colo re
h reglom a collec on 8 p)xel. Aregey
4- Com qmecte it everg 2 Pix e be Jomecd

2- bikela b joimeal by for oiagona


Pxels aa also emclosec anegh bogs

4-Conme teo
piel þixel
the abþroach to fillirg a bound-ineo re9 13
to stat at a aint ixel) callaol a seed /nsrolo h
ns cnd þaunt th Qzta þrog ve ssively tojay)
boudar tli methol ia caltuot Bovindary-fill algar

q samble þixel ( caled t seed ixel) from th ,a


fill celoY valu and a boundary colbY yalue
t the Seed Þixel 0s AYst set to fi| csloy o le ita neighbou

boumdar colaindt fou nd then theJe piaela a set


to ill cafo similay neighoouys thes neighbo uring

there qs tuo apbvoache fa bounclay til| algY


vitbm aA felleua

Stork-Bosed -AbÞroaoh
bouaoy setedy rola bou
qory nd
fillmcl shecited
by Color fil poarh
a)t qp
bayedstacke- aoti the ConmeeBeo
fill
me
BaseArh' stack- (2)
preteyre
nolar) boumdlar-Hll(,
-, bey
bsu il, +
nolrg) bourdarg-I1(,
beymdar
1) f (, pixel get
boundary)
then
el( bìz Get GlOm ol .)< kel 14Get
bi
boumoart boumoarg-fill
0, , recuve! Pro
bsunda (,9),
1), Seorbixel :Put J
Agrihm'
boundng speified
by celorboundaryY
mol H, byciied Sþe oY
col 4)Precedure
with
RecUYEVe. metbo:
i dt fi0 N-Canne
cte
Algoitkm
Jmput seed Pixel (ny), il, bou ndary
PUsH Þiel (, )
tile (stack not emb

Set pìxel( M, 4 f)

bounclon) then
omd
(x-1,y)-ol Get bixel(M4}<> bovndor
i4(Qet þiaet
then
PucH Pijelt a-)

then
pusH PidelC, +)' bounda
i4 GetPjked (u.y-) illnd Get Plael(,-)
hen PuCH Pixel (n, -)

Plord fill algorith ms


ta filling inojor-odtine
Algorith np vged
fill algor h
Yegibry a generaly KrNanan fleod
arm algorithm stata toith a seed pidel by reblacig
Such usig thi 4
ita existHy color with fil1 Caor then eta l coloy
or Q- Conne eteof ohoun the
algo rithm
other interioy pixela A u ming that al th
+o th a eftned yegion have Some
imgn )nteior-
)nte rior difined
piaela
Color, ts fload fil| algorith m tey mina when mo
Proreclre emd
colo) old colo, i1(,4+,
L Plon
old.calor) fldil(4,9,
HW-color
hen bldCaler (n)=: pine1t(Get
Color) 4lLcoloy,
olo. flonclHIn
(,9 Prorere
tolor ;11-coloy,
o. .) Þinel seed- JnPut;
Algovithm
I|-calo. by
citied 8he Celo
new ornc lolor old sheified
by col -i|| old with
algoihm
vng fill
tlad te aiing tlnathe,
o apbrRecursive )
cola. old the hve þirel Cenmete Mre
-!m the atva ttin terminology
sèlime- Rebre sem tatiom! A Sbline is a flexi ble
strib U.sedl to þrodyce
a Smooth Curve through a 0esigmated set of þoimts
SevevalalSmall 1oeight ara distyi but eol alorg the length
the strip to hel it im posi ion on the olraftinf
table a the CUYve i& Yawn
-Jm Combuter Grapkica 4he term spline Curve
re fer to an com posite cUYve foY mel with þolymsmial
SectHons satsfximg specifiesl Cominut conoditioma
at the boundary 5 the Þicces'
-A sblime surface cam be cuscvibe oith two sets y
orthogona sbline cUYVea'
- there ae several di fferemt Knds f sbline
caHon
SbecifiCatio that ae usedl im gxaþicA abbli
Edch Jnodividual s þeci fi cation simbly yeferAtoarticulay
boyndáry Conditiord
tybe þolynomial oi tb ertaim sbecie
HonA to origm
a Usec in qrab kica abþli ca
Curve omd surfqce shabes, to dgi tize drasins tr
Com Þqter stora m to sbecify qnimatibm þatha
for the objeets or the Cameva in a Sceme. Tybi cal CAD
abplicationk for Sblines incluca the olsign 4 automobile
bodies, aircYaft dhnol Spacecratt sUYfaces,
Jmterbolatiom omd Abbroximatiom Sþines
-A SElime curve is shecity by aset
Co-ovolnat þosittoms Calsol control þoint
otich molicat thu Gemeral shabe s the CUrve:
these comtrol ojnts an thenHed ith bjecewise
ComtimusUs Þarametric polynomial func ion in tuo
aya
L. Inteypolatel sblime'- hen bolymomial secting
au fiteol s that the
Þasses hrough each Comtro) Þoinb;
cUYve iA saicl to have ite*
the yeulting þoimts
the set ot contro) controbomts
- Cwvve must basg, thvsgh eontesomy

ximateol sblime'- -whem the polymomjd,


2.A ÞÞro fted that without
-

CUe Bo
through dny o the control Þoinb,
necessayit þassing contat Þtl gan, the resalin
the
it abþroximas the shabeabbyoximatol the set o control
to have
cUYve iB saidl
þeints
2
13

Sx

inter bolats
CuYve Will þass mear control þoimt na
the start om emd þoita
contoi pojmt
CUYve is influence by shabeis usually
CONTINUITYI Ang combleg
mot moolblel bya sing le CUrve.
but a Seveval pjeceA U CUYVe But these
shayþ Corm eYA that Can redt
Joimts Creates
representing t
tu fine Curves
oifitulty im
in
there aNe tuo tybes Contimuty
bd een' to adyacemt CUYve - pece
4-me ia the paYa metric Contmutt olenotey

amo other ia the Geb metric Continuty cdente


b G- Nymeri cal suberscri bta an U Jed 3ith
Comd G toimoi cat clagree of conimut or
Smoothmess
-Para metric Conti mut'- Comtimuty
for þarametric
we vie
the cUrve Chn Surtare as a fumetHon ather
4ham a shaþe.
piece o CUrve Cam be oles cribod bythe
Each
tollbo i bara me tric equatib
= (t) tistst
22(t)
Cotinu ty cam be set by matching the
þasa metic aoljoiming curve Þjeces at
þarra metric oderìvattves t
ojnt:
+heir com mon- þ
oler-þqrametric- Conttmutt'
(O 2ero-
þositibn 'Contimity
- þoint/ contimut meomya
þqrametric
zer0- order meet
the CuYVes
Simply that
t Contimuut} eist hen t uo
- tis kind boint wìtout
Curves Share a common eno
cUrVes at the
regaro to the Shabe g the
Jo)m point ie the valu st x, y omol z
evaluateo) at t | for he fist cvrve Sech on a i
Coresþoyoling esual to the vald Ao , .
evaluatol at to r the next curve secHon
this kim Comimuty is Callhc 2ero- order
þarametri c comtinuty oun otedl by co

2er0- 0Yoler

CH) fisst- ovder- pqrametric Contimuty


ovder pavqmetrìc Continut i6 also
- First-
Callacl the Tangent Contimwty
vector ie the arametri irut
-Jf the tangent
tuo connecteot Curve Segment
olavi vativeA b +he
theiroirectiong omol
e epual t n P G | e
aru epual) at the jojmt þoimt then the
magmituds ordeY Þarametri c ConHmut
Curve has first-

Cirst- ovoley

CH) Se Cond- order- þarametric eontimut


parqmetric Contnu y
Se comd ordey- Contimit
CuYVatUYe
iA also calleol
- Lohen botb the firt anol secon
bavameteric Oderivqtive the curve Secion
eequal at the joint Called Seco no orde r para metrc
icomtiuutt Secomd- order

yeometric-cotiuty!- Qeometric ConH uty cam be


ole fined using onl; the shabe
9 the CUYve:
Jt is samea
)2erp - oroler. Geometric- COnti nut
ondrepYesentedb
2ero- ooley- parametric- con ti muty
2 first- 0Yoler- Qeometri- Continuty f the

inectons( but not me ce ssahilythe magnitubs)


CUrve
commeteo
the tangent vector S the tuo
SegmentA are e ual atjoim-þojmt: the cUrve iA
first- order 2eometriC-Contin ty
Saiol to be
Reþrejented b g :
pies that the curve au G Comtimusu
G ConHmut im the joim boint
therSloþe aru ejual at
On od also hat
chara ctei ses this Comtimu y
The conoitiom hat oeriaive the first curve
first
that the þarametric scalqr nulti ble the pan etric
q
at the jeim pojmt i Second CuYve at the same
ot the
First lrivative
peimt'
g-comd- ovoler- þerametric Conti nu ty
the seconcd
Order
nuity regir, the fist omo seco nol
geometric Comti pieces o
barametric oderivative fa to succe scive
CUYvE proportional at joining point
T V 2

8, Onol
nt)
Lae c ContimuDUA becau theiy tan genta

ToinÞoit

Comtinuty eshectivey
CUBIC 3EZIERCUR E
my mbe)
Sblie cuYye cam be fitted tC qmy
H 3ezieY the tamg
ContYol þeint , koi th o ut meces sitati m
54
Shecifiction at qny ot the centrol boints'
Vector
charactevistic bolynomil abbroAImati
-A set 9 tunetionb) biemol
tuneHond,Callad ezier blemeing
to bioclucu a 3ez1eY curve
The Ctntol þ0it
Segmemt:
cuY ve Segmemt is obteymine
the cleree Ta Bezier
þoint· to be tittel wjth
Contro)
the unbey o
thut UT Ve Sgment
þot Po, Pi, P Pn
Cyven set I m+ e0ntre) that infit
a þqrametrie sezjeY CUYve Segme»t

P(t) = P; Bilt)
blemount tunction
Rhere Binlt) Cva the 3e2jer
funcn oefined
also Kneon as Bermstein Basis

Bimlt)
c(n,i) =
Henca trom
Plt)= Po Bu,n (t) +Bynt)4 . + Pa- B,(t) + By,|t)
4 Picn, 4) +*(1-t)+..
-he lagree the e
et d ezier cuYVe
CUTVe Sey mert '
Me fess 4ham the munbex Contro) Þoints Useo
-The Bezier cUYVe im 9emeral þasses through on
the firt Control poimt Po, Om he Last Comtro

1ne Gezjer cUTve ot olegree 3( n=3) we finol tha


tour(n+) contro) Þojot ane re ire to s becit
a cubic Geeier curve sememt Henet
P(t) = Pei2(t)
Bi,3(t) oStsi
z
P(t) = o, Bez(t) +P, B, 3lt) + Asslt)+ Pe,B3,3
here
L3
Berlt) = ID L3
L3
B1(t)

L3'

L3:

(-t)+3t(1-t)'e,+ 3tl1-t) t'e


P(t) =
+(3t6t+2t) ,
P(t) = (-t4zt3t+) Po
+{3t43t)h+t'P
3

thiA abressio n Corm be tram uteo imtt the mati


form -

Plty ()(M(B)
Here the bosis tunctibn mutr tej- Best), B,t),
the Be2ier Geonm etry maha (B) = Po

Omal he Bezjey basis matr ja [m= 30


3

Soch that [e =(T (M)


thereore a Cubic 3e2jey Curve. Cntollel by
the poimta Po, P, P, P3 A
P(t) -37 P
[tt t ) -6 2 P,
-3

Plot of.BeziEY Dlemong fuaciens


t 3e blet emch 4 the Cubic-Bezier blending fumctis
Gi against þarame tev t to osts) we et
at t=o al the blemoingy fuametion
hae 2evo Vaut
cepting Bezlt) 9fich has a valu 4. hnal
y t t 1 ta fumehon Ba,3 () wtta a

ualue 1.

to the Shabe 1 the cUYVe at t=o om


res becti vely . t.i
1
ensureA that the UYve dlsays pasey trogk th
fist mnd Last c0nt ro) þoints.
foY ether intermediat valus o t betue
- Þatiay comti but tothe
4 al th Contro) Poimta blemling fune n an
CUYveA shabe, a al th
fa o<t<i
varg of t, &13 (t
-Howevey im the 9termeolia comparuol te
Cc By2(t dix plays kigher valus
greater pull 0mth
Be3(+) omol 833 (t) im blying a
fumiena atu le 82,3 ltj
B3 lt) i maaimym at t
cuyve:
¿Jnadimum at t= 23'
B33lt)
noing
gezie Bglt)
ble B1glt)
Cubi- Not- 9t Cq
fouy be þrove t
|tor qry Bezjer
Thetoy 02 blendig jun
t Bi,m(t) +he mau
t Vn
wene

Ntieg +he Bezler fmeio iA negatHve dny hey


+he Som tu fumehonA ie &; a(t) i4
hi everyuhere.
Thèse twofact, resut in
amother imþex tamt
Probevty t cubic Bezjey Curves that Say%Such
CUrveA alway Lie Comblete ly 1oithin the convea hu
the fouY Comtro) bointa.
Tam gent 0n Bezjey CuY veA
X

The þaYametric tangentvectoy cbtaimed by


iHeetiating, a Cobic Bezier CUrve Segment
PLt) = (-t+st3t+) fo +(at2 6t+3t) f+
at
(-3t43t) P+(t)P
amy þoit t ia given bg
P(t)= (-3t46t-3) Po +( 9tt+3) R+(-9t +6
+(st) P
tvaua ti t) at the start point ieat t -

£jmilavly at the enol theçurve ie at t)


3(;-P)
Thys oe Cam Say that the tanglnt to the
CUrve at the e nol poin ta ae along the line
ycimimg the veshective emol boimt tt the
adjacemt Comtre) Þeimts
nspecHng all thu Bejey (vve ke en
Lhat
the stt 6d the Cor veA hey one tan gen t to sa
at
comtro!
me Commecthy the fivst cmal secono
þoimtA; Aikewiset the en t the cUYVeA hey olne tdI
on
th ime Commecting the thirc
tan gent tot the
Contl þoim t
tour Control boints, only the enol þoimtsom
41mstea afiting Cub
aru
tuo emd peimt tomgenta as s þecified
out
Gezier CUYve can sti.be olotermimeod by finein
to inter meciat Control boimts Using euen 0
- 9t Can be roveol that for cny Gezjey CUYVe t
the
cagree m, the þarametri tirst oyiyatives t
emd pointa nu given bt
P'o) =n(- Po)

þqvametric Secomo olarivgHve t1 a mtb alyree


-The poimt ean be Calculte
Bezjer CUTve at the emod
P"(O) =1(n-) (Po- 2,+)

So, f ox a Cubic Bezier l0rve (n=3)


P" (o) 6(Po-2 Pth)
7
2 A)vas the Beziey Curve otin ed by the
Corrtro) boimts (2,1) (3,2)(S,D),ornl (b,2 3y
pyoþexly chow sing
Orus q BezjeY Curve
anothen set o Comtro] Pr
uch hat th 3e con
Curve is oime s mothly witb, tha fist CUrve
P,= (3,) h=[s,) =l6)
the curve Stata at Po. je: P(t-o) Cnd emd, at
P3ie P(t=)

frbm c ComHimuty conoli Hon


P(t=)= &(t-o)

Continuiy

&1= 2P- Pe
264)- lr)

Contimut t 3= Qo
p"(t=) = 8"(t=)

(?2)44(6 )-4 fo)


A Cubic Be zieY CYVe
by the Con tro) pointa Pil , 20) Pl40,8)
Pa(8o oo), Pul9, so). Another curve Segement
IA clascYibe bt 8i(a, b), 82 (c, 2D), 82l 1so, 20)
E49 20) eter nìme +he valus a b eno 60
that the tu CUYve Seg ment j0im gmooth
.co Comtimuty, §l9, b) muut b coimciolunt
oitb Py ( 9, so)

{a, b] l9°, S)
a 9, b=sO
As the Curve Segments Join Smootbly oe assome c'
Contimuty at the join point &y =Py
3( Py-P)= 3( G2- 91)

(90 so) -(go g) = [c20) -[9: s)


c 20)=
(1o0 2)
+he CUYVes (e not c
Contimuoy at th ycti
becouse they cdonet Satiaty the c Cominuty
cubi -pLINE
þly be the bavamet ric þosi i om vectoY 74
Pojnt albng the curve, the geneval @xþre ssion for at
Shlime cyve olagree ol- 1 i given ht
h(t) = P; Bi, () tmiySt<t
2Sd <mtI
lohere bi a the iat Set

olafimed by the e cUY S)0m-for mulas!


Bia(t) -ft-ti
=

Bi,- t) +f
+5 ti- t
tid-ti
ohere titol- ti
oth eraie
- Pov a Cobic- B-slime the odagree ol-l =3 &e o=y
ber comt rol points(m+) vegtw'reo
atleast 4.
So þpose be hare to ur control Þointo Pe, P, P
Ke can obtam ftuy CobËc B;Sbli me blemol
FuncHbn By), B,4(), Ba4lt) mo B:,tt) He
btt) Po, B4 lt) +h B4t) + Pa Bay(t)+ P? Ba u(t
Umi ke the Be zie) basìs tunetio a the 3-shine
fumcton u mot ceimed ov ey the emtie
total pavameter vange tmin" tma
-it tht rangt (tma-tmin) 61 t ia
e
diviolacd into
3+4 y Sub-imterval +hem ech6the t4
CUbic . blem ding. fumcion sþa
- Sele ted
eight (n+d+1 9) þorameter yaluy (tj.o
Satstyimg he rela Hor tj<tj, MankA the e mod boin
thesubimtervay.
the set tj ie to t, t, tytytr tet+] i rejerreol
as a Knot ve ctoy we ca cho.se umifoxm 1mte ge
Kmbt vecter i ke Co, 1, 2,, y. S.64] ìth
Kot Valy. th ies the ranige evenly sPaces
þqYa metetqsf r
tmin = to= D. Upto tma ty 7
-USIn the Yeeurren ce relotion eg- we obtain

[. t-to
B o,lt) = B, 3 (t)+ te~t B,2(t)
to- to ty-ti

t-oBealt)+(t) ,31t)
( ) B4s(t)+E) 8,alt)
t- ty t- t
B, 4tt) -
ty-t t-t
B21lt)
Bialt) + S)8lt)
3

k-tlo..
t)=00 B2,) else 3st<4 |t)1
if B3,
else 26t<? ít t)=4 | B2,
0[t) Bo,) ele Bolt)=
weqet 6toifrmo Vanyg btHenca
Dtt)= Bii lk e
tist<tit! it
&slt)4(-t)
Berlt) (t-s) =
|t) 2Bs,
lt) 8s, t) 6-+(B4lt (t-4) 2(t) By,
(t) B3,(4-t) lt)+ B2,(t-2) &2,2(t)
(t) (2-t)
82, It)6(t)+ 2+)= Bi,
lt) (2-t) &i tt)+ Bo, t): (t) Bo,
s
otoitran vaying and bubtig Pimaly
B,alt) +t) (t) t)& =| lt) B43
B,lt) +|6t) 3(t) ) =lt) 633
32t) St) +(
Balt) t:2) ()= B.s
B2,3
e) () =)Bi
+lt) Beslt) get
eguaf 4otoitrom vanying omol ol=3 puting -Again
L)B34
evauat1
- HPRYih eqma ) m uma succersyveg
-0 an to (6) we qet s he cifC eapres:
tor the truy blemai on. fometHon &-in oi f erent
Sob )mter va t as

Bo,&(t) =
(4)
(e) +(3-t)+ )(4-t)(t-) (3t)+%)tt)4t)
3) (4-) far 3st<y
V) tt-y3
8i,4()>

() (+-) 3

fa S3t<

fe 4st<

V) (1t)a 6stey
Nte! +hÁ valtt t Biut) a a t t d t ) Con be obtimecl!
Bo,( , t ) B1(t)

2 6
Po, Bey tt)
i, G,lt) A, &eult}

t3 to t4
blemolinaumcionA have +he same shabe
that is al the
Each Successive bleoing tumctiom ib Sim P.
stütted o trq)Slated versjom ot the previ 046
a
fumcti0n:
that each of these blending fumc tion
A1s0 mote Cubic 8egments Nith inheent
LUTves Consist o to4r mter meoliat knot
Zentinuty c c comtimut) at the
tt(3-+}la-)l4)l8-t)
t(2-t)+ht(t-y(3-t) +%lt-) (4-t)
+; (t-)"9-t)

03 #(4-t)3

3
SPan the full ange o1 t: Jti6 initecl to a
Yeduce þarameter ange to-=3 to tm9
wich the Sum o all the fo4Y Over
equal to umit blemoung tumctOYA
evevywhere
ie
ZBlult) =1 for 3sts4
-hus the ejfeeive exbre ssjom for a
efinecl by four control þoint Po, cubic B-sbine
P, Pa, P3, n ol
Umiform Knot vector [o|234561) iA
Þlt) B0,4 (t) Po +By,4() Pi + B2,4l)+
=
B3,t) P3 whd
34ts4
(4)= 4-o+4t)l4-t)"+}(t)lt-y(4-)+%
(t-3) (s- t)??6 +(t-y(4-t) +7lt-ylt-3)l-t)
+*(t-3y(s-t)}fa +1tt}B bhere
3 <ts4

Now fyom the above exþxessjom w e


Cam fimd ot the boumdqry valu of the
Shiime cuYve ab
Pstevt = P(t=3) = (Po+4f+B) end poimt
Pemo = P(tE9=(Pt4a+P)
Ptayt 't3) =4-fo)l e m hoint tamgenta(foune
evaluating payámetric firs
P'end = p'4)=4 (- ) derivativ; t the emd bi

ctant = P (3)= Po-2 f+f.) Yate of change o end polnt


P'end = pt: -28+P, )tamgents (found by evaluat
Þarametric Secon od darivativ
at the emd þoimts
-Unike the cubic ezjey cuYve motice that the
Tast poImt om the Cubic Q-sbline curve o met
0YYespomd to the first omd last comtrol þoimt
the ofiming Þolygon NoY. the tangent vectows(3
at the first omd last þoint the Same as the,
tirst qmd last s pqng the detining
-The CuYve Cam be Madu to þasc thyo4 gh fizst dmclpolygonc.
Lást comto!
0ithot chamging the fouY Control poimt þosit
we Coula add fouY More control Pints (two at ea
e no) on the defimning þolygon Thus the mym bert
Cntrol pojmts (n+)will be eight but the shaþe o

the dutiming polyg070 remains ym chargel

Po
it cqm be byoved that f0ra cuDIC (q=4)
B-SAline fited to m41 Control þoimts Po, Pi, Ps
Pn-2, Pn- Pn the stat nd emd þoimto anl
stant (o+4h+f)

Hemce tor the above case ith tyIÞle vertiC


CComtrol poimta) at the e nds
P'staxt = (Pot4PotP) = Po

the GUYve starts omd emda at the tirst omd Last


ie
Control points
- Note that im ceqsing- tthe numbey.5t. Control
pojmts doet at ect'the dugree the curver

express the eg1o) jna matrix foN


We can
for thiA we
Similar to those foy ßezjer S Þlimes.
have to re parameterize the blenoing functionss
that parametert within imterval 3to 4 is mabþes
parametey
to the imterval oto l, t the equç valemt
then
i o. to | imtexval is termed u
t-3 t-3=4
4-3

How reþace ut3 toy t in efm(D)


434

Jn matri foym:
3
p
3 -6 3
-3

8: Pour Þojot Pola, b) Pi(20, 5o) (40 40). P3(1,


asu available for dlvqwimg a B-sþlime
segment Com þut the val o a, b,c such that Corve
the CUYve sft tr0m the pojnt (21,43)
onc terminak with slope-)
Y'stant lot+

-[E++) ( ) ) 6

6 + = 2|

6
lend (a-)
dt |A=tend
dytt)
dt lttend dt teetend

foc)-[20 So)}

2
dt t=temd

dy (4)|
d t ttend
Hemu the sleþe t he cÚare at the empont 1A

c lt=tend dt tetenc
dt lt=tend
Uçed
be wi Hh clas
o object, Qre tHu
desci
They mtlud se quadvic sufous wic
<bhevea,comd-ol sgree esuations (quadratics)·
elli kseidy, tovi,
Jn crtesian
coovolmaty
Yaddus Ycentered the coor a Pavaboloide,and
sbhevical
hyberbo
sorfaca wi
dened as set o
ei nate biin
Poimt[, Y, ) that Saisty th equati
We Cam glso
olesevibe ke Sbherical Syrtaain þara netri for

elibsoid' Am ellibsoidal Surface cqm be


duscri bed as qm atemsiom
a sbhevical surfau, btre theradii in th ree mutualy
perbe nou'cuqy ouyecHo can have duHeremt valuy
-The C qrtè sian rebresenfeton ta Ponta oveY tÅ syYfqr
y qn elliPso)d CemteYed on the orin i

qnd apqvqmetric yebresentatton t the ellibsoi

Sin
Jt can
be gemeqted byyrotatt a circde
Comic about a sheitied qis'
the cartesian rebyesentaton fa Pointr over th Surta
can be writen in thefoom

where YìA to qy ven sttset value Pqrametri c yebyeSenta


for a to ruJ ane Simi)aY to thOe ta,m elibse Ecebt, tha5
amyle tem ds over -360.
-vcy tatitusu omd longitu angus omd o. we Can oescrib
thi tous Suxfau as th Set oimtA that catity

t y Y+ ()Sjne
sing.
Super quadvica e foY mec
in cov Þorating adoi onal paYam eterA
Imto the quadyic euatoms to pYoi du incy eajeal tlexi bi
t adusH objet chabey
qdeitional
-the num ber Favameter vIecl i a egual to the olmensi m
the obeet 0ne PavameterA t cuYye omd tso Parame

sube yellibse we ob tain a Gartesiqn reþreJe


tatibn tor asoperellibsc trom th
CoYYespon oli'ng equotion t qn ellibse by albu 0ng the
ex þone mt
om the nomd y ter to be vaable

where para me ters can be assig any realvau


Lshens | We get oronary elliþse.
Parametri oguatiomi tor the susey e 1ibe -

Super ellipsoid A cartesian rebresentation for a


euat
SubereliÞsojd obtained fron the þasam
by jm cor þoY aHy t e xÞonent
qm elli bs oic

()
we howe am
Superellpcord
ametre rebres en taton f t
th þar
Se zieY Suy
faces'.
BeziY Sur faea þatch is a
4x4 9vid j l6 Control þo1 nte ih
duicibe a
bavametric bitubic sufa qiyinga tompaet
malematet defitin 4vch surfrt orth,oet
Shreeach tht tmtrpotated point: heneotto
gene ra2aH on the 3ezier
reso conto) þoints Can be urve, in utich each
imen lbn. tnought as a se atr curre in
A Bezity Sur fa þatch i
STYIR GB, haich sheiies theobtimel by its 4x4 Be zier
Geometry
As im the
contro) þoints 4 tne surfau
the cae
cate Bezier tirres the Cormty þoimt Y Ge
sheity actued boimt
imts on the eclge g the imter
polsteed Surfa
Yol, firtt colymn,pomtqny
a fourth
þoimt ot bnfrt row, fourth
beimts sthich inoli rey Column)the qre imter neoate
the surfau seit tomgeut vector. to
-he ymd 2 lirectin s
the sYr ca are caleus teal
fa a 39 Surfau a toh
nctualy be seharat gee metr thee laill
('ne fa each oirection. mstries Gay omd noz
-it is þossi ble to 2
rebyeent a Beeier suxfau in ony tuo

Poy Poe Pos

P',j re

Each boint on surfAu


vary between oamd
olebenoy on tuuo þarametors 4adv
sini lar to he CaJe vtha
th 2
-led ucontro) thet
the þath (ie fnm variation along fm to to bottom along
Poy oßx) ond vfm et
f Pro to Px) ay te right(i-e
spertid above
cucri bed Aies þrecise ly on the
hus u v0 at bounelay beirg
the sur face
cotrl boint Poìnt Poe ael U= v=l at
Crtel beint P3,3
hen a given poim on the
fa
co
surfae
eorh -0rone , 4 Onl oy be caleulated os felloas

Be ity bess
CaBealytin Be 2ìerCve
3 3 -3
3 -6 3 0
-3 3

atieh roge tm oto 1


U=

the co-cr
clinstes 71 earh bejnt on the
oirecty frem thu Bernstein bwls Poysurfac eym be
emials caleulste ol

34(1-y2
Bel4) = u(-4
4hen fe earh

Ris
BilJBj)

Bk.
yNna min

wjmolo

XWmim
The leng th o imiuge om tRa sareem must be
measYeol im ScYeem Co-oY oinat ( we have
Momane 4ke Scyeen cAbydimats Sohat thy ange
rny
het weeM

objet
Sþau

Jn the cbjeet sbau Posiiom i% meas uveo in physiccy


Umst.such a metera, t ma s hau Positom

Weuyt hae Some say comveri g from the cbjeet

.(screem spar) eom be dome by Scalip trrsHo

hm

Ascalig trongjomat
Lsill Convert objet Coori
nat ymits tonomalizeay
SCreen Co-or
Yomin
mitim. Trmr (oorinte v)ewpo
- indow
to
oìxely insCYreD actual Higt
orolinsk Co
ranste co dice Actual
Co-0Yoingtes cevice
maizes) te calls are Units mont otebe ovice
in the
ouvice: blay Particular
i
t feaus ble! byiae aÞro oyoimste
to s Co
TheJt
onveyt to pree erint the use Omdbìxele thon
Co-oyinstes
some othe bnts
in bicture the autine tohae e
oyoingos' Co
maizeTmstormahon
o NoY to
Hons!. ma
fTrcms
oyvTrcms 1mg vigw O
Xmae- Xvmin X mas- Xomi'n

Y-min Yu Ywmin
Yymin Ywmae Ymin
Stlvi hese erutoms fe t vieu þort þosion (v, Y)
Xy= Xvmin t Xy-
X%min)
khere sceding factors qre
Xumag - Xv min:
4he Vieksng
vie trms forms tton tch mab bictóre Co-orolinstes
fn the ycs to oibly
co-byaingtes im pb(S is perfor mea b}
the follo loing troms for
mstiom
ci) Nor mai zing
viewing Co-orelinste s
CnveY g moymalizec) vieksi ng looyoinsles t olrice
Co-yoinste s:
trmine Convent sorld Cemert
Normalizes Nvc rmal 2el

Peleling co byelirste
tsfor mgtion
viewirg co-oral' vieing,
o-oYns fe
viebing
Cobyoes
|to olivies
-
the þro ( oyre hat joumi fies the por
þicture that tions a
qre e the in sidu or out so
cþeafied a
- the regim
regiom sþare is veferred to au ciping.
wich qn
obiect is to be cli bhe
is Callad a ci}
windaw a clip bing aindo lo

+he ciing algorit m


otermines uich points imes
Aimes e itin the

) CUrve
Tert iit.
he egual sign malicates hat boint on the w
imdloo bomduy

TBRL
lest
Rignt
Batom
ToP.
One ckithig Mid oimt Sybaivision Alg0rithm
- the Suther (amd Co hen ubivision ine ci pping
algoritby
Tegures the calcula tiom 4he intersection the ine
Loit the Win da) edge +hese Calulati bns can be
Qvoidd by refetitively subdivi oliny the line at its
nid peint

+ Ane is þar tially visible then it is sub oiv iodo in tiro


equa parts ne visi biity tests qre then apbdieo to
each hal
- this sub divisom þroossis vepere Umit we get
Csmpletey visible amd Ceom þletey
þlete in visible ine
Seg mevd s
Mid poimt Subolivi sion Algorihm

3 Assign egion cooly fe tuo end


steti. points usirg follouig

3 it n> Uxmay then R= lse R=o

Ag. check fe visi bityint


a) it regin cooosfe botb end points qre Zero thtn
the lime is Comtleely visible.
b) 4 region Cooles fe emd þoimt! are not zero Omd
the lagical ANPing st thern is aso Mom2ero then
letely invi sible, so vejet thtine
the ine is com
)H regln cooy e to enolointa ds nt satst

t. &ivide 4he þartialy vi)ble ineseAat in egual


þart od Tebeat stebs though s fa botb Suearida
Line seg mtte untl you gt
Comhledely
Com plete invisible ime Sg mets
vistb
6 sto
Gohen- Sutherlanol kine ciin Alyorit, m

Loindb

fowr bit codas fa mime regjons


TBRL
left
Right
Bottoy
Top.
eth
erlang and Conen subaivIsion Hne clipping aigorithn :

(Wx,. Wy,)

P,

(Wx, Wyz)

Fig. 5.15

Read two end points of the Iine say P, (x,, y) avd |, (, v,).
Read two corners (lett top nd rht-bottonn) of the window. r (W,. W
nd W, Wy,).
isigu the region codes lor two endpoints |, aid !, using lollewin; stepy
Initialize code with bits (0000
Set Bit 1 if (x < W,)
Bit 2 (x W)
Set Bit 3 - if (y Wy.)
Set Bit 4 -- (y Wy,)
4. Chek for visihbility of ine P, ,

Onpletely vribl Heen the lie d o lo step


Comp
Windowing and Clipping
ter-@raphics 5-16

ANDing of them
regioN codes for endpoints are not zero and the logical
b) If compleely invisible, so reject the Iine and
iS also hon-7ero then the line is
go to step 9.
4a) and
region codes tor twO endpoints do not satisfy the conditions in
c) H
4b)the ine is partially visible.
the
of the clipping, window by inspecting
5. Determine the intersecting edge
region codes of two endpoints.
find intersection
the end points are non-zero,
a) If region codes for both window with respect to
points ; and ß with boundary edges of clipping
point P, and point l,, respectively. intersection
one end point is non-zero then find
b} If region code for any respect
edge of the clipping window with
point I; or Pß with the boundary
to il
intersection points.
6. Divide the line segments considering outsides the
the line segment if any one end point of it appears
7. Reject
clipping window.
S. Draw the remaining line segments.
9. Stop.
Subdivision Line Clipping Algorithm
code for Sutherland and Cohen
vtubooks.com)
(Softcopy of this program is available at
#include<stdio.h>
#include<conio.h>
#inchude <stdib.h>
#include<dos.h>
#include<math.h>
#include<graphics.h>
end point of line */
/* Defining structure for
typedef struct co-ordinate

int x,y:
char codel4];
}PT:
void drawwindow();
cl);
void drawline (PT p1,PT p2,int
PT setcode(PT p):
int visibility (PT p1,PT p2):
PT resetendpt (PT p1,PT p2):
NumeYICr YOble ms
A
Clibbing bindoJ ib qiven by A(I0,10)
B(20, 10), c(20,2o) omd 0(10, 2o),ind the visible
Por tiom o a Ane P( S.s) A(s,25s) Jm sid the inde
c(2
Ans, wimddowlett edge Wx min lo
oindos Right edge 1xmas=20
oin oloWA toottom A

wimdlowA edgewymin4o
Top edges wymae 2o
( 1o, 10)
B(2c,1b

£md Point o thah ine Pls.s) . l so2)


Nou Equation oyine Passimg through'ls.)9
Cso25)
Y-s= 20(-s)
4s

(b Left edye imdos c at theine D ak put =r


-s=io-s)
.20 20+5
t= 2:22+s
t=722
Simee
So iti reir'teol
2)<wymin
Right edye indo cut the line O at
Put n=20

sinu Jymim <¥M-66) <Wymad


So tis (20,166) i acceptel
In Gotm edge cut the ine ) at tslo
l0-S=Ca-9
4:
9

4St5

accepted
Tebey cut the ime(at Puty2 0
20-5 =()* (1-)
135 +5=38
4

Yejecded
Hena wisible Por HOn ume between
3
Griven wimdow A(10,20) (bo,20)
c(60,s) (20, So) Use - Cohen - Suther\ane
algriHm to find visible Por Hom oof the nex
Pl 30, 2s) 8lso, 4s) omd A (30, SS) Bl6S7S)

(9e:

Given: windosleft edge min -20


Wimdo right edge xmay = 60
ainoloA bo tom edge aymm =20

Emd Pointa oine P(30,2_) (S,45)

Solhon Set the tour bit tor P and &


Let touY bita oru TBRL
(LLest
Rignt
Botton

f 3ynas Then T= else T=

It > Wxmay then R=l else R=D


.it n <Wimin Then L=l else L= o
Hence foy Point P.
Wymim <Y Jymax T=B-D
R=L=0
Sim1 lanly for Poimt ,T, G= R=L=D
sinu both Point P4 a's bits an

Hena me is combleHy vìs)ble


Simi lavly bit setting for A4 8
’ ymax T=,{ B- 0
W min nmax ’ L=R= D
SiiLarly tor G T\, -0, L=0 R=!
A bit seting Jo00: TBRL)
ds bit setin CTGRLY
taimgbitiseandlin¢
weWe get a nom-Zero mbey ldoo Henet
Hi ine is Completely imvisible
9 using any of the ime elipbing algori thm,
obtain t visi ble Portion te foll ooin
Jine segemt
Pil o's, 024)
Ui) P, (o4, -6)
P, ( o4, -] 6) Pe (o8,-2)
civ) Pic-2-3)
Ps(3) 5)
Gtiven
Xwm)n =0 Yumim=0 X ma

Pb, o
Regiom Code for Pi
Sime Xomim <n< wma
So lett om dl Right bit wu
au Zerb

omd Sinee Ywtim <y


So bottom omd to KYwma
bit ae sero
Heme t e regin code for P,, iA
Now
Regiom co da tor P.
sime
So t bit.zero cm d Right bit
Omd simu
dwmin Lyywmas
So botom on d to bits au Bero
Heme Aon code for Pa
Sime te bitwise ANDinai Zeyo So we CAm Ta
Say oe ther it oi) be vieyea or Cipþeo
Lime Passig thyoush: Pl's,4) om d

y-4 = (9- 4/ (r6-o:s) (n-)


Sinee only vight bit is set im regìon code
P omd P2 so ime will be ibpeol
omly gainst
te rignt boymdary Hemce Put n=) jn equation '

3 S

S36

St vìsible Po Hom is (oS, o4) to


(i0, S4)
() Region code for i
4fen bottom bit=1, Top=o
So regi on co de foy P.
region co de far Ps
bitwise ANAing
Sme in gegi b co de oh P ommn P otom mod To
bit ans set ao ne l| be ci bped o mboto m4
wimdoo
ten ea viay eo Paiy ot meA ; .

Regiom
Bituise ANbing
sime bit oise AND0 ngi nom ero nm ber
ine is Combletely bes
& Use out coce bajesl ne ciping me thoc to cla
ine stating from (-13,5) omcl enoing at (14,)
ajinst ta oim dou haing it Lowey tt cemer at
(-8-4) nd þhey yight (oy ney at (12, 8)
cehen- Sutherlamd outcocu Algoyithm to

AlSe, o)
A Clibbing winde AGcD is lecotel aas fo'
A(16e,1o) B(060,10) c(I8e, y) D(lo,4 o) : tsg
4h vist
Suiherland -Cehem cippimg algoyithn tinel
ant! E(se,)
Povib c1 1th ine Segmen's EP,GH nc
1 140,0)
F(1,8t) G(U20, 2 0) , H
E 120, g, 30

R(So, to) 's (7o, 7


limes p( -20, 70) ,(20,3) emcl
Poiit Lociss
gaimst tha wimdo Use thu end totelly
mes to tmd out it thenes a
i
IVisi ble óy Panti ally visi ble Use
Sutber Lano'Line clibing algorit
xplin the Cohen-
to find the visible borion o the
Use this algoritban 30) imsioa the ld imolos, the
me Pl4, 00) l20,
cuttmeol aa ABco- A(20,23), 3(,20).
loimdow ÌA
D( 29 4)
c( 6o, 4). Om o!
Crus- BecK Aine ci phing Algori thon
-

- The mi þojmt
Suboivisibn hnd cohen-
assume that the citbing wiolow is aSutherlano Ajme cPing
yoqulay rectong le
TAece algorilhms qre mit aphlica ble fa non
cliping imdbu vectamguar
Cywmd eck have olevelo ped a
agor1tm tich is abblica ble to Aenevaized ine clpbing
any arbitYart Conen
vegibm:
Ahi algorith m Uses a þarg metrie
Smnt to id the inteySecHon þointseguston
4a ine
aine ith the
clprirg edyes.
the parametric
e9ustHom o aine semtnt from hto
þit) =
f,+{-f)
ohere t is a
t
avametr t=0 at R Ond t l t h
Consialer a Con vex cping yegion R, f is a bounalary Point
the Comver
Oibn R onol n is an înner moYMa ta
one
its"bo4ndaes. ay s hon in he fig bodo
Boundary Poi at
R- Convex regon
then oe Cam dic tinguih im wtich regiom a bornt e.b.
looing at the vala the alot þroduct nfpu)-] as
Shon jm figure below:

Pt)4) >0

icithing edge
nfpIt)-f](o
th en the vector pi) -{ ir þoì nte) abay from tne interiovyR
14 dlot þroduet is 2er0, ie
nþlt) -4)=0
then b[-+ ir b8jmted paralls to he plome com taining
t ond þer þenoicay to the nor mal

3 dot þmduet is þosiive,ie


n[plt)- f) >0
them 4he vector Plt)-f is þoimfeo) 40wqrdy he iter
-0Y R
-the þojnt f les in the boumdary plane or edge fa shich
n is inmey noy mal, then that þoimtt Ônthe ime
bty wtich
$aisfies m[PIt)-f)=o Coni itn is the intersecHo
othe Sine 5ith the
bounaar eoge.
Comsicr the ine f0m-2 ) to P (84)
Cipþec to the rectanguar Yegion Ras shoun in
t3 belo he tine P.e inlersect s the sinoaw. caleuat
he imter section ooints.

2 4
8

Sal the þayametric repreLen tatirn g the dine Pa is


plt) = + (a- R)t= [-2 ) +(1b 3)t
(iot-2) i +(3t+)j: 05tsI
ohere i i +i
4 ate umjt vectos in 4he omd oirecto ms
yesþeetivey. the foyr inner nor maly are ven ay
lelt: m=i
Bottom:. mg=
Tob

choosig f(39) fa tne let ege oìves


þlt)-f - (1ot-) i+(3t+)i ohrol
n [Plt)-f) = lbt-4 =

Subttituting vau g tn þaranotie e_ugtiom koe get

-l2,) + (4, Qls) = (2 2123


yashectivel. eog rigt onel edge teft
th 3y
ad(7 (32'y þoiimtorsecthn
nta to get be
4hy
rejecteo is
ronge the otsio is t valu1 4his
=-(3t-4)
=0 -) Þity MT
gives eg to
the te
fs) Ueig
reject
t=-3
t|=0 AtU-)
3t = mo[
gies edge bottom the fe f(2,
d)VSig
-[2)+(9
27)9)
3j(3)) )+[e P\) =
egot wsHon metrie
ep þora in)tSubshtuting
vall
-(lot-)=0 mapt)-) =
ao
(3t-4)j 9)i+ (Iot- =-f PIt)
ives edge rignt the te
f(7) ehoosimg
Computer Graphics 5-28 Windowing and Clipp
As shown in the Fig. 5.18, if the point f lies in the boundary plane or edge
which n is the inner normal, then that point t on the line P(t) which satistaa
n[P(t)- f)= 0condition is the intersection of the line with the boundary edge
SEample 5.3: Consider the line from P (- 2, 1) to P; (8, 4) clipped to
A rectangular region R as shown in the Fig. 5.19. The line PP, intersects the uin
Calculate the intersection points.

6:

P{8, 4)

P(-2,1)
6

Fig. 5.19
Soiution:The parametric representation of the line PP: is
P(¢) = P, + (P, - P)t = (-2 1]+ (10 3] t
= (10t - 2) i + (3t+ 1) j; 0sts 1

where i and j are the unit vectors in the x and y directions, respectively. The t
inner normals are given as
Left n, = i
Right nR =- i
Bottom

Top
Choosing f (2, 0) for the left edge gives
P(t) f = (10t - 4) i + (3t + 1) j and
n [P(t) -f] = 10t - 4= 0
t = 2/5
Substituting value of tin parametric equation we get,
P(2/5) = [-2 1] + [10 3] (2/5)
= -2 1) + [4 6/5]
= (2 2.2]
Duter Graphics 5-29 Windowing and Clipping

Chsing f(7, 5) for the right edge gives


P() f = (10t - 9) i+ (3t 4) jand
ng|P (t) -f] = -(10t - 9) = 0
t = 9/ 10
Sabstituting value of t in parametric equation we get,
P(9/10) = -2 1] + [10 3] (9/10)
=[-2 1] + (9 27/ 10]
= [7 37/10] = [7 3.7]
Tsing f(2, 0) for the bottom edge gives
ng[P(t) - {] = 3t + 1= 0
t = -1/3
This value of t is outside the range of 0s tsland hence it is rejected.
Using f(7, 5) for the top edge gives
n, [P(t) -] = - (3t 4) = 0
t = 4/3
This value of t is outside the range of 0s ts1and hence it is rejected.
Thus, we get two intersection points (2, 2.2) and (7, 3.7) with left edge and right
respectively.
To get the formal statement of the Cyrus-Beck algorithm we substitute value of
in equation 4.
n[P(t) -f] = n [P, + (P - P) t-f]=0 (5)
This relation should be applied for each boundary plane or edge of the window to
the intersection points. Thus in general form equation 6 can be written as,
n, [PR +(P2 -R) t-] =0 (6)
where i : edge number
Solving equation (6) we get,
n, |P, -]+n [P, - P,] t =0 (7)
Here, the vector P, - P, defines the direction of the line. The direction of line is
portant to correctly identify the visibility of the line. The vector P, - f is
oportional to the distance from the end point of the line to the boundary point.
Let us define,
D = P - P; as the direction of a line and

W, = P - as a weighting factor.
oB163)
Vs
Vb

b
Hgu abau shawy tle Hexagone

(S 275)
Computer Graphics 5-32 Windowing and Clip

Referring Table 5.2 we have,


The maximum lower limit (t, ) 4/10 and
The mininum upper limit (ty) 7/8
Substifuting these values of t in parametric equation
we get,
P(4/10) = (-2 1] + [8 2] (4/10)
- |-2 1] + (3.2 0.8]
= |1.2 1.8]

P (7/8) = |-2 1] + [8 2] (7/8)


= [-2 1] + [7 1.75)
= [5 2.75]
Thus, the two intersection points to line P,P, are [1.2 1.8] and [5 2.75] with ed
V,V, nd V,V,, respectively.
Liang-Barsky Line Clipping Algorithm
h the last section we have seen Cyrus-Beck line clipping algor:thm
paranetric equations. It is more efficient than Cohen-Sutherland algorithm. Liang l c
Barsky have developed even more efficient algorithm than Cyrus-Beck algorithm VSn
parametric equations. These parametric eqations are given as,
X = X, + tx

y = y + tAy, 0sts 1

where Ax = Xy - X and
The point clipping conditions for Liang-Barsky approach in the parametric
can be given as,
Xwmin S XË t tAx S Xwmay and

ywmin S yi + tay S ywmax


Liang-Barsky express these four inequalities with two parameters p and
follows
i= 1, 2, 3, 4
where parameters p and g are defined as,
P; = Ax, 41= X1Xwmun
P2 = Ax, 92 = Xwmax - XË
oJJ9ismerp R ov

FGraphics 5-33 Windowing and Clipping


P: = - Ay, 93 = Yi - Ywmin
Pa = Ay,
ng observations can be casily made from above
definitions of parameters p
Line is parallel to left clipping boundary.
Line is paralle! to right clipping boundary.
Line is parallel to bottonm clipping bondary.
Line is parallei to top clipping boundary.
Line is parallel to one of the clipping boundaries
cotresponding to the value of i.
Line is completely outside the boundary
and can be.eliminated.
Line is inside the clipping boundary.
Line proceeds from outside to inside of the
cipping boundary
Line proceeds from inside to outside of the
clipping boundary.
afoe for nonzero value of p,, the line crosses the clipping boundary and we
g parameter t. The parameter t for any clipping boundary i can be given as
t =
i= 1,2, 3, 4

-Barsky algorithm calculates two values of parameter t : t, and t, that define


of the line that lies within the clip rectangle. The value of t, is determined by
i n g the rectangle edges for which the line proceeds from the outside to the inside
The value of t, is taken as a largest value amongst various valucs of
ions with all edges. On the other hand, the value of t, is determined by
gthe rectangle edges for which the line proceeds from the inside to the outside
The minimum of the calculated value is taken as a value for t,.
w, if t, > ty the line is completely outside the clipping window and it can be
d Otherwise the values of t, and t, are substituted in the parametric equations
he end points of the clipped line.

Read two endpoints of the line say p, (x,, y) and p, (x, Y).
Read two corners (left-top and right-bottom) of the window, say (xwnin Ywnay
Xwmax ywmin)
-Riang-avs ky algoril hm caltda tes uru
valus Þaremele t: t, nol t hat oufine
CODING
hat þart 9 tho ine that ioy ithin the cli
Yectengle:
Private Sub Commandi_ ClhckO valw ati ooteryeal b} checlmg tne
Listl.Addltem "bca Yectanyle edge te yhch thi ine bceeds
Listl.Additem "bba" foom outciols te t4 insida(P<)
ListiAdditem "mca" th walu tis taken asa Largert velu
List1.Addltem "mba" Cmergst vari ous alus o inter sections wth
List1.Addtem "b.ed"
Listl.Addltem "ba"
End Sub
Proceedy fom th imsjodo te th out sie
the calcalate!. vale
Private Sub Command2 Click) is talen q yal fe t .
List1.Removeltem (0)
End Sub
t,7 ti,h ime is Com bletaly
CaPþigwinolo Cnot it Cam be
Private Sub Command3 Click)
rejecteol
End
Substitute! in the þara meti euationg
End Sub
to get th end beints the ci speel t.

HIMT/PROGRAMMING IN VISUAL BASIC Page 5


Alyan tages :.
J 3t more e fticiert hom Cohen- Suthetnol algorithm; Simce
in teysetibn Calculatios qre reclutecl
a. Jt rerires only one oivicìon tð Upolate þaramete s tt
Q.
Ond t
3 winolo ineY Se ction tthe ine qYe
com Þutel
Omce
Find the ci Ppmg c0-o rolinaBerfo a ine RB bhere P
=(19)
Omd al 6o 20) ajunst wimde th (y min, Yomi
n)=i5 )
(Xawman Vum) -(25, 2).
Hrt

Y= 30

Sincefa these vay P<0


Simle te these valuy Pr0
ere tË<t md the end þeints cibpe ine hre

-22S

= 10+ 02S X20 =)S


S Aind the citping Coorolnstes fe aime tP
r adeye
wtere
R=(toib) Orrol P(64 30) against oimdeo si th (Xmin, Yonin)
-\ISi) omd ( Xumn, Yoma)(2526)

Xwmo 21
d= 30 wma = 2

, = X- Xsmin -5,

= 0'3
P= -0y = -20 Ymi to-S= W3

t= inlo3, 75)= 03 Simu fe thee vella Pso


HRne tË(t 0d th
enol Pojmts cbe ne n

|o+ o'3x 2 0 = C
Suther land - Hecd geman poly gon ciing'
te gon can be clibþocl b þroceesiny its boynao
asa lshole aganst each loimales eol ge
4his Can be achieved by þroeo sting al
boly gon
veries agoinst each cip ectagle
bouelg1
Begining sith the original set polygon vertices,
we Coalod firt clib verti ces,
he þohyg8n again1t the
Yectamglk boundar to produ ce a mew et e
verHces. seyutn
- the new set st
þassedl t a rìghtverices could 4hen de succe csively
cibber Ond a botom bomdary ctþer a tob bounday
shoan in fig bel.
beb boumdgry cpber, .a
as

6riginal þlygon

Right cibec
genevote
en step a me sets þolygarn Vextices is
and þass ed to the net inola boundars clber.
the suther lancl
- this is the fundamemtal jolea usef in
-Hodge an algoithm

Loim clao bounda amd the second weoter the


edye is inatou 4hen he iaterdecton peint the
þoly gom edge it, the tdo bounolat althe
Second verter qre added +othe butut rerter
ist
& T4 bth verices 44he edlge qre inai the
oin dbo bunda4, 0nly 4he Secondvertea i3
qdoda t the otpyt verter ist
2 T the first ertta the ecge s instoy the
toinda bounolary nel the second verter tthe
edge is utside bny tne edge iyter sectbm ith
4he oidoto buum dary iA ad
Yerte ist ao h the outut
4 T bot vertices sf the edge qre sutsiola
the
toi daw boynct. nothing is qoldecd tthe
) (8s) (22458
(6,)

Bresenham's Line Drawing Algorithm:


Step 1: Input the two line endpoints,storing the left endpoint in (X1. Y1)
and Right endpoint in (X2, Y2)
Step 2: Plot the point (Xi, Yi)
Step 3: Calculate the constants, Ax, Ay, 2Ay and (2Ay- 2AX) and get the
first value for the decision parameter as:
Po = 2Ay - Ax
Step 4: At each X% along the line, starting at K=0,
perform the following
test: if Pk < 0, the next point to plot is (Xkt1, Yk)
and
Pk+1 = Pk + 2Ay
Otherwise the next point to plot is (Xk+1, Ykt1) and:
Pk+1 =Pk + 2Ay -2Ax
Step 5: Repeat step 4, Ax times.
Note: The algorithm and derivation
above
For otherslopes we need to adjust theassumes slopes are less than 1.
algorithmslightly.

You might also like