Professional Documents
Culture Documents
Mathematical Elements For Computer Graphics by David F Rogers J Alan Adams PDF
Mathematical Elements For Computer Graphics by David F Rogers J Alan Adams PDF
DAVID F. ROGERS
J. ALAN ADAMS
MATHEMATICAL
ELEMENTS FOR
- ...
..... ,... h
~
• -
•
• ..
•
, ..
• •
W' • J(
'
THIS 8001( BFLONGS I 0
MIKE HAYDEN
~~n£1YATICAL ElB£Nrs
FOR
CO'RJTER G£\1\PH l cs
•
MATHEMATICAL ELEMENTS
FOR
COMPUTER GRAPHICS
DAVID F. mRS
.Aerospace Engineering oepar tt1ent
United States Naval h:al:lemy
J. ~ PIWf>
l~cal Engineering oepart:ment
United States Naval Academy
3 4 5 6 7 8 9 0 FGRFGR 7 9
~. Oa\nd F 1937-
r.\"lt:hesratica.l elencnts for o:xt~ter graphics .
XIII
PIUAC£
QW'lER 1 nmax.x:TIOO ro Cll<lPl1l'ER GRAPHIC ~ 1
1-1 Overview of catp.lter Gra[il:ics 3
1-2 Iepresent.i.ng Pictures to be Presented 3
1-3 Preparing Pictures for Presentation 3
1-4 Presenting Previously Prepared Pictures 5
1-5 lnteract.in<J with the Picture 8
1-6 Descript.ioo of scrne Typical Graphics Dcvi oes ll
1-7 Classificatioo of Graphics Devices 16
References 23
200
C-1 A"' Al.godtm for '1\.o-Oim.msi.onal Translations 200
C-2 A '1\.o-Dirrensl.CnAl. Sealing Algorittm 201
•
C- 3 h '1\.o-OiJrensl.onal Peflection Algorithm 202
C-4 A General. '1\.o-Di.m:nsl.ooa.l lbtation Alqorit:ml 202
c-s A 'Ihree-Dilrensional Scaling Algoritml 203
C-6 A.'1 Algoritl'm for 'lbree-O.urensional lbtaticn About the x- Axis 204
C-7 r.n Al.CJ.Xl.tml for 'Ihree-Dirrensioocll lbtaticn About the y-Axis 204
C-8 An Algorittm for 'Ihree-D.inensional ~taticn About the z-Axis 205
C-9 An Algorittm for 'Ihree-DJ.SrenSional Reflectioos 206
C-10 An Algorithm for 'llu:ee-Dilrensional Translation 207
e-ll An Algorithm for 'lhree-Di.nensional ~taticn
about 'Any Arbitrary Axis in Spoce 207
c-12 An Axooaretric Projective Algoritlm 208
C-13 h Dirrctric Projective Algorithm 209
C-14 An Isaret.ric Projective Algoritl'm 210
c -15 An Algorittm for Perspective Transfonnaticns 210
C-16 'lbroe-Dimmsialal ·en Algoritbns 211
C-17 A Stereo Algorithm 213
C-18 An Algorithm for a Nonparametric Circle 214
C-19 An Algont:ml for a Paran-etnc Circle 215
c-20 rar~ic Ellipse Al.gon.tm& 216
c - 21 An Algorittm for a Paranetric Parabola 217
C-22 Algorithms for Pa.ra.rrot.nc HypeJ::bolas 217
c-23 An Algorittm for a Circle through Three Points 218
c-24 An Algoritl'm for Generating CUbic Splines 220
C-25 An Algorithm for Paralx>lic Blending 223
c-26 A Bczier CUrve Algorithm 225
c - 27 A a-spline CUrve Algorithm 226
C-28 1\n Algorithm for a Bilinear Surface Patch 228
C- 29 An Algorittm for a Linear Coons Surface 228
C-30 An Algoritml for a Bicubic Surface Patch 229
C-31 lktLer SUrface Generatioo Algorittm 230
INIIX 232
FOREWORD
Since its inception rore than a decade ago, the field of carput.er gr~ has
captured thl! iiragi.naticn and technical interest of rapidly increasing nuttlers of
individuals fran nany disciplines. A high percentage of the g:ro.fing rc:&Ilks of
cx:xtpUter graphics professionals has given primary attentioo to catputer-oriented
problems 1.n progianming, S'Jstem design , hardware, etc. 'lh.is was pointed out by
Dr. Ivan Sutherland in his introduction to Mr . Prince' s book , "Interactive
Grafhlcs for Ccrp..lt.er- Aided Design," in 1971 and it is still true t.oday. I
believe that an inadequate balance of attentioo has been given to applicatioo-
orientcd problem; . There has been a dearth of producticn of useful information
t:Mt bears directly oo the develO(Jtent and iltplerrentatioo of truly productive
applications. Understanding the practical aspects of carputer grat:*\ics with
regard to both the nature and use of applications r epresents an essentja] and
ultiJMte requitetettt in the devel o p tent of practical catputer graphic syst.enS .
~.athenatical tcdurlques , especially principles of geanet.ry and transfozntttioos,
are indiCJenOus to nost ~ gra{ilic appl.icatioos . Yet, l arge ni.Bbcrs of
graphic prograrmcrs and analysts struggle over or gloss over the basic as~
s. H. "Olas" 0\ascn
Locl<heed Georgia Calpmy, Inc.
•
PREFACE
David F. JO]erS
.1. Alan Adams
•
CHAPTER l
INTRODUCTION TO
COMPUTER GRAPHIC
TECHNOLOGY
catputer gr~ics as defined abo~ can be a very o:xt~lex arvi ell verse Sl.b-
ject. I t cncx:~~paSses fields of study as diverse as electronic and rroch.lnical.
desi gn of the corqx>nents used in catpUter gr<qitics systans .md the oonoepts of
display lists and tree structures for preparing and presenting pictures to an
ooserve.r using a c:atputer gra[:irics system. 1\ di..scu<;sion of these aspects of
interactive c:atputer g:rar.hlcs is given in the bock by Ne~ and Sproul (ICf.
1-l ) . llcre ~ will atteupt to present only those aspects of the subject of
interest fran a user' s point of view . From this point of via", CXlClputer
graphics can be divided into the fol lowing areas:
Representing pictures to be presented
Prepari.nq pictures for presentation
Pl:escnting previously prepared pictures
Interacting wi.th the picture
Here the word "picture" is used in its broadest sense to rrcan arrt collection
of lines , points, text, etc., to 1><:! displayed an a graJ=hics device. A picture
TMY be as s.inple as a single line or curve , or it may be a fully sca.lcd and
anrotatcd ~ or a c:atplex representation of an aircraft , shl:_:~, or auta•cbile.
Pomts are the b:s.sic building bloa'<.s of a graphic data base. 'ttlcre are
th.."""O basic rroth:xls or instructions for trea~ a point as a graphic <_7El00etric
entit'l: nove the be5n, pen, cursor, plottinc] head (hereafter CAl led the cursor)
to t:he point, dra.<.> a line to that point, or draw a dot at thal point. F\lnda-
m::ntally t:he.rt=- are c..'O wtJYS to specify the position of a p:>int.: absolute or
relative (incra·ent.al) ooordi.nates . In relative or incranental ooordinates the
position of a point is defined by giving the displaoerne.nt of the p:>int with
respect to the pre\"ious point.
The specif1.cation of the position of a p:>int in either absolute or relative
ooord.inates requires a niJ!I't.)er. 'lhis can lead to difficulties 1.f a mrputer
"''it.'l a l.irnlted lf.'Ord lengt.."'l is used. Generally a fUll 0011puter lf.'Ord 1.s used
to specify o cxx:mii.natc position. 'lhe largest. integer rnmber that can be spec-
ifl.ed by a full cr:r.puter word l.S 2n-l - 1, where n is lhe nutber of bits in the
\<o'Ord . For thl. 16-bit minia:rtp.lter frequmtly used to 5\.{l{X)rt CQlPUter graphic
displays, t.his 1S 32767. For many awlications this is ac::oE4"'table . ~var,
diffl.culties arc cnoount:ered ~.~.ne.n larger integer ru::bers than can be specified
are required. At. first '-'C might expect to 0\."ercare this difficult:r by using
relat.ivc ooord.i.Mtes to specify a nurrber sud'l as 60 , 000, i.e . , using an absolute
ooor:dinatc spcciflcation to position the cursor to (30000 , 30000) and then a
relative cxxm:Unat.e specification of (30000, 30000) to position the beam to the
final desired point of (60000, 60000) . 1-t::Jwever, this will rot \o.'Ork , since an
at!:.crtpt to aOC\I':Ul..ate relative position specifications beyond the nuxi1Tun rcp-
re:scnta>lc val~ wi 11 result in the generatia~ of a mlt'ber of ~ite sign
ard erroneous nagnitu1c. For cathode ray t\De (CRI') displays tins w11l generally
y1eld the fhen::n:na cal.l.OO wraparound.
Thew~ out of this di~ is to use ho•oge.~l:S ooordinates. '1hQ use of
hcrog€~us o:x>xdinatcs introduces sare a&ii tional cuplc.xit}·, ~ loss lil
speed, and ~I'! loss in resolution. tb~'ever, ~ dlsadvant.aqes are far out-
~ighed by the advallt~ of bci.'19 able to represent .l.ar9c wteger nwbcrs \·d.th
a cucputer of limited wonl size. for this reason .:lS \o.<ell as others presented
l ater, hom::lgene.ous coordinate representat:.i.oos are generally used in t:his bock .
In harogcncous roord.inates an n di.rrensional space is rcpre.•;cnt:ed by n + 1
dim.:msions , i.e . , throo-d.inensional data where the position of a JX)int is given
by the triplet (x, y , z) is represented by four ax:n:dinat.es (hx,hy ,hz,h) , ~re
~lith these CXJJtnents about data bases in mind it is ne<X!SSa.ty to note that
the data base usad to prepare the picture for presentation is alnost never the
sarre as the display file used to present Ute picture . The data base represents
the total p1.ctura wile the display file represents only sare portion, vie.,r, or
s<X!re of the picture. The display file is created by transforming the data
base. The picture contained in the data base may be J:eSizcd, rotated, trans-
lated, or part of it rorroved or vie..JOO fran a particular point to obtain nec-
essary perspective before being displayed. f"any of these operations can be
aca:xrplished by using siJtpl c linear transformations which involve matrix trulti-
p~cab,ons . 1\rrong these are rotation , translation , scaling, and perspective
views. As we shall sec later, hart:>gen(t>us ooordinatcs arc very oonveniont for
acxortplishing these transformations .
As will be shown in det.ril in 0\apt:ers 2 arrl 3 , a 4 x 4 matrix can be used
to perform arrr of these individlal transfonrutions on points represented as a
matrix in harogcneous ooordinatcs. \\hen a sequence of transformations is
dcs.i.:oc<l, each individual transfornation can be sequentially applied t.o the
points to ochieve the desired result. If , ho.-Jever, the nurber of points is
slbstantial, this is i.neH icient and t.irc consU'lli.ng. 1\n alternate and rrore
desirable ret.OOd is to rrultiply the iOOividual rotrices reprcsantinq each
~ transfo11Mtion t:o<)et:har and then to finally rrul.tiply the matrix of
points by the resulting 4 x 4 transforl!ation matrix. 'Dri.s matrix operation is
called cx:ncatenatioo. It results in significant t.irre savings when performing
C:OifX'UOO matrix operat.i.ons oo sets of data points.
Although in many grilliUcs applications t.'lle cotpletc data b.lse is displayed,
frcqoontly only portions of the data base are to be displayed. 'lhi.s process of
d.ispl.ayll¥J ally part of the cotplete-picture data base lS called W1IlCic7wing .
\\indo.;ing is not easy, particularly i f the picture data base has been transform-
ed as discussed above. Pertonnance of the winda.dng q:leration lJ'l so.ft..rare gen-
erallY is sufflcicntly t.ine CXlOSuni.ng that dynamic real- t.irre intoracti\'C qtafhj.cs
is not possible. .Again, sq:::histicat.ed graphics devices perform tlu.s funct.Loo
in hardNare. In ge.ncra.l there are two cypes of w~ - cllppinq <md scis-
soring . CUpping i.m.olves deteonininq whid\ lines or FOt"tions of lines in the
picture lie outs1de the wi.nda-1. 'lbose lines or portions of H.ne.s am then dis-
carded and not displayed; i.e. , they are not passed on to the displ ay devioo.
In the scissoring t.edlnique, the display device has a larger fhysical drl!Winq
space than is required . Only those lines or l.i.re segrrcnts within the specified
'".i.nclo..> are made visible e1.e1 though l.i.rles or line segmmts outside the w~
are dra-m. Clipping aCOJJ<plished in hardYcU:e is generally rrore advantageous
than scissoring; e.q., clipping makes available a much larger drawirq area than
sd ssonnq . In scissoring, those lines or Se<JITClts of lines \'f'hich are not vis-
ible in the wi.ndc:7w are also drawn. 'lhis, o f oourse, requires ti.lre, since the
line gererator l't'llSt spend tiJm drawing the entire data base whether visible or
invisible rather than only part of t.'le data base as in the CAse for cliwing .
.In two dim::msions a windcw is specified by values for the left, right, top ,
and bottx:lrrl ~ of a rectarqle. Clipping is easiest i f the edges of the
rectangle are parallel to the ooordinate axes. ll, ho..lever, this is rot the
case, the rotation of the w~ can be o:npensated for by rotating the data
base 1..n the Of+OSite direction. 'l'No-dirrensional ciiwirq is represented in
Fig. 1-1. r..i.ms are reta.i.ood, deleted, or partially deleted , depond1ng on
whether they are mtpletely within or without:. the windo.q or partially within
or without the w.incX:w. In three dinensions a wi.ndow consists of a frustum of
vision, as stn.m in Fig . 1-2. .In Fig. 1-2 the near (hither) l::x::A..lOOary is at N,
the far (yon) boundary at F , and the sides at SL, SR, ST, and sa.
JlS a final step in the picture presentatioo process it is ncoessacy to
a:>nwrt fran t:he ooordinat.es used in the picture data base called user coordin-
ates, to those used 1::1}• the displey device, called display ooord.irotcs . In par-
ticuLu-, it is necessary to a::>n\.'ert ooordinate data which pass the winc:bd.ng
procrss into display ooordi.nates such that the PJ.cture appears in socte specified
area on the displa-J, called a vi0-1p0rt . 'lbe viewport can be specified by giv-
ll¥3 its left, righl, top, an:l bottxxn edqes if ~l.onal 0 1:" U t:hree-
dirren~nooal by also specifyinq a near (hither) and far (yon) boundat:y. tn the
ltnc p.utl.tll~ '~tlhtn \\tndo"'
DJrl from a b dtspla)'cd.
pa fl rront b- c not dt~played
c
l tnc cnllrcl)
\qlhlll --
Wtndo ''
cn l trt l1nc
d •~P Ia ~ cd
!II
L•nc: paru;~ ll y
J
"'1th1n
I tnt ent•rtly
J OUISide O(
w 111dow no t
-- I
dt)p l aycd
wwdow p~ll from b-e
d t\ph•,,.d pall\ .t-h. c- d
no t dt:.pla ycd
1 l1h cr npltc
hunulc
I
I
Ph ~>l••rnuluplu: r
•C/ luhe
l et di~Piol)
.__., Pu l~c ~hnl'lll!1 c trcull 1 > - - cnnr 111llc 1
1.ndicat.ing which S'"'itch or s.dtches are active are also usually provided .
The analog tablet is the ItDSt versatile and accurate devloe for cx::mrunl-
cat..irq {X)Sitional information to the mrputer. Pxoperly used, the analog tablet
can perform all the functions of a light pen, joy stick , track ball, IrOUSC , func-
tion swi t.dles , or control dials . Asscx:iated with the tablet is a pen which can
be roved over the surface a.rd whose position can be sensed. It is also possible
to sense whether or not tho pen is in close proximity to the tablet surface.
PosiLional Wornation with acx~uracies of :!: 0.01 inch are typical of many tab-
leLs, and Uiblct.s with accuracies of :!: 0 . 001 inch are available. Typical analog
tablets arc sht::Ml in Fig. l-9. 1'he position of the pen and its relative loca-
tion in t1'IL! picturo-di..splay area are tied to:)ether by rreans of cursor (a small
visibl e syrri:nl) whose tTOtion on the pictl.ln! display area is in concert with
that: of the pen m the tablet . 'lhe analog tablet has two distinct advantages
o"ur the 1 iqht pr·n. IJanely, when the analog tablet is used to perfonn a
JX)inting function , the indication occurs in the data base and rot in the dis-
pl.dy file. 'n1us, the proqrdlmlin:] is sirrplified. Also, dr~ or sketching
cr r-ointlng ~ing .m ru'lillog tablet wtri.dl is on a horizontal surface is rorc
natural than perfonn.lng the san-e oper-
ation with a light pen in a vertical
orientation.
An analog tablet Cml be irrplcrrentod
in hard..are by using a variety of clcc-
trocnagnet.ic princi?lcs. ~of these
are discussed in Ref. 1-1 in nnrc dctai 1.
Except in unusual cnvl.roo!rents the user
need not be cau:rned with the precise
acldi tion, this C1aracteristic results in t."le interaction between t.~e user ar.3
the di.spl~ bci.ng' scr.cwhat: s~-cr t.flan with a refresh display.
A refresh CRr ~cs display is based on a telev>_sion-like cathode ray
tltk. Ho..oe\.oer, t.ie r.et.'10d of qenerati.ng the image is quite different. 'fule-
Vl.SlOn uses a raster scan tedmi~ (see below) to generate the reqw..red pic-
ture, ,,t\e.reas the traditional refres.'l CR!' gra!Xllcs display is of the call igraFhic
or li.nr-draw.i.n:] type. A refresh CRr graphics display requires ~ elerents in
addition to the cat:hodc ray bbc itself : a display buffer and a display a:m-
troller. In order to understand the advantages and limitations of a refresh
display it is necessary to cxmceptually l..ll'lderst.md the puxpose of these devices.
s~ the: ptoS"t.hor used on the catl1ode rey tlbe of a refresh display fades
•
verJ rapidly, .e., has a short persistenc2, it u; neoessa.ry to repaint or re-
CQ'ISt.ruct.: t."'" enUre picture rnny tires each sccx:nd . nus is called the refresh
rate. A refresh ra~ t."lat is too ].o..,. \..:ill result i...r1 a ~"nrCCOO called flicker .
'Ihi.s is SL'!Ular to the effect "ttich results fran runni..ng a rrovie projector too
slew. minittun rcfrcs.'l rate of 30 tires per SC<Dnd is roqui..red to achieve a
A
flicker-free displaJ. A ref,...,._s'l rate of 40 tires per SCCl::lOO is reccrrrnndcd.
'I!.e !unction of the display buffer is t:O store m sequ"..l'lre all of the inst.ruc-
tions neoc.ssacy to cirtlw the picture on the catliode ray t\be. fu function of
the display controller is to access (cycle through) these instruct.ions at the
refresh rate. Imccdiately, a limitation of the refresh ~lay is obvious:
'lbe OOiplexity of the picture is l.i.mited by the size of the display buffer and
the speed of the chsplay oontroller. Ho..-ever, the short persistence of the
ilnac]e CM be liSE"d to advantage to sho.-r dynanic rrotion. In pcuticular, the pic-
ture can be \.{)dated every refresh or, say, every other refresh cycle if dolble
buffering is used. fUrther , si..nm each elcrrcnt or instruction necessar; to
drcr,.. the mcplet.c picture exists in the display buffer, any individual ele!mnt
can be changed, deleted, or an adlitional e1crncnt £Kklcd: i.e., a selective
erase feature can be iltplarented. One additional disadvantage or a refresh CRI'
graphic device is the relative difficulty of abta.i.nirxj a hard oopy of the pic-
ture. 1\lthough refresh CRJ' graphic displnys are generally rrore e>epcnsive than
storage ttiJe displays , the above characteristics make them the Uisplay of choice
when dynamic rrotion in real t.irre or very rapid interaction with the display is
required.
A raster scan CRT grafh,ics display uses a starxlard television monitor for
tile display c:or.sole. In the raster scan display the picture is cnrposed of a
series of dots. These dots are traced out using a dual raster scan t:.cchniqoo,
i.e., as a series of horlwntal lines . 'l\o.1o rasters as sho.m in Fig. 1-10 are
used to reduc:e flicker . 'lhe basic electrical signal used to drive the display
cxnsole is an analog signal wl'Y:>se nodulation represents the intensity of the
individual dots which cntpot:;e the picture. In using a raster scan display con-
sole it is first ~sary to convert the line and d\aracter infotmatlon to a
form <:x:ccpatible with the raster presentation. 'Ihis pn:leeSs is called scan ccn-
wrsion. once it is converted the infox:mation mJSt be stored such that it can
be ae«:Ssed in a reasonable manner. With the advances in data storage tedmi-
ques this is ~9 rrore feasible . In considering a raster scan CRT graphic
display, the odvantagcs and disadvanta~ are similar to those for line-drawing
displays , with sate additional cx:nsiilerations . Narrely, they are generally sore-
what sl011er, the selective erase feature is rrore difficult to inpl.erent, and
they 11\:lY be directly interfa~ to cloGed-circuit television systans.
Digital incre:rental pen am ink plotters are of two general types - flat-
bed and drum. Figure 1- ll sho..ls a flat-bed plotter and F~g. 1-12 sho,..rs a drun
plotter. l'bst diun and flat-bed plotters qJe.rat.e in an incrorcntol rrode: i.e.,
the plotting tool, which need rot be a pen, noves across the plotting surface
in a senPs of small steps , typically 0.001 to 0 . 01 inch. Frequently the run-
her of directions in which the tool can nove is limited, say, to the eight
directions stn.n in Fig. 1-13. 'lhis results in a curved line appearing to be
a series of small steps . In a nat-bed plotter the table ll1 generally station-
ary aro the ·..ni. ting head rroves in o.u
di.rrtmsions over tho surface of the table .
A d..>"\r.\ plotter uses a sarewh8t different
f-t n t ra~ lff
'-t:conll ra ~ tt:r technique to achicvo bo."CHl1.!:-cnsional no-
tioo. Here the marld.nq tool rroves bac:Y.
and forth across the paper while the
-__,....--:::
= c:..
--- - -
-~
, le.ngth.dsc notion is obtained by roll.i..nq
the paf>"'r ~ck and forth uroer the rrork-
-- _.... _,_.
-
,;::;;JI-...c..-- -
-- - - - -::-~
ing tool.
Digital i.ncrem:mtal plotters can prov:ide
. r=::
--
------
-- -- ~~
...-.:-
-- i.ntl!ractiw gratilics . no--ever, where
-----~-- L ~'
.
'" - '\. __ -- large dra.rings are noill\llly required for
-- ......
__,- -
_____.--
a particular aplllcat.ion, a flat-bed
---- -- '
- --- ----------'
-~-<..: --:11.:-..T> -
plotter can be utilized as a coubination
digitizer and plotter and an interactive
Figure 1-10 Paster mtputer grllfhic system S'n::essfully
scan technique.
cb.-elopcd (see Pef . 1-2) •
':he elect.rost.1tic oot matrix printer/plotter operates by depositing part-
icles of a toner onto small electrostatically charged areas of a speoal paper.
F1gure 1-14 sho-"9 the qenernl ~which lS esrployed . In detail, a specially
coated paper which will hold an electrostatic charge is passed owr a writing
head -.,tu.ch oont:cu.ns n ro..- of SJMll ~-riting nibs or styb.. Fr'Oia 70 to 200 styli
per inch iU'1:' typical. The styli deposit an electrostatic charge onto the spec-
ial paper. Since tho alectrostatic c:ha..rges a..re therrselves rot visible, the
charged P<l?"r is passed over a toner which is a liquid oontaining dark toner
particles. 'lhc particles are attracted to tr.e electrostatically dlarqed areas ,
~ then visible. The paper is then dried and presented to tOO user. Very
high speeds can tx> d:>tainOO, typically fran 500 to 1000 lines per minuto .
'lhe elccLrosl..c:iUc cbt rnatri.'< printer/plotter is a raster scan device; i.e. ,
1t. pres~ts mformation one line at a t.irre. Bec.!suse 1t is a raster scan devire
it. requires .:1 scl>stantial crount of mcputcr storage to construct a CXJC•pletc
picturo. 'lhis p lu.,. the fact that the ~vice is useable for only pass1.ve gr~
ics 'll'T' the principle disadvantages. A further cti..ecedvantagoe 1..9 relatively lew
accuracy ar.d rcsolut ~ m, typically ~ 0 . 01 l.lldl. '1l\c principal advanta<}es are
th.. very high speo..-.d wi th "''hich drawing!> can be prtdloed and an excellent reli-
ooility rcoord. Figure 1-lS sho.ls an electrost..'ltic dot rrat.rix printer/plotter
Figure 1-ll flat-bed p1otter.
-- OJ
,
I Pa Jl e r
$Uppl)i
f'irst let's consider the difference beb.'een a passive and an active grafhics
d>vi~. A IldSSive qr~cs devi~ s.inply draws pictures lrder O:XIpulcr control;
i.e., it alla..~S the o:x•puter to Cl001'1lln.icate graphically Wl.th the user . EXillTplcs
are c1 t.elctypa , a high-speed 1..i.ne printer, and an clcctroGtatic oot matrix
printer, pen and ink plotters, and stor~ tlbe cathcxie ray tlbe (CXJ') and re-
fresh CRI' devices . Exar.'plcs of sate of these deVices curl the typical pictures
that th~ rniljht qenr;:rab: an. sho..-n in fig. 1- 10, 1-U, and 1- 15 t.h.ro\ql 1-20.
'!be re~r might wonder aboot ronsidcrinq thP tel etype and the high-speed line
printer as gr.J(..hics devices . l~ver. the'; have been used to drcr,... sirple
qrafhs or plots for a nurber of years .
-
I ~
,p J.
- •
~
rill
~~iii:'!
I
~
..:
Ill'!
:;;;,
1.11
:00
- ....
-
---:
. -• --------
-
....
~--
- --w
~ -.
---
••
... :. ..__...,.._
- - ~-- -
·-• -· - ...__
. c;,.r-
4
• ~
- -
__ --
• --.- =-=-.:-:
~JI::: .... <IIt • ••
·-
-·-· --
-·-- ~- --- --
--... -·
......_...._........._
--~--..,.._.
- ....,..
a---......,...
...,_._,_
- - -~ ~ -'\.- ;-_:.:
_
_....__,.,.
.......
~
C"'".._..... .... .,_
--~-
- --- . ·n:--.s••:r
- ... .... . .
::----...,._ - -:e.!:.
-·...., .---
.-... =~
.
-- -- ~.:a- · ''::"~-":""~.-L'-
·: •• I "· -·-.:::s--- ..,.. ___
..........
- --
..Cl.::. ---.5 •
•
c.::~ · , z~:- - - --.. • •
----
- e; ----
-~-
• -- •
-~·-.:
•
:J:ii·----
- - ,,..
• i:"
.......-.--
·~.,_
~····:::."--
-~~-- -
..,..... -- ----
f'=oii_,___
-.:
...... .,_. .
~. c: -..-...,;; --~
INrR:IXX:l'ICN TO C'Of-IPI.1I'ER GPJ\PI JICS 'l'mNXDGY 21
•
llo
............
I •
•••
... ···-· ······· •••• •• ··-·-······- ...
•• •
.. ..... . ·· · ~ · ... ......... • • • it
..
• •
•·•
•
•
•
•• ...•
• • •••
•
•
•
•
•
•
•
•
•
•
•
.
• t 'I
• •..........,,,
• .. ..
• •
• •
•
•
•
•
•
•
••
•
.. • •
••
•
....
• •
• • • .. -1-PI' ........
• • •• • •
. ..• ..
• • (' )
• • ••••• •
••• •• • •• • •
• •
• •• • • • •
• •• •
••• ..•
•
•
• • •••
..
••
•
•
..•
....
• • •
•., • ••
•
•
.. • •
• •
•
•
•
• •
•
• ..•••
• • •
•• ..
• •
• •
•• ••
•
I
••
•
.. ....• •
....
• •
•
•
••• • •• •
•
•
• •
• • ... 0
..
•
• •
•••
•• •• • • I
• • • •
• • • •
•• • • • • •
•• • •
•
• ..
•
•
• •
•
•
•
•
•
•
• • • •
• •
• • • •
•• •
• • •
•
• • • •• •
...
.
• • • •
•• I • • "'• • I .. •...• ••
• •••
••
... .... -· •• .' ....
• •
. •
•I
., ol '
• " •I• ' I fI I f
•••••••••••••••••••••••••••••••••••••••••••
•• •
• •
•• • ••••••••• •
• ••• • ••• •
•• ••• ••• •
•• •
• •
••
• ••
•• ••
• • •
•• • •
• •• ••
•• •• • •
• • • ••
• • •
•
•
• I I
•
•• •• •• •
• ••
• •••• • •••••• ••
• •••••••••• •
•• ••
•
••••••••••••••••••••••••••••••••••••••••••••
Figure 1-20 Teletype
and typical grapuc output .
I f points are plotted close enough t:.ogether , they will awear to the eye to be
a solid line. All the storage tli>e CRl' and rrost refresh CRI' gnph.ics devia:!S
are line-dra.ring devices. All the pen plotters are · devices. 5atc
refresh CRr grapucs devi~, particularly raster scan (televl.Sion-lil'..e) devl.ces,
can be oonsidered as point-plotting gra(ilics devims . 'l'eletypes, hi<jl-sp:'ed
line printers, and electrostatic dot matrix printers are classed as point-
pl otting devices . 'lhe uti 1 i ty of a device can f~y be CX)OSl..deted in tet::ms
of its resolution; e .g . 1 a teletype has a resolution of ! 1/20 i..ndl horizontally
aro : l/1 2 inch vertically, ~reas an electrostatic cbt matrix device may have
a resolution of :! 0. 01 inch.
Still another rret:hod of classifyin] graphics devices ~ dctenni.ning
whether a device can aooept true three--di.nensiooal data or whether threc-
d.Urensianal data nust first be converted to n.u-d:irrensicnal data by the appli-
cation of sare projective transformation and presented as C.u-dirrensional data.
In essence this rrethocl requires detex:mi..ning whether a gra._chics device has 0..'0
or three registers to hold ooordinate data. In the case of a al
device the third or z ooordinat.e is usually used to control the wtensity of
a CRl' beam. '"tis feature is caned intensi ty m:xlulation or gray scaling. It
is used to give the illusi on or depth to a picture.
Each of the classification rret:hods will f-requently plAce a particular
gra{ilics device in a di fferent categoxy. Ho«Ner1 each tmthod roes yield sorre
insight into the characteristics of the vari ous graphics devices .
Appendices A and C contain the architecture o f a software sche:fre based on
the concepts presented in this and in subsequent chapters. Of C'Olli'SC , the
description or position vectors , lines , cu.rves , and surfaces aro the transfor-
mation of these gearetric entit ies can be accarplished mathenaticaJ.ly indepen-
dent of any display technique or display software. 'lhe remainder of this book
is conoerned with these mat:hefratical , devioe-i.ndependtmt techniqoos .
REFERENCES
2-1 ltrrROIU:TION
~·1e begln our study of t.l-te furxla.'ielltals of the matharatics underlying ca•r-
p.lter grapti.cs by oonsidering the .representation and transformation of points
and llJleS . Pol.Jlts am the lines wbidl join them Me used to represent oojects
or to display infot:rnation graphically on devices, such as discussed in Chapter
1. '1he ability to transfonu these points and lines is basic to CXX1pUte.r gr a-
rtUcs. \-,'hen visualizing an d:>ject it II1!!IY be desirable to scale , rotate , t r ans-
late, distort, or develop a perspective view of the object . All of these trans-
formations can be ac:carplished using the mathematical techniques discussed in
thi!i and the next dlapter.
cl ·ruions t:>r by r~J in three di.Jrensions . ION rMtrices like (x,y] or oolurm
rotrlc.x:s like [r] arc frequently called vectors . A series of points, ~ of
f'OINI'S N:O LINES 25
'lhc c.lerrcnts that make tt> a matrix can represent various quanutics , such
as a mmber store, a nab.'Orl<, or the coefficients of a set of e:JUations . '111e
rules of matrix algebra define allaVclble ooe:rations on these rntrioes (cf Appen-
dix B) . t1an}• physical prd.:)lerns lead to a rrotrix fonrulation . Hero the prd>lGn
m::ry be fonrulated as: Given the matrices A and B flnd the solution matrix, i.e.,
Nr = B. In this case the solution is T ,. A- la, where A-1 is the inverse of the
square matrix A (see R:!f . 2-1) •
l\n alternate usc ofa matrix is to treat the '1'-matrix itself as an operator.
Here rotrix trultiplication is ~ to perform a georetrical transformation on
a set of points represented by the position vectors contained in nutri.x 7\. 'nle
matrims A and T are assurrcd krn-'1"1 arrl it is required to det:.e.rrnine the elerents
of the matrix B. Th.is interpretation of a mat.ri.x nultiplication as a ~trical
'lbis mathematical rotation mans that the initial CXX>rcli.nates x and y are trans-
fenc-ed to x* and y*, where x* .. (ax + cy) and y * = (bx + dy) • We are interested
in investigating the inplicat.J.ons of considering x* and y* as the tra.nsfornoo
CXX>rdinates . \'le begin by investigating several Sfeeial ~,ses.
(X y) [~ ~ J • (ax y) = (x•
y*) (2-3)
'!his produo~ a scale change since x'" =- ax. 'Ihis transformation is sho.om in
r :1q. 2-la. llenoe this natrix nultiplication has the effect of stretching the
original ooordinatc in the ~on .
ard a reflection about the y-axis has occurred . The effect of this transfonna-
t.ion is sho..m in Fig. 2-lc . If b = c ~ 0 , a::: 1, and d = -1, then a reflection
about the x-axis occurs. If b = c = o, a = d < 0, then a reflect.l.on about the
origin will occur. 'Ihis is slnm in Fig . 2- ld, with a = -1, d = - 1. Note that
reflection, stretching , and sc:al.ing of the ooordinates involve only the dia<JOM.l
tcnrG o f the transfoDMtion rratrix .
No..' <::a)Sider the case where a = d = 1, arxl c - 0 . 'Ihus
[x y) [~ ~] = [x (bx + y) 1 = [X* y*] (2- 6)
IIP['P '1\"e see that thP o rigin is invariant uroer a general 2 X 2 transfonmtion.
'ltn s is a liJTU t.ation whidl will be overc:nre by thP. use of ha•ogenrous coordinates .
POINt'S AND I..JNES 27
• ' ,. \ , A• I. L
'·~.
~ c
\. \ ) . ~ ~ ) .
)
".
,,,.T= [~ ~] .
(\'•\
T= r-10 -1OJ n
.-
I'
,
·" ,.
!- •
h~ T
[~ ~]
)
r
•
,,
, ,, .... \ ,. h\
',. • "' ".
,
~ "'
f
••
I'
A straight line can be tlcfined by bov rosilion v.....ctors \olhi.d1 specify the
CXJOCcli.ndtes of its end (X>ints. 'nle position and orientation of the line joirr
uq these b.."t> points can be c:::hatY.Jed by operatul<} on t:hcsc two pJSition vectors .
~ actual q>eration of dro:JWing a line bet\-'{!(:11 two points will depend on the
output ck.'Vi.ce used. Hen. we cx:m sider only the mdUtunalical operations on the
er¥:1 posi lioo vectors.
A straight l ine bebw'cen b>o points A and u in a ~ional plarE is
drd;IJ'l in Fig. 2-2 . 'lhc posit ion vectors of r.ou1ts 1\ and D CJ.re (0 11 aro
(2 3) rest=eelively. No.I cons1der the trrlllStoDT\llion malrix
[~ ~]
(2-7)
T =
....tuch .,.,'C recognize fran our previous discussion llS producing a shearing effect.
~.Sing mJ.tri.x ITllltipliC<ltion on tllP position vectors for 1\ and B prodllCes Ule
~w Lransfomed vectors N· cmd a• CJl.Ven by
AT~ to 11 [~ ~] (J 1) • A* (2-8)
8'!' : (2 3) (2-9)
J
o:::nsider transfolT.Iation of the midpoint of the straight line beboleen A and
B. Letting A = [xl Y1l, B = (x 2 y 2 ) 1 and T • [: and transforr.U.ng both
] (2-U)
\,hlch gives the mic\X>int on line A*B*. 'lhis process can l::e rep"'.lt.ed for any
subset of the initial l i.ne, and it is clear that all points on the initial line
Lransform to points oo the second line . Thus the transformalion providas a one
to one correspondence bet..;een points on the original line and points on the
transfor:rred line. Fbr o:::rcputcr graphics applications, this nmns that any
straight line can be transfo.rtred to an.t nEM position by s.inply transfonning its
end points and then redrawi.n9 the line betlo.-een the transfomed end points.
result is <1 seoond pair of parallel lines . To see this, oonsider a line beb."OOn
A = [xl y 1 ) and B .; lx2 yz} and a line parallel to AD beo.Aoon E and f' . To
shari that these l..incs and any transfomation of them are parallel, we exa:-.U.ne
the slopes of AB, EF, A*B*, and E*F*. '1he slope of both AB and EF is
Y2- Yl
mt • X2 - Xl (2-16)
xl
[><2 Y1
Y2
J [a b] =
c d
rnx1 + cyl bXJ. + d.Y11 = [><!
lax2 + cy2 bx2 + b.Y2 ~
yt]
Yi
= [A"]
B1t
(2-17)
I(I
10
T: [~ ~]
• l
6 ( 1/2 J/] lA
l •
) .\ .
4 ...
·u ·2 ~ H13 · ll
,
-
0',\ ~· - 4-
0
0
,
• b IU
•
12
•
'·"
Figure 2-2
Transformation
of straight llne:s.
Figure 2- 3 Transformation
of intersect.ing lines .
'1\-.lo dashed 111tersect.ing lines AS and EF are s.ha.m in Fig . 2-3. 'Ihe ~int
[: ~] . 'll\us ,
- -
1
2
3
2
1 2 - 1 _!!
2
3 -2 1 -3 12
romrs A'llD LINES 31
-1
[ ~-1]
3
[1 1 -3
2] - -2~ 1 1
3 3
This gives the solid lines A*B* and E*F* sho..m in Fig. 2-3. 'lhe transfamed
point of int:ersect.ion is
[~ ~) [l 1)
'lhat is, the point of intersection of the initial pair of lines transfotli'G to
the point of intersection of the t.rclnSforned pair or lines . Close examination
of the above transformation of intersecting straight lines will sha.l that it
has involved a rotation, a reflection, and a scali.nq of lhe original pair.
However, the total effect of a 2 x 2 matrix transformation l.S easier to see,
considering the effects of rotation, r eflection, and scaling separately . In
order to illustrate these .itdividual effects, we shall oonsider a sinple plane
figure - narrcly, a triangle.
2-9 fbTATION
Consider the pl ane triangle ABC s.ha.m in Fig. 2-4a . 'Ihis triangle is ro-
tated through 90° about the or igin in a counterclockwise sense by operating on
ead\ vertex with the trnnsforTMtion [ 0 1]. If we use a 3 x 2 matrix conta:i.n-
-1 0
ing the x- a00 y-coordinates Of the vertices 1 then
(2-19)
3 1 [01]'"' 13
4 1 -1 0 -1 4
2 1 -1 2
'Ih.is produces the triangle A*B*C*. A 180° rotation llbout lhc origin is abu.i n-
ed by using r-1 0] and a 270° rotation about the origin by using lo -1].
0 -1 1 0
Note that neither scal.in;1 nor reflecticn has occurred in these cxanples.
2-10 REFLECTION
~\!lereas a pu.re ~onal rotation in the xy-plane occurs about an
ax:is norm:ll. to the xy-p1ane, a reflection is a 180° rotation <~bout nn axis in
the xy-plane. 'IWo reflections of the tri.anqle [EF am shcMn in Fig. 2-<lli . A
reflection about lhc line y =x occurs by usinq [~ ~] •
(}'
•
I•
a !:>
s ,-• ro
•
l - •
....' e- 2-20)
~
I 3 1 oJ 3 -
~6 2 -
,(. 6.
J.• .ref~on a::xr~ y = 0 :..s cbt.a:. nee fr.::clfl _,0, .
..(; -4
a-'"C s-h~. by
•
a l- 1 -- • -
-~J
8 -l
7 3 0 7 3
.e 2 6 2]
~.q a.:.r d' sc.:.ss!.on of ~-...e r:...~.sfot~ar::oo cf r=oi:ts, W'£: can see mat
sca 1 ~ r.g is cxr.trolled ~· t.'le. rogr.itu:ie of ~"'.e t;.O te~ or. ~..e: p~-.:tri ~.al
cf t."le ratri.Y.. If the t'iltr-Y. r2 0 .:.S ..:sed as Zi!". 0""~-.ttor cr: the ..~_ioes
.0 2j
o f a ~~"l'il~, a .. 2-t.i:'cs• e.-: .arge: -er.t. occ;.n:s abo"~ the oric;.r. . If the r..ac;ni-
tn1es nre ur~l, a d.lSt.OrtJ..on oo:.-.!..""5 . ~..t:S= eff~...s are sha--n i:-. fig . 2-'>.
Tria."¥]!~ 1-& if: t=c;J"Sfc:::;:-.-,d at 2 Q'j ; ~'l:.s a sCil.l.i.N; OCC\!I"S , a.'"ld <c...""ia~:;le
0 :2
POD\'TS A"''D t..niES 33
~
the \.~oes , the shape and position of
the surfa~ can be controlled. Ho...-e\...:rr, (\
;'
- It
a desired orientation my require no;re
r r c·
than one transformation . Sinre mtri.x ~ ~ 'I
, '"' ~~~·
nultiplication is noncntuutatiw, the - I)
-
- -
">; "8
,_
\
--
••
\
,.
-' ~
- h
\
and then
(-y X) [-~ ~] •
(- x y)
(X y] [ -~ ~1 =
[-x y]
and
[-x y) [ 0 11 • (-y -xl
-1 0
is d:>t:aizled .
So far we ha\."C concentrated on the behavior of points and lines to deter-
mine tho effect of sillple rratri.x transfonrations. However, the rratri.x lS
correctly considered to operate on C:Vt.l'll point in tr.e plane. As has been shown,
the only poir.t that remains invariant in a 2 x 2 matrix transfonnatjon is the
origin. All other points within the pl ane of the coordinate system are trans-
ferred. ~ transfoll'l\ltion nay be inte.rpreted as a stretching of the initial
pla~ and coordinate system into a new sh.apQ. M:>re forna.lly, we say that the
transfonMHon causes n J'lk'!IPPi.nc; fran ore plane into a second plane. Exanples
of this rnawin:J are sm.,., in the next section.
~ ~ 1[: :J- ~ ~
(2-21)
:: :::
: ~ ~J la: c b : d:
..
l •
I
tJ' u
~-
- -x
I
a Before b After
as follc:MS :
~ • (a t- c) (b + d) -j{ab) - i(cb) -¥(b + b + d) - ~(c + a + c)
which yiel ds
(2-22)
(2-23)
In fact , since the area of a general figure is the SUTI of urut squares, the
area of any transfomcd figure~ is related to the area of the initial fi«]llle
~by
(2-24)
[_~ ~]
In effect F.q . (2-25) is a mrbination of scaling and shearing ~ch leaves the
final dirrensions unc:h.anged. 'lherefore, this transforrrat.ion rr.atrix produces a
pure rotation through an amitraey angle e.
Up until the present t:.im! we have rot discussed the translation of points
and llnes or the figures or shapes resulting from COJtbinations of points and
li.Jl,e,s . E\.rndM"entally this is because within the fran-e ,.ork of a general 2 x 2
l1\3t.rlx it is rot possible to introduce the constants of translation. Foll.ow.l..ng
Fouest (Pcf. 2-2) we rote that this difficulty can be overc:x:JTC by introducing
a thlrd corponent to the p>int vectors {x y] and [x* y *), naking them
[X y 1) and [x* Y" 1) . 'l'he transfonnat.ion I'T'atrix then becares a 3 x 2
matrix, say,
'Ihis is necessary since the nurber of ooh.rms in the !X)int nntrix nust equal
the llUiber of ro.tS in the transformation matrix for the operation of matrix
I!Ul.tipllcat ion to be defined. 'Ihus,
[x y 1) 1 0 ' = [x + n y + n] "" (x• y•] (2-26)
0 1
m nJ
where W"e note that the constants m, n cause a translation of x" and y• relative
to x and y. tblever, a 3 x 2 rratrix is not square and thus does not have an
inverse (cf 1lppCNiix B) . 'Ihis difficulty can be ovenx:t~1c by utilizing a full
3 x 3 matrix, say,
1 0 0
0 1 0
m n
as the t.ransfonmtion matrix . Notice that the third exxtp:)nent of the position
vectors i s not affected by the addition of the third col~..~~m to the transfo:tm:t-
tion matrix. Using this matrix in SJ. (2- 26) gives (x* y" 1] for the trans-
fonred vector .
'lhe adCi +-..ion of the third elarent to the position vector a00 the third
co1mn to the transformation matrix a.l.l.oNs us to perfonn a trar.slation of the
position vector. Alternately W"e may consider the third elerre.nt as an addit.J..onal
coordinate of the positioo ·vector. For notatiooal pw:poses we assuro that when
the fX)Siti.on vector (x y 11 is operated on by a general 3 x 3 natrix it beoorres
the p:>Sition vector [X Y H) . Previously the transforrratioo was perfo01ed suc::n
that (X Y Hl • [x • y'* 1} . If we consider the t.ransfooration to be taking
pl ace in thrce-dimmsional space , this confines our trar.sfor.retions to the plane
H ,. l. If, t-o,..ever, W"e assure that the third colum of the general 3 x 3 trans-
fomation matrix T is
rather than r0
0
ll
matrix rrultiplication yields [x y l )T = (X Y H) , where H 1- 1.
'lhe general plane in 'Whidl the transforrred position vector rt::M lies is in
th;t:'e(~.immsional space . However, at the present tiJre we are not interested in
what happens in . ional space. Hence we d>tain x• andy* by proj ect-
ing ftun the general plane back onto the plane B = 1, using a pencil o f rays
thrcu.Jh the origin. 'Ihis effect is shewn in Fig. 2-8. Csing si.rnilar trumgles
\o.'e see that H/X = 1/x* and H/Y ,.. 1/y* . With three ca1pooents it follo.-."S that:
X y (2-27)
(x* •"*]
:r = [-
H -H 1]
\ree-Cli.rre''lSional vector representation of a two-di.Jrensiooal positioo
H,
sc nc rat
plan CHII
*Note that here we have put the result of the tr&'\Sfotrnation oo the left-hand
side of the equation rather than on the right-hand side as was done previously:
i.e . , we write rratrix equations as B = AT rather than as 1'\£ = B. Fl:an hereon
we w1.ll adopt this c:onwntion for ease in translat.i.ng results into cmputer
algori tlurB.
romrs J\ND I....INES 39
x* .. ~ and y* - ~ (2-29)
0 1 q
0 0 1
Here X • x, Y • y , and li • px + qy + l. 'Ihe coordinate H ~ch defines the
plane containing the t:ra.nsfonred [X>ints expressed in harogcncous coordinates
00;1 has the equation or a plane in thlre.<:Hii.tn:msional space. 'lhi.s transforma-
tion is sho.m in Fig. 2-9, where the line AB in the two-dimensional xy-plane
is projected to the line CD in the ional plane pX + cfi - II + 1 = 0.
In Fig. 2-9 the values p "" q = 1 are used .
!l:onrallz.i.n<;J to obtain the two transfoll'OOd ordi.nacy coordinates, t;le ,.'rite
X X
x*-n=pX+qY+l
y y
y* ; if = pY. + qY + l
>"
2-
( . ,
-
(
-'-7'~o·- . - II I
•
. ..
' A
l..s we have seen a , b , c, and d produce scaling, shearing, and rotation; m and
n pttxluce translation; and p and q prcxluoo a projection . 'Ihe f ourth part,
elcrrcnt s , produces overall scaling . 'lb shcMr this , consider the transformation
(X Y H) "" [x y 1) 1 0 01 • (x y s] (2-30)
0 1 0
lo o sJ
POimS NID LINCS 41
t-fl ,,/~ j ol
1 1
55 0
3 2 1
LS 5 .J
~tiplying both sides of Eq. (2-31) by 11C1 and noting that l·r·C1 = I, the
identity TMtrix yields
l 3 2
[x y 11 • 'S" (0 0 ll
1 -1
3 2
'nlus, x "" 3/5 and y = 2/5 es :req..:ired .
Conslrlc- tloiO parallel lines defined by
x+v=l ~
x+y=O
Proc::ee!ing as above leads to tt.e r.atrix EqUdtion
(x y 1) ~ 1 1 01 • (0 0 1)
1 1 0
•
..-1 0 lj
fb.'C\.'C.r, C\te.:'l though a square matriX exists in this equation, it does not haw
an ~rse, since t..o ro..:s are identical . Another al t:.emate eguation is pos-
sible t..trich does have a., invertable mn:riY.. 'Ihis is gLvcn by (cf ~. 2-3)
(x y 1] j l 1 11 = [0 0 x) (2-32)
1 1 oI
-1 0 o..
The :i.m:erse of the 3 x 3 rratrix in Ec;. (2- 32) is
r~-1 = r~ ~ -~l
Ll -1
!-hlt!.p1y.L'¥3 both sides of Eq. (2-32) by this inverse gives
lx y 1] ~ (0 0 x) ro 1 -11 - (x
1
-x 0] x[l -1 01 (2- 33)
I 0 1 1
l1 -1 o. .
~ resulting hatO<)el'leous CXlOrdinates [1 -1 0) nust represent the "point of
intersectJ.on" for the n-o pa.rallellines , i.e., a point at infiruty. In ge."leral,
tr.e t::...'O-d.urensicmal hatOgeneous vector (a b 0) represents the point at infinity
on the line ey - bx = 0.
'Iho fuct that a vector with the harogeneous carponent 11 equal to zero OOe5
indeed represent a point at infinity can be illustrated by the limiting proc:ess
Sh.'Cn be1cw. ConsJlder the line Y* = (J/4)x• and tr.e point (X Y) • [4 3] . Re-
calli r.<:J that a unique represe.r.tation of a position vector docs not exist in
b:::m.::xJcneous cx:ordinates , tr.e point [4 31 can be represer.ted in hcr.cgeneocs
co:>rd.i.nat.cs in all t.~e ways sl'lcwn in Table 2-l. See ~f . 2-3 . Note t:Mt lll
Tal;le 2- 1 as tH>, the ratio of yi/x' ren:rlrs at 3/11 as is rEqUired by the gove...>n-
ing cqt2tion. F\lrther rote that SIICO"!SSiW paj rs Of [x• y*), all o f .._'hid\
!all on the line y • - (J/4)x•, beoat·e closer to i.nfiru.cy. 'ihus , in the linit
as 11-.o , tl1e p:>int at inhnity (x* "r 11 = (m (I) 1) is g~ven by (X 1 H) •
POINIS .aND LlNF..S 43
Table 2-l
Harogeneous Coordinates for the Point (4 3)
H x* X y
1 4 3 4 3
l/2 8 6 4 3
1/3 u 9 4 3
l/4 16 u 4 3
•
•
•
l/10 40 30 4 3
•
~J
1 0 0
""'1'1\ -n 1 l 0 0 b n l
By canyinJ out the n.-o interior rratrix products we can write
(X Y H) = [x y 1) f cos6 sinO 0, (2- 35)
-sine cosl3 o
+ n(si.ne)
-'"1ll (c:xl50 - 1) -rn(sin8) - n(cose - 1> lJ
For e:-carrple, ~ the center of an cbject is at I 4 3 ) and it is desired to
rotate t.'ic cbject 90° counterclocJG.tise about its o.m omtral axis . ~tion
by the matrix
0 1 0
-1 0 0
0 0 1j
causes a rotatiGn about t:.hc origin, rot the ooject axis . As sho.om above , the
~~ procedure l.S to fust translate the OOJect so that the desired center
of rot.iltion is at the origin by using the t.rnnslntion n'iltrix
r1 o 0
0 1 0
-4 -3 1
then apply tr.e rotation mat.rix, and fil'lally translate the results of the rot.:r-
tian bac:X to t.'ic original center by rreans of the reverse translation rratrix.
'Ihc: entire q:Jera tic.n
[X Y H] [x y 1) 1 0 0.., o1 rl 0 01
0 1 (2- 36)
0 1 0 -1 0 0 0 1 0
L-4 -3 1,; 0 0 1J l4 3 1J
can be cn•bined into or.e rratrix cpo:>...ration by conc:atenat.J.ng the t.ransforrnatic.n
Ntrices, i.e. ,
[X y H] = [x y 1)
I 0 1 ol (2- 37)
-1 0 0
•
7 -1 1J
'11-.enl x• X/II andy* = Y/H .
'lWcrdiirensional rotations about each cuds of an orthogonal nxis system are
represented in Fig. 2- 10. A cntputer al90rithm for performing a t:wo-dirrensional
rotation about an arbitrary point is given in Appendix c. a.long with other
algori thn'6 for ~ic:nal translation, scal j ng 1 and reflection .
REFERENCES
2-1 f'ox1 L. An Introduc:t:.ion to N\marical Li.near Algd>ra, OXford lhriversity
PresS 1 1.nndon 1 19 64 •
2- 2 Forrest, ;,. P. . 1 "Co-ordinates, Transfoxmations , ard Visualization Techni-
que.•," CAD Grol..p ~t N:>. 23, Cafl'brid:;e University, June 1969.
POINTS At;o (,fNE:S 45
2-3 Ahuja, D. C. , and Coons, s . A., "Gecm::ltry tor Const.ruction <lrd Displa~·, ..
IB15yst. J., vol. 7 , oos . 3and 4, pp.l88-205, 1968.
,. l
•
,. 1
1 0 0 \
0 • \
>" CClS)' SlJl)
\
}
0 -silry oosy
\
l .->"
\ ""I
'{. l I
'
->
,. 1
,.. "
oosa 0 -sl.nS \
0 1 0 \
,.
-' -
\
sinS 0 cos a \
\
\ .,.,. ~
j·
\ .. I I
>"\ }'
OOSil sim 0
. \
-smn coso 0 \
0 0 ] \
\ ... ... ..>..
,..J
\
... •
'
X Y Z
lx• 'Y* z• ll • Iii ii ill (3-1 )
1ooo1'1ero T is sore t.rans!or.rut1oo catrix.
'I'hc c_,'Cnarali7.&l 4 x 4 transfoil"oaticn Ntrix for three--dirnlo_nsicnal haroc}e-
tlDOUS coordinates is
T• ab cp (3-2)
defq
hi j r
tmns
The 4 x 4 t.ransfonnat.ion matrix in Eq. (3-2) can be partit.loned into four
sepsrate sectiCX'lS:
3
J X 3 X
1
--------
1 X 3 I 1 X1
A 0 0 0 1
8 00 1 :
I
-c.n
--c.a~
I
C . 1~
O.l
0
0
- 0
o.~
0
1
0
I
I "'
I c.•
c o ac J o.• I l 0 -.n l O.f I
t D 0 1 1 : 0 0 0 1 -o.~ :1' 1., l
r. 1 0 II J -c.,. t' ,1!; l t•
I 1 0 1 I '
&.!. 0.15 l.~ I t•
0 l I II 1 0.1S 0.1~ 0.¥. r•
J ' 1 l 1
·'~ 1.1~ l,<l'j, •
s·
,.
•
Figure '3-1
'lh1s effect is shct.m in Fig. 3-lb. :Incidentally, the same effect can be obtained
by means of equal local scal.ings. In thls case the transfornatHX1 matrix "'Qlld
be
!9 0 0 0
0 !s 0 0
0 0 !s 0
0 0 0 1
The off-d.iagcxlal terms in the upper le£t 3 x 3 CXli{XOt'lent mat.rix of the gen-
erAlized 4 x 4 transfonration matrix produce shear in three dimmsialS, e.g.,
(x y z 11 1 b c 0 = (x + yd + hz bx + y + iz ex + fy + z 1)
d 1 f 0
hi 1 0
0 0 0 1
A siJtt:>l e t:hJ::ee-dirner1Siooal. shear on a unit cube is stxlwn in Fig. 3-lc.
0 cose sine 0
o -sine cos6 0
0 0 0 1
Rotatia\ is assunel to be positive in a right-han:i sense as one looks fr:au the
origin outward a.1.oog the axis of rotation. Figure 3-2a smws a -90° rotation
aro.xt the x- axis.
final result. In order to sln.l this, o:ns:ider a rotatioo abot..lt the x-axis fol-
lowed ~ an equal rotatioo about the y-axis. Using F.qs. (3-6) and (3-7) with
e =~I we have
T = 1 0 0 0 cos¢ 0 -sin~ 01 ('3-9)
0 cos6 sine o 0 1 0 0
o -sine cosS 0 sin¢
~J
0 cos¢
0 0 0 1 0 0 0
- cosa 0 -sin6 0
. 2e
Sl.n cos6sinecose 0
2
cos8sine -sine cos e 0
0 0 0 1
On the other hand, the reverse operation, i .e . , a rotatioo about the y-axis
f01J.o..Jed by an equal rotation about the X-axi.S with e= ~1 yields
I
T = cos¢ o -sin~ 0 1 o 0 0 (3-10)
0 1 0 0 0 case sine 0
sin¢ o cos¢ 0 0 -sine cos9 0
0 0 0 1 0 0 0 1
• case sin
2
e -oost sin6 01
o cose sin& o
2
sin6 -cos6sine cos e
0 0 0
Caq:larison of the right-hand sides of Eqs. (3-9} and (3-10) ~ that they are
not the sc:ure. The fact that three-d.iJrensional rotations are oonoc:mrutative nust
be kept in mind when tJDre than one rotation is to be made.
'Ihe result of transformatioo. of the upper left object in Figure 3-3 con-
sisting of o-o 90° rotations using the rratrix prcrluct given in Eqs. (3-9) is
.sho.m as the dashed figures . hllen the opposite ordcu of rota.tioo. as specified
by Eq. (3-10) is perfumed , the solid figures shaHn in Fig. 3-3 graphlcal ly
dem:nstrate that different results are obtained by changing the order of rota-
tion .
f'requently it is desirable to rotate an abJect about one of the cartesian
coordinate axes . Algorithms given in Appendix C allow rotatioo. al:nlt the x-,
y-, and z-axes.
1 0 0 0 1 0 0 0
0 0 1 0 0 0 1 0
../
0 -1 0 0 0 0 0 -1 0 0
~ ~
0 0 0 l 0
0 0 0 0 1
,
0
../
) •'
) •'
0 0 -1 0
0
1
1
0
0
0
0
0 / ------~
I .,.-" I
/
-r---71
0
-x;•
0 0 1
J&.-.-~--1-
/
} - - - ~ ~-- ..) ,~
/
/;/' /
7
/ I / I I .,.
/ / ___ _v /
// J--~--j
z•
f. ...... /
/ // /
/
, I//'--..'( /
~ ....... I / /
' ....V.,..
Figure 3-3
8
a·
0/
l .l "
A
B
1
1
0 -l
1 -1
1
1
1 0
0 1
0 0
0 0
- r1 0 1 1 A*
111 1 B*
c 1 0 -2 1 0 0 -1 0 l 0 2 l C*
D 1 1 -2 1 0 0 0 1 1 1 2 1 D*
E 2 0 -1 1 2 0 1 1 E*
F 2 1 -1 1 2 1 1 1 F*
G 2 0 -2 1 2 0 2 1 G*
I 2 1 -2 1 2 1 2 1 I*
The reflection of a uru.t cube through t.~ xy-p1anc is shc:7..m in Figure 3-4 . For
a reflection through the yz-plane,
T = -l 0 0 0 (3-12)
0 1 0 0
0 0 1 0
•
0 0 0 1
and for a roflcct.i<r. t:hroogh the xz-plane,
T= 1 0 0 0 (3- 13)
0 -1 0 0
0 0 1 0
0 0 0 1 •
An alqoritln which INill perfom t:hree-ctirnensional reflecticns is given in
1\ppendix c. Reflections al;o.lt ot:OOr planes can oo obta.ined by a oanbination o f
rotation and reflection.
y* = 'i = Y+m
H
z"' - !H = z + n
An a1gorithn for translations in three dimonsions appears in l\ppe1¥ii.x c.
2
n1 + (1 - '1 2l008 D n1 ~ (l - oosO) • n 3sJ..ne ~n 3 (1 - 008) - "2~1n 0 (3-18)
0 0 0 l
a derivation for dete.rming the elments of the rotat.l.oo matrix R .1.S given in tho
next section.
Fqu.ations '3-17) and (3-18) can be nserl as a basis for c::arputer software
algoritbns . SUch an algorit:l'lm is particularly useful for c::a1puter anirrations.
'Ibis transformat.ial , as well as others discussed in this dlapter, can also be
produced by use of hardware ~ts in a display device .
An algoritbn which will produce a · jooal rotation al:xJut an arl>i-
trary axis in space based oo Eq . ( l-17) ~ given J.n Appenchx C. The alqont.hns
for rotation about the in:lividual x-, y-, and z-axes previously discussed are
special cases of the present algorithn.
mine the elerrents in the matrix R, we rrust relate the transformed coordinates of
P* to three variables: the coordinates of P, the rotatial angle () , and the
direct.ioo of the axis of rotatioo as specified by the unit. vector n. • This dcri-
vatioo i.s given below.
~ dircctioo of the axis of rotatioo is nost easily expressed in terms of
three directJ.oo cosines, "1 = cosa , "'2 = cose and n
3
=cosy. The angles a, B,
of 1:.~ ~t ~_or n. .. .. .. ,
For arry gc.r.eral "l!Ctor
.. 0 = qlI • q2j + c;.j. tlu.s tr.it
wc':.Or u ca.lc-..:l.at:.ed by n • C/ C 1 where C is the absolute value of the vector
g1ven by i3 .. 2 +/q1 sl+ s 2 1 ard I 1 j, and k are u:ut veco-..ors l-"'1 the x-, y-,
3
a.."ld %-di:'~..l.a'Ui tesfE!Cti\lely. It folla..'S tr.at:
0.1
COS'l • "" n
1
;' 2 2 2
ql ... q2 ~ q3
q2
oos3 - --:::::::::==::::::;==::=: = "2
/ 2 2 2
• 0-1 + 0.2 .,. q3
•
q3
COS'( • --;:::::;=====:;- • n3
I• ql2 + q2
2
+ q3
2
-
-
!.."'1 t""d':.r!.X form t.l-Us 15 written as n {"t "2 n3] .
Z<
~ other results fra:1 ~....or calc-J.lus1 tl'.e dot product. a."ld t."le cross
•'
/
'
/
•
• _ :;/
I
p"
t)l'?-=:;:_-=
-:--- - -
-J •
1
- ·-
n
•
-
, ..
•
• .-\
Figure 3- 5
produ:::t, are needed to relate P* to P. 1h! vector dot prtxlu:::t is 91ven by
P . ~ .. IP nlcos~ • IPI~
.P = ..
where ¢ is the angle bet....-een the tw:> vectors, as shcl.m in Fig. 3-5.
[x y z) and n • (n
1 n 2 n 3 ), the dot product can also lx! expressed in matrix
since
form as
•P • n
• =~ + YJ7 + ~ c [x y z} '1.
"2
"3
~ vector cross product is give."\ by
.,. t" +k
.....
n x P • det n
1 )
n n =
1 2 3
X y Z
a !cn2z- n3y) + j(n)x- nlz)
In IMtrix form the cross product is
+ +
n x p = (x y z) 0 n
3
-"2
-n3 0 '1.
"2 -"1 0
It 1s also true that
... ..... .. ,.... .~
1n x P - n P sino) = P sin~
where + is again the angle between the b.'O vectors.
'lbe foll.o.oling three vector equalities are obtained fran Fig. 3-5:
0 + ci• • p• (3-19)
(3-20)
(3-21)
....... 4- .... .... ..
Fran Sl· (3-21), oP = (P - Q} . Since the magnitudes of QP and (F)* are equal,
the ma.gnitldc of vector QS, which is in the direction of QP, is given by
+ + •
OS • IOPicos9. Thus CS • (P - Q)cose . Using this result and m 1bining
Sis. (3- 19) and (3-20) gives
•u= nxP
.. .. -
...nxP.•
... ..
1n x PI IP i sin~
- -
SP• -
n• x P•
p Str.~
-.
p - Q Sl.n J
~ ~ en x P}s1.ne •
Eqt.:.11 t; cr. ( 3-21) can oow be written
...... ..... . ...
p• • Q + (P - Q)cos6 + (n x P)sine
- . (3- 22)
.. • t ....
Fl.9'..:.re 3-5 ~ !1-.at the vector C l..S t.lte proJection o f the voctor P on t.lv! axis
• :z: .. - ...
of rotation. 'lb! mag:nita'!e of Q J.S t'· n = P cos; , a.'ld the direct..ion of Q is n.
t:Sl.."lg the e<;Uality o.. <P·;;)n, r.q. (3-22) beocJres •
0 0 u •~ LO 0 0 l J
1'11P. three t.erTT'S within the braces give- the required rotat.ioo rratrix (R] .
L 0 0 0 l
R= r COSH sine 0 0
•
-sm cos., 0 0
0 0 1 0
0 0 0 l
'lhis rMtrix a<JrCCS with tlut given m Sec. 3-~ f or rotdtioo about the z-axis in
the xy- plane.
The idea of a vcct..or Lo describe a point. was .initially oonc:civcd frQI'" qoo-
rmtrical c:ooccpts. Gearet.ric theorG'l\S have been developed for boili perspect.1.vc
and affine g<X.metry. 'Ihe theorems of affine geaoot.ry arc identical to t.ta;c for
Euclidean geonetry . In affinQ gecmatcy parallelism is an .inp:>rtant. concept, and
the ratios beboleell parallel lines is an inte<]ral p.trt of the geatetry. Si.nec:!
Euclidean ga:t~Ctry has been taught in scrools for many years , draw.Lng and sketch-
ing techniques based upon this gearetry have bec:are standard rrethods for graph.i-
cal ccmnunication .
1\n affine t.ransfor.rration is a canb.ination of linear transfornations folla..'ed
by translation . For an affine transfonration, the last. oolum in the gcllcral
4 X 4 transformation IMtrl..X must be ro . OthenoJJ.SC 1 llS sh(l...n in Sec. 3-11 belo.t,
0
0
1
the t.ransforrred torogcneous coordinate H is not unity and there is not a one to
one oo.rrespondence bet\.-een the affine transfol:'lfatioo and the 4 x 4 matrix opera-
tor. Affi."'le t.ransfornations fonn a useful subset. of bilineAr transfornaLions,
si.rce the product of n.o affine transfo:rm3tions is also affine . This alla..-s ooe
to perform a g<?.ncral orientation of a set of points relative to an arbitrary
coordinate systan while slill maintaining a value of unit.y for the hotoqeneous
coordl.nate H.
Alt:hot.Jgh perspective views are often used by artists and architocts because
they y1.eld rroro relaistic pictures, t.hey are seldan used in t..cchn1cal work be-
caU9C of the difficulty of C'a'\Struction. HoNcver, when hcrlogencous CXX>rdinates
are used to define an object ~'ithin a mrputer, c.1.the.r affJ..ne or perspective
t.ransfOJ:T"Ut.Lcns can be obtaint::rl with equal ecu;e . In perspective gearctry no bolO
lines arc parallel. ln fact the perspecbve plane can be oonstdered "lS a hemi-
spher1cal surface and t:ha pcrspcctt\"C tran.sfornatioo considered .:lS a transforrra-
t:lon fran cne t hree BE • '"· a 11 1' r.,... ~ spa....tJ.
\>J'Cl the elerrenls 1n the lasl oolum of the general 4 x 4 transfotmltioo
11\;ltrix arc not zero, a perspective transfOLtMtion is fotned. A perspective
trcmsfoCTitltiOO is frequently associated with a projoct.ioo ooto a plane, su::h as
z = c , fran a lcx:al center of proJectiOO. 'nle catb:ination of a perspective
1
transfotl'"\ltiOO with a projectiw transformatioo is called a perspective projec-
tioo. A p:.rsp:cllve pxojectioo represents a transforrratioo fran three space to
O.Q space. I f the center of projection is located at infinity, then the perspec-
tive proJectiOO .LS Ccllled an axooc:rr-etric projection. Ot:heiwisc, the form depends
upon the locatioo of the projectioo FOint.
'nsble 3-1
Ax.onc::r.etric Proj ecti<XlS
Pro)ec:tl.on
T' = l 0 0 0
0 l 0 0
0 0 1 0
0 0 n 1
follo.,'9d by a projectioo ftu!l infinity ooto the now ~ .. 0 plane given by the
transfm:matioo
T" = l 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
'l!le concatenation of T' and T" 1 i.e. , T" T' 1 will yield the transfoz:matjoo matrix
given in F.q. (3-25). 'lhe effect of tl1e translation is to nove the z .., 0 plane
to sate other position in the object. Proje::tioo onto the z .. 0 plane then oor-
responds to projectioo onto the z ,., n plane.
Axonc::Xretric projection transfotmations onto the appropriate zero plane
always contain a ooll.ltn of zeros, \olhi.ch oorresponds to the plane of projection.
Such project.i.cns are frequently called orthografhic projectioos. They are can-
ncnly used in rrechanical drawing. Exarcples of an axcn:ttet.ric projectioo onto
the x = R. and y • m planes are given by
T' • 1 0 0 0 and T" = r1 o o o
0 0 0 0 0 l 0 0
0 0 1 0 0 0 0 0
t 0 0 l L.O m 0 l
As noted in Table 3-1 the transfomation natrix for a trilretrix a>col'lCI'I'etric
projection causes pure rotation. 'Ibis type of transformatioo \.as studied in
Sec. 3- 5. Aux.il.iary views u.c;ed in engineering drawings are tr.itnetric projec-
tia1s. An exanple of a trilretric projection of the unit cube onto the z • 0
plane after a 90° rotation al:x:>ut the x-axis is shown in Flg. 3-6.
In order to develop the oonditicns for diJretric and isaretric projections,
recal 1 that caubined rotatioos folla.;ed by pr-ojection fran infinity f orm the
basis for generating all ~tric projectioos. In particular, WI:! consider
a rotatioo about the y-ax.is, follONed by a rotation about the x-a.xis. Fran
Eqs. (3-7) and (3-6) the matrix project which gives this is
(X Y Z HI • [x y z l) cos~ 0 -sin~ 0 1 00 0
o 1 o o o oose sine o
sin'P 0 cos¢ 0 0 -sinO cosO 0
0 0 0 0 0 0 0 0
cax:atenatioo yields
>· ,
A".\" L" c·
~·
A 0 0 0 1 rl 0 0 0 = 0 0 ro ll ,. .
B 0 01 1 0 0 0 0 0 0 0 1 a•
c 0 1 0 1 0 -1 0 0 o 1 o 1 c• I
D 0 1 l 1 lo 0 0 1 0 1 0 1 o•
E 1 0 0 1 1 0 0 1 E*
F 1 0 1 1 1 1 0 1 F'*
G 1 1 0 1 1 0 0 1 ~
I l1 111 1 0 1 I• ll
Figure 3-6 ~c Projections .
00 0 ~J
By use of this transformation matrix, the unit vector on the x-axis, (l 0 0 11 ,
transfo~ to
[X Y z H) = [COSQ sin¢sinS -sin~cose 1)
and
x* = cos¢, y* = sln¢sin6, z • • -sin¢cos9
In projecting ont:D the z• • o plane, z* is effectively neglected as previously
slnm by fl:i. (3-25) with n = 0 and Eq. (3-28) . a result of this transform!l-
As
tion, the mitut1 z- axJ.S unit vector OCM has a magn~tude of
/ x*
2
+ y• 2 = ks2~ + (sin¢sin6) 2
Slrri.lar1y, the unit vector on the y-ans, (0 1 0 1], transforms to
[X Y z HJ = (0 cose sine 1)
and
x* = 0, y* = cose , z• = sin~
x* = sin¢, y* .= -cos~sine
Now we shorten the magnitude of this transfomed unit vector to a value of l/2
by setting
or
5~·
~~2~
'f'
+ {1 -
. 2 ) . 2&
Sl.Il ~ SU\ ""
1
'f
Introducing Eq. (3-27) loods to
4
8sin e - 9sin
2e + 1 =o
'l1lis equatioo has roots of sin2e • • 1/B and sin2 t • _.. 1 . 0. \'hen sine 11/8
or e = 20 . 705°, then sin¢ ::: 1(1/8)/(1- l/8) or Q .: 22.208°. 'l1le terms 1.0 tlle
transfornatioo matrix in F.q . (3-26) are thus determi.ned.
Using the values for a dilretric projectioo, the t:ra.nsforrMtion rretrix
{a:J. 3-26) is ¢ven by
(Z Y Z H) = (x y z 1) 0.925820 0.133631 -Q.353553 0
0 0.935414 0 . 353553 0
0.377964 -0 . 327321 0.866025 0
l0 0 0 1
A clinet..ric projectioo is sln-m in f'iq. 3-7.
Perhaps rrore cam at is the isoretric projectioo . '1'0 form an isaretric pro-
jectioo, all three transfomed axes are equally shortened. 'l1lis requires that
l::oth
~
X y Z
•
!. 0 0 1
l 1 0 1
1 !2 1 1
1 01 1
0 0 0 1
0 l 0 1
<
0!2 1 1
;
0 0 1 1
•
I 5 .,..
•
>"
O.S25820 0.133631 -~.353553 0 I, -
0 0.9354H 0.353553 0
I! - 0.377S64 - 0. 327321 0.866025 0
0 0 0 1
)" 0!1 l
-~
I0 -
•
... 4
0 •
OS
I
-
I <
OS -
,y·-.--==--___.. '
-4
-0 !
•
OS
·0 s D netr1c
The first oondition a9"in gives
2 . 2-
sin ¢ = sm
1- sin2 ~
. 2,.. 1 - 2sin2 ;;
Slll .,. :: ~--'-~i'--
1 - sin2A
2
It follows that sin e • 1/3, or sine • 11/3 and t- .. 35 .26439°. Then
2
sin ¢ e r¥h = !
and
oos 2 ~
= 1 - sin ~ = ~ or ~ = 45°
2
The angle lolhich the projected x-axis makes with the horizc:nt.al is given
by
t.ano = sin¢sine
cos~
This result is well knc:J..m to those wtx> have prcdnced an isaretric projectioo on
a drawing toard. A plastic right. triangle with incluOOd angles of 30° and 60°
is a cx:xutonly used tool for this purpose.
USing the angular values for an isoretrlc projection the transform:ttion
IMtri.x in Eq . ( 3-26) OOoc:mes
(X Y Z H) • (x y z 1) 0. 707107 0 .408248 -0.577353 0
0 0 . 816597 0.577345 0
0. 707107 -0 .408249 0 . 577353 0
0 0 0 1
An exanp1e of an isaretric projectioo is also sh:Mn in Fig. 3-7.
Cblique projections such as cavalier and cabi."''et do not preserve ort:hcx:Jon-
ality of the coordinate system. The characteristics of these O.;o are shown in
Table 3-2 . Since they are not frequently used in technical '-()rk they axe not
di.scussed f\lr"ther.
A si.JTple orthograiiUc projection onto a zero plane perpendl.cular to any
of the three ortrogonal axes .results when the corresponding co1llm in the 4 x 4
transfo.mation natrix contains all zeros. For exanp1e, a proJection onto the
~ = 0 plal1e will resull when the follOWl.llg JMtnx ~s used .
T = 1 0 0 0 (3-29)
0 1 0 0
0 0 0 0
0 0 0 l
66 MT>.'Il01l\TICAL £IDn.1I'S FOR <X:NPllu:R GlW'HICS
Table 3-2
Cblique PrOject..ials
X X
( 3-30)
x*=H=rz+l
Y" = yH = rz
___.Y~-,-.,...
+ l
'lhc C]"...oretrical eff~ of this transfonnation can b.! indicated with the aid
'm:REE-DlNF.NSiaw... 'rRA.~FUif.WI'IGNS A.~ Pinli:L"l'I<M3 67
I
of Fig. 3-8 . The nontransfor:trod p:>int
P is transform..'>d to P* by the aoove
operatial, WJ.t:h r • 1/k. In Fig. 3-8
the center of projectia'l is located
at [0 0 - k ) dnd Lhe plane of projec-
tial is z "" 0. Smoe the above ope.r-
atial prodtrcs no translatial, the
origin is unchanged and U1C xy- and
x*y*-coordinatcs share thO sane
origin. By using the similar t.ri-
angles shc7...n in Pig. 3-8 it foll(1.o1S
that
x• X
k • {z + k)
or
X
•
xe
z +1
1<
Considermg the yz-plane in a similar
rrrumer gives ( r OJCCIII'n
C'crllcr ul
rx * Y* 2 * 1) -
-
{ X y Z
rz+lrz+lrz+l 1] (3- 33)
~
Similarly the perspective trans-
·t , fooration
Cen 1cr t )f
p• QJC:CI•on
= (X y Z (px + 1))
with ordinatey coord:i.nates
rx* y* z• 1) -- Ipx+lpx+lpx+l
x Y z 11 (3-37)
will result in a vanishin:] point located oo the x - axis at (1/p 0 0 1). '1lle
transfoonatioos given in E>qs. (r32), (3-34), and (r36) are called single-point
or parallel perspccti ve transforrraticns . '!bey result in views such as sho.m in
Fig. 3-10a. Fic;ure 3-loa shows a single-point perspective of a unit C\t)e
pxojected onto the z • 0 plane. 'nle vanishing point ~ on the z-axis at z • -10.
A rore natural single-point pe.rSfECtive can be obtained by first centering the
face OCFG with respect to the z-axis . That .is, translate the eight corners of
the unit cube by X "" -0 . 5 and y = -0 . 5 before awlying the perspective opera-
tion. '11-.e resulting view is sham in Fig. 3-lOb. '1bis centered, single-point
perspective i s the type that artists often use. It can, hc:7,..1ever , give a dis-
torted vi&t of the depth of the object i f the vanishing point is noved too far
away fran the center of the picture. This is what causes the "unnatural• view
in Fig. 3- loa .
Lf b;o terms in the 4 x 1 colum nBtrix are nonzero, then a two-point or
angular perspective is obtain~ . 'Ihe o.o-p:>int perspective transfotm!ltion
[X Y z 1) = (x y z 1] 1 0 0 p a [x y z (px + qy + 1)] (3-38)
0 1 0 q
0 0 1 0
0 0 0 1
with ordl.naty coordinates
results in two vanishing points : one on the x-axis at [1/p 0 0 1) arxl ooe on
the y-axis at (0 1/q 0 1). This is shc7.n'l in Fig. 3-lla, where the results are
)' >" t lo \1 PI on ) • 111.1\
I .11 } 10
I
l ·.o· G" •
-ToVP1 on A·B l< l \
IIJ. 10
(
(j
E ..... ,..
ll A" s· E"F"
~
Po5it.iat tl.VI? and Folo.iuon
Vectors Projecticn Vectors o! Nolll\1 II zed l'crii-
F o f o ng- Tr.lnsfOYt:D- 'rransforrred u oo Vectors o f
1na.l Clile t ion Mat.."'U! Cube Trons fo l'l"f'd C\.bP
A 0 0 0 1 1 0 0 0.1 "" 0 0 0 1 A• 0 0 0 l .. ,
B 0 0 1 1 0 1 0 0.1 0 0 0 1 a• 0 0 0 1 s•
c 0 1 1 1 0 0 0 0 0 1 0 1.1 c• 0 0.91 0 1 c-
D 0 1 01 0 0 0 l 0 1 0 1.1 o• 0 0.91 0 1 o•
E 1 0 0 1 1001.1 t• 0.91 0 0 l e-
F 1 0 1 1 1 0 0 1.1 p• 0.91 0 0 l f"'
G 1 1 1 1 1 1 0 1. 2 c• 0.83 0.83 0 1 c•
I 1 1 0 1 1 l 0 1. 2 r• 0.83 0.83 0 1 t•
).
c·.o· G".l"
A
-- X
-· ~
l
-
•
'-
A. n·
I I ·.I •
Pcrspec-
Positlon t1ve Md
Vectors Projoctlat Pos.1.tion \'ectors lbtm1lized Pos1.tion
of orig1- Tr.vuofor'IT'dt.iat TransfoDM- o f Tr&ns!or:rood voctort. o r Trans-
na1 CUbe !'latrix tion ,.latrJ.X CIJbe fO,!t'IOd CUbo
0
11. 0 0 1 1 0 0 0 1 0 0 0. 1 = -o.s -o.s 0 1 A• = -o.s 0-0.5 1 A•
8 0 0 1 1 0 1 0 0 0 1 0 0.1 -o. 5 -{). 5 0 1 a• -o.s .-o.s 0 1. ~
F 1 0 11 1001 F"' 1 0 0 1 p
G 1 1 1 1 1 1 o 1.1 c• 0. 91 0. 91 0 1 G•
I 1 1 0 1 l 1 0 1. 2 P · 0. 83 0 .83 0 1 1•
u,. .,
l
I
•
Figure 3-12 Three-point perspcctJ.ves .
•
Papel
VP
- - - - - - - - - -Hor11on- -
1- yc lc\C I
-
St.liHIO po1nl
-- -
- •
(
,.
\p - -~
<::-::>
-- - -
~
-
' --- - -- -- ~
-
- --
- - ------
-- -- --
Hot ron \ P
--·
, _.-
--- n
-
u ------ -- ----
- - - -..:::--..,.. \P
-:::- -
~---------
---
TP .
\-E will roN rotate the urut cube about the y-ax.is and translate l.t to the
point [0 m n]. 'l11e resulting figure ~;.'ill then be viewed fran a P'Sition k on
the z-axis and finally projected onto the z = 0 pl.aoo. Uswg Eqs. (3-7), (3-11),
and (3- 29) with r = 1/k yields
cos~;
0
o -sine o
1 0 0
1 0 0 01
0 1 0 0
- ,.cose 0 0 -sre
Is:~
1 0 0
sine 0 cos6 0
0 0 0 1 cosO
0 m n 1 k 0 0
k
0 0 0 1
L0 mO n + 1
k
Since projection 01to the plane z = 0 was desinld, the third oolum of t..'Lis
ll'atrix is all zeros. NOtice that t\Oo of the t hree terms in the fourth col 1.1m
which oontrol perspective in the matrix are nonzero. 'Ihus a t'..\'rpoint perspec-
tive view will result.
'!be eight vertiocs of the unit cube, expressed in honogeneous coordinates,
can be represented as an 8 x 4 matrix . r-hltiplication of t..l)is rratrix with the
above transf0%l'll4tioo rMtrix produces the required transformation on oach point. '
'Illis l.S given by
0 0 0 11 fros6 0 0
0 0 1 1
0 1 0
k
•
-suw ..
0
~
- 0
.
m 0 !!.+1
k
cosO + !!. + 1
S.ln;. m 0
0 1 1 1
cos k k
•
Sl.n 0 0
0 1 0 1 k sin'" 1+m0 coso + !!. + l
k k
~+
1 0 0 1 0 mO 1J
1 0 1 1 0 1 + m 0 !!.+1
k
1 1 l 1
cose m 0 -sinG + n +1
1 1 0 lj k k
cose +sine m 0 -sine + oosO + n + 1
k k: K'
oose + sinS 1 + mo -sr-e + J<0 .. ~+1
oose 1 + m0 -sre f + + l
[X"' •'*
I
1] - H !B
[! ll
0.344 -0.4
0 -0.5
0 .44 -1.75
0. 83 -1.22
0. 83 -{).61 •
0.44 -{).88
'Ire transfotned cube is shown in Fiq. 3-15 . Cl:lserve what has happened to
the parallel sides of the cube. Lines which were initially parallel to the x-
0 and z-axes respectively intersect at ooe of the two vanishing points. 'lbe
nc:1n'
... intersections of the initial parallel lines occured at infinity. '!hey now occur
at finite values along the x•-axis. <:nly lines iniHally parallel to the y-axis
remain parallel after the t:ransfor:natioo.
Following sim.U.ar logic, a three-point perspective can be created and
vie..-ed fran a position k on the z-axis by first performing rotatioo.s about two
y
Vfl l VP1
_.-~I
....-- // I
_, /" " I I
-'/ I
/(
I
I e .. 60°
I m • -2
I
I
n • 1
k. 1
0
I
0
0 0
.... .....
.,..
•Ulll 0 oI 00
0 000 I
1
[
0 .,.. 0 r•~
l
lan.l 0 0 L 0 0
DOC! I all.I! - ·11"1 c ~._..-
ic of harOgenCOUS ooordin-
atcs , we again consider the transfometim of a l.1ne parallel to the z-axis onto
the x*z*-plane. The line AB is shown in Fig. 3-9 . Applying a perspective trans-
forrratim rratrix to a general FOint m the line gives
78 t-~TIID·~TICAL EI~ FOR OJMPOI'ER GRi\PHICS
(X Y Z H)= (x y Z 1] rl 0 0 0 = [X y Z (f + 1))
0 1 0 0
0 0 l !..
k
0 0 0 1
(x+ y- z* 11 =
[
X
c; + 1> ~+
y
1)
z
(~ + l)
1]
This operation (\o.~th k = l/4) transforms the initial 1~ AB to the line A*B*
shown in f'ig. 3-9 . A*B* lies oo a line which passes through a vanishing point
at (0 0 k). ~hen the Z-<:OC>rdinate is neglected, the line A'*B* is projected onto
the pl.:me :z• • 0, as shc:Ml by line A' B' . The oot result is a projection from
the line AB onto the plane z* = 0, fran a center of projection at (0 0 -k).
Notice the symret.ry of the vanishing point and the center o f projection.
An algorithm which will genexate a general perspective vie..~ is given in
l\ppendix c.
T'41 T'42T'43T'44
l1lO rosults can be pro)ectcd ooto a t::wo-diJrensiona1 plane, say, z "" 0 by using
e":l• (.3-28) I i.e . I
T" ::. 1 0 0 0 (3-28}
0 1 0 0
0 0 0 0
0 0 0 1
OJnc:atenatioo of the 0.0 matrices yields
T = T,.T' = Til T 0 T
12 14 (3-43)
= [x* y* 0 1) (3-45)
Note that x* and y" are the coordinates in the perspective projeet.ioo onto the
z • 0 plane. 'nle same procedure could be accutplished using proJecticns erato
the x = 0 or y : 0 planes .
Writi.ng oul F.q. (3-45) yields
T x + T2ly + T31z + T41 = Hx* {3-46a)
11
(3-46b)
T x + T y + T z + T44 ~ H (3-46c)
14 24 34
using H from fl:J. (J-46c) and substituting yields
(Tll - T x*)x + (T2l - T x*)y + (TJl - T34x•)z + (T41 - T44 x*)
14 24
=0 (3-47a)
wher& tt.o superscripts l and 2 illdicate the first and second perspective pro-
JectiOO view'S. Note that the transfor.mations ~ and ~ need not be the sarre.
These oqucttions rr.ay be rewritten .in matrix form as
•
[AI (X] .,. (B] (3-48)
~.ere
~4X* ~2
1
~4Y* ~2
1
-t-12 - - - ~4y.l
~11 - ~4x* ~21 - ~4x* ~1
2 2
~4x«
2
-
~u - ~4y* ~22
2
~4y* ~2
2
~4y*
2
- -
(X) T : [X y Z )
Since Eqs. (3-50) are tx:m:>geneous, they will contain an m1n.tra.ry scale factor .
~ T 1"1\:ly, for ex.arrp1e, be defined as unity and the resulting lransfo.rma-
44
tl.oo norruUzcd. ·nus reduces the rcq..Uroncnt to 11 equations or 5 1/2 points .
If the transfornatioo lS nornalized, t.~ the last COlUITI'l in (A I I is 11'0\ied to
the right-hand suie arrl the us Jratr ix equatioo lS solved.
AS a specific ex.anple, cx::nsider the unit cube with the six Jcno..m corner
pomts 1.n the physical plane q1.ven by
IPl = ro 0 01
0 0 1
lo 1 1
10 1 0
l 0 0
l
1 0 l.J
thc corresponilinq points in the transfonrod vifM are q1.vcn by
(P*] • 0 -1
o.J44 -o.8
0.344 -0.4
o -o.5
0.44 -1.75
0. 83 -1.22
fXiUation (3-48) then becares
0 0 0 0 0 0 0 0 0 1 0 0 Tu - 0
0 0 0 0 0 0 0 0 0 0 1 0 T12
0 0 0 0 0 0 l 0 0 l 0 1 Tl4
0 0 0 0 0 0 0 1 0 0 1 0 T2l
0 0 0 1 0 -0. 344 1 0 -o . 344 1 0 0.344 T22
0 0 0 0 l 0. 4 0 1 0. 4 0 1 -0.4 T24
0 0 0 1 0 0 0 0 0 1 0 0 T31
0 0 0 0 1 0.5 0 0 0 0 1 -o.s T32
1 0 -o. 44 0 0 0 0 0 0 1 0 0 .44 T34
0 1 1.75 0 0 0 0 0 0 0 1 -1.75 T41
1 0 -o. 83 0 0 0 1 0 -o . 83 1 0 0 . 83 T42
0 1 1.22 0 0 0 0 1 1.22 0 1 -1. 22 T44
SOlut.ia'l yields
[T) = 0. 867
0
-o.s
0
1
0
0. 5
0
0.867
0
-2
2
can be designed and attached directly to the cntputer controlled output device.
For a hunan with average eyesight, the strongest stereo effect occurs at
a d.ist.ance of about 50 en in fralt of the eyes. Thus, for an eye separaticn of
I Ph..). /}
I
It
ll.
Plane or
P rOJCC: I ion
'Ihis creates two separate pers pective vie-'S , one for the left eye and o ne f or
the right eye. At this int:e..orediate step the left-eye view is to tho r i ght o f
the ori gin, and the right-eye v i ew is to the left, as 50CMn in Fig . 3-18.
Le fl c ~ c: \le~
I
----_.. ,..
--~ -·
c~·~.L~----- o - - - - - --ci•l
-
l.tl l C:}( v
F
create the t:\10 perspectives and a final translation matrix to generate the
required eye separatioo distance.
An exarrple of a stereo view of a siJTple ional wire frcwne
generat ed using the STERFX> subprogram of Apperxhx c is sho.m 1.n rig. 3-19. The
positioo vectors describing the wire fra:re are
0 0 0
1 0 0
1 0 1
111
0 1 1
0 1 2
0 0 2
-1 0 2
-1 0 0
-1 1 0
0 1 0
Prior to cal ling the S'l'ERID subprogram, this daUl was first translated by usi.ng
Sli:lprogrcm J[YJ'RII.~ (Appendix c, Sec. c-10), with £ • -0.5, m = -1.5, and
n = -o.s. 'lhen a 20° roUltion about the y-ax.is was per!orned in preparation
for a b.o-point perspective. The stbprogram 3DYOOI' (1\ppcnd.ix C, Sec. C- 7) was
u9:!rl for this operation. At this p:>i.nt a catpJter search sho..>ed that the
maxinun z-value was 1.9226 . Then 3m'RA.~ was used a<3<1in with 1 = 0, m = 0 and
n = - 1.9226 to place the object behind the x*y*-plane. At this p:>int STEREX>
(Appendix C, Sec . C-17 ) was call ed, using k • 4 and E .. 2. 'lhis resulted in
the stereo pair slxJwn in rig . 3-19. However, a final overall scaling ~-as
a pplied to prcxluce Fig . 3- 19 .in order to fit the output to a particular storuge
t ube cro'.
REFERENCES
•
4-2 tb~PAAAVETRIC URvES
.-..
correct root of an algebral.c equation. '!he detem.ir.aticn of roots of inplicit
curves satctiJres requires le."l~· calculations .
Both eJ<plicit an:i iltpllcit nonpa.."'"ar'etric curves are axis-dependent. 'n'lus,
the choice of the coordinate systen can affect the ease of USl.nCJ the curves and
calculating their properties . In spite of tl-.ese li!r.itations, nonparametric
curves have been 115M with success (cf Refs . 4- 1 and 4- 2) . Silrple s.:ca'ld- and
thlrd-degrec cqwtions provide a wide vnriety of curve forms.
Fl:an a rotharatical p::>i.nt of view, t:r.e problem of defining a curve frau a
la'o..n set of data p::>i.nts l.S cne of interp:>lation. 'lbe c:u.rw can be made to pass
tl'lrough all Jcnc:Mn t:0i:1ts by use of ?Jlyncnial i.nterp::>lation. 'lhis requires
~ter:'ilining the coefficients in the ll'Btheratical equaticn for a ?Jlynanial of
SOI'e ~ee. ~ actual shape be~-en t:.he data p::>ints dept!nds lplt'l the order
o! th:: p::>lyroniaJ and the Ntheratical t:oundary cxmd1t1.ons "'hlch are applied.
:. the other hand, i f ~ data p::>ints are only approxit!ati.o:".s to sare
unknown "true" ~ues, then a curve is required which indicates tht: correct.
trend of the datu. L"l general tlU.s curve l'l'c'lY pass t:hrou:jh ally a few data
FOint:s an:!, in fact , may not pass t:hrough .lilY of the data FO.i.nt.s. 'Ihis
PU\t.:F. OlRVES 91
requirmcnt exists when <:1 curve is needed to fit (intc.rpolat.e) data obtained
fran exper~tal rroasu:rarent.s or other observed data. This curve ht. glVes
est:imaled values over the r<UlCJC of observaticn.
\\hen the data points inherently conbin unc::ertainb,..s, the rrethod of least
squaros a.Ff>r<»UJT'dtion is a cx:mronly used curve fitting (or c:llJ:'W fairing)
technique. 'this technique prod\IO:lS a curve fit of pr~ fonn y c f' (x)
~ch minimizes the sun of squared y-deviations bcb.t.>en the observed and
estimated values. '!he pn;scrib...~ fonn ~ usually b.:tscd oo a Jcro,.rlcdgo of tho
{:tlysical ~n whl.ch produced the data.
CCmronl.y prcscribe:J e><plicit, nonp.;u-curettic forms used in the least squares
technique are fOI-& functions , ~~tial functions, and polyrx:mials . l\ fX"""Cr
function might be prescnbacl as y = axb and c'lJl eJqX>nential fonn as y ,. aabx,
\\ilere a and b are constants. l\ general p:>lynam.al has the fonn y = '1 -+ C'r +
c-r2 + •.• + crml,f. ReqardltSs of the presc:riOOd C\..II'V\! fonn, the least squares
techm.que requires solv1.ng a sel of sinultaneous, linear algtiliraic equations in
order to determine the I.ITlkzv..m constants in the prcscr1lxx! equation.
Z.bst mrp.1ter facilities have library programs for least squ,...rc curvo
fitting . Reference 4-3 oontaUlS a "'ell docunent..ed BASIC alC]Orittrn which irrple-
rrents this technique. For t.ha r~ of this chapter~ consider plane
curves which pass through the spccl..fied data points.
A general secord-deqree, urpll.c1.t equatloo .lS "''ritten as
2 2
ax + 2bxy + cy + 2cy + f =0 (4-3)
If the curve is defined rc.J.ativc to a lOC2l coordinate system through which the
curve passes, then f ... 0. By c.Wfi.Jung the oonstar.t coefficients a, b, c , d , e,
and f , several types of plane curves can re produced. Hound'lry oonditions arc
used to establish a particular curve through specific pomts , as shown below.
rf we now choose c =- 1. 0 m t:h.o genPral equation, then to dcf inu a cu.rve
~t bcb.leen l:w:) [X>ints , hve independent oond.itions rust bP specified to
determine the values of the remaining five coefhcients. one choice is to
specify the position of the 0..0 end points, the slope of the. curve segrrEnt at
each end point, and nn i.nt.e.rn:;odiate point t..hrough wtuch the curve ITUSL pass .
If, instoad , \,~ specify b =0 nnd c == l.O, then the rmalytlcal ~scription
of ti'C resulting curve is fi..xcrl by specify.iJlg only four additional oonditions,
su:::h as the boo end points and the u..o end slop.>S. An even s.wpler curve can
be defined t7j first sct.:ting a • 1.0, b • 0 , and c 1.0. 'Then t:.hc fonr of the
curve is given by
2
x +/ + 2t1x + 2ey + f = 0 (4-4)
'1lle three. ex>nd.it1.0ns rcqu1rro to flx d, e , and f can be the 1:'-0 em po1.nts and
e.1.thcr the slop.. at the bcqi.nning or the sJ.or;c at the end of the curve: ~~t .
1\oot.her chou:e is to specify the t...o end IX>ints and a third internal rx:>int
through \o.hich the curve nust pass.
A ~ght line is obtained by setting a • b = c "" 0 . ~ the equatioo
is
dx+ey+f .. O (4-5)
•
or
y • -(~)X - ~= 11'0( + b (4-6)
where rn is the slope of the straight line. 'Ihe values of m and b are fixed by
spec1fyi.ng the t:'-0 end points of the line.
create an inflection point in the curve ~t , it is necessary to use
'lb
a hiqher order curve such as a cubic. 'llris curve form·can be expressed by
3
a + bx + cc 2 + dx - y ... 0 (4-7)
Specifying the t:'-0 end rx>ints and the slopes at these two p.:>ints fixes the
The positioo vector for a point oo the curve is then a single ro.1 matrix given
by
P(t) = [f(t) g(t) J (4-9)
If required, the nonparasretric fmm can be obtained f:tun the pararretric form by
eliminating t:.re paraooter fxan Fq. (4-8) to obtain one equatioo in terms of x
and y.
In a<k:tit1on to sinple curves, the paramet.rlc form is suitable for
PlANE OJRIJES 93
Where t • tanS/2 . This choice requireS very little cx:Jil'lltation t.ine , but it is
a oatp:anise si.J·x:e the arc lengths are not exactly equal .
~, consider the problan of determining the value of y \>~hen the value of
x is known. As an ex.anpl.e assure that x • 0. 5 and that it is required to deter-
r:u.Ite y a1 a unit circle. For the explicit representatioo this is straightfor-
ward:
1 - X l/2 1
t • <t + x> = /'1 = 0. 57735
and thus
y =
2
~~ = 4 = 0 . 866
For rrore <Xlitpllcated pararretric representations an iterative seaxdl technique
rray be 11ore convenient to firrl the unla'loNn values of an e><plicit variable.
PLANE OJRJES 95
,
/
d
( 11 de
All the c:ooic sections can be described by the general i.rrpl.icit sec:::oro-
degree curve
2
a ' - acos a + bcosasinet + csin2a.
2
c' = asin2a - bswcosa + ect:JS a
d ' = dcosct + esino
e' • -ds:i.na + eoosa
f' = f
and
cot(2a ) .. a - c
b (4-16)
Alternately i f the curve exists such that cne of the refereooe ~ is an
axis o f symretry, then iL can be rotated through any angle a to a new on.en-
tatial. If the coefficients a', c ', d' , e ', and f' are known far the original
axis of symtetry orientation , then the coefficients a, b, c, d, e, and f o(
Eq. (~-14) in the rcw orientation are
2 2
a = a'cos a + c ' s1n c
b = 2 (c ' - a' )cos~in,) (4-17)
• 2
c = a I s1n o ... c 1 cos2o
d :: d 'coso. + e ' siro •
e :o e'coso. - d 'sino
-.
f - ...
Equatl.On (4-14) em then bo used to generate the requued curve.
'Ihe character of ~
conic dcscritwi by Eq. (4-14) is an ellipse, a para-
oola, or o hyperbola, de~~ing on t.l)e value of the di.$:r.i.minatc b - 4ac
2
2
a parabola if b - 4ac =0
..
c an el11p5e or a circle if b 2 - 4ac < 0
Considen.."lg Eq. (4-15), a CJ.rcle occurs if a' = c ' . '1l'le equation of the
•
cuclc with ce."lter at n, k and radius r is given by
2 2
(x ' - h) T (y' - k) ~ r2 (4-18)
h = ~·
2a'
~·
k = 2a'
r• r ~O
4a' 2
If r = 0 , the circle degenerates to a point .
A parabola occurs if a ' :; 0 and c ' = 0. \\'.ri t ten in the camon fox m the
equatlal of the parabola is
2
(X ' - h) • 4p (y ' - k) (4-19)
h:: - d'
-
2
e'
p=-
4
the roles of x ' and y' are interchanged, the x'-axis will oo the axis of
S}'ll"l'l'et.ry. If p > 0, the parabola will open up or to the right; if p < 0, .1t
will open do..n or to the left.
An ellipse occurs when neither a' nor c' in Eq. (4-15) is zero and both a '
and c I 'nu.ve
- -' the sane S.lgn,
• •
.l.e. . ...___ I 1 > 0. 'Ihe equatioo of the ellipse with
1 wucu a c
-d'
h = 28'
-e '
k"" p
(l2 = ~
a
e2. ~
c
g = -f' c;ao
\~ g = o, a point results. '!be eccentricity of the ellipse £ is
£- I Q2 - B2 < 1
a
A hyperbola is generated by Eq. (4-15) when neither a' oor c' is zero and
both have opposite signs , i.e., when a'c ' < 0 . 'llle equat.ioo of the hyperbola
with center at (h, k) is then
(x ' - h) 2 (y ' - k) 2
cl - - 82 ~1 (4-2la)
or
2
(y' - k} - (x' - h) 2 - l
(4-2lb)
(l2 B2 -
d' 2 e'
g = - f' + 4a • + 4c Cf?-O
If g - 0, the hyperbola degenerates into a pajr of intersecting straight lines.
NoW that in the case of a hypertx>la the d.irect..i.on of opening is determined by
the signs of a ' and c' in ccnstrast to an ellipse , \oo'here the orientatioo is
cootrollro by the relative signs of a ' and c '. 'lhe eccentricity o f the hype.r-
tx>la is given by
•
4-5 fb.wARAt-ETR IC CIRCUlAR AA.cs •
Hany of the early techniques for curve definition were based on the use of
nonparrumtric cx:nic sections. As long as relatively short curve segrrents ~
x
2
i
+ dx + ey + f = 0
+
where \..e have drop{led the prines for coownienoe. Evaluating this equatioo
clt the three points yields
2+d+o+f""'O
8+2d+2e+f=O
l3+3d+2e+f=O
Solving these three equations for the three unknowns gives d • -5 , e • -1,
and f • 4. Thus, the equation for the ciro1l ar arc through the throe given
points is
2
X + y 2 - Sx - y + 4 = 0; 1 :S_ x ~ 3
The omter of the ciroJl ar arc is located at x • h = ~2a = 5/2 and y • k =
e/2a - 1/2. Using Eq. (4-18) the radius is r = I!0/2 "' 1.5811. Differen-
tiation of Eq. (4-18) yields
2xdy+2ydy-Sdy•O
r
~ - 5- 2x
dx - <2Y - 1)
I t follows that dy/dx • 0 when x .. 5/2 and dy/d.x - a. when y = l/2. However ,
oote that this infinite slope docs not occur within the arc ~ent oo~
[11] and [3 2].
When a1e creates curves for use in <XIIplt.er graiilics , c:onsldcration ru;t
be given to how the user will define the curve. For exlUTple, u . may be ~sctry
t.O create a circular arc ,,n.th a specified radius ~ ~ end poUlts, rather
than passing through three specified LX>ints as in the preVicus ex..:mple.
2
d + e 2 - 4af
25 ;; 2
4a
'Ihe solut1on to the a}:x)ve eqwUons l.S nnre difficult due to the non.l.inear
terms in the third equation. An .tterative techni~ l11.lSt oo used. By trial
and error, it can be sh:::Jwn that an approximate solution to the above set of
equations is
d - -8. 4
e = 5.7
f = o. 7
for a = c = l.O
Thus, the center of the cucular arc which r:rects the .irrposed oonditJ.ons oocurs
at x = 4.2 and y - -2.85. 'lhe arc no 1onqer passes through the int:.ermed.iate
LX>int (2 2].
on the other ha.rd, it may be necessary to oontrol the slope of the c..L.r-
cular arc at the initial and/or final powts. 'lhls can be done by choosing an
alternate set of caditicns.
at x; 1, ~~ "" 1
dx y. 1
at x = 3, ~; 0 •
x
2
+l - 6x + 2y + 2 = 01 1 ~x .S.. 3
Not1oe that x "' 3, y ~ (-2 ~ 132>/2 = 1.828; i.e . , the final point is [3 1.828) .
If the final point an a circular arc truSt be spectiied, then only cne end
slope can be specified in additioo to two end points. For e.xanple , to produce
a fillet between two straight lines, one might specify the initial point, the
• final {Xlint, and the final slope.
y' = -
e' ! k•2 -2 4(x• 2 + d ' x ' )
and the second form is
fl.gure 4-3 Translated coordinate
system for a circl e x ' .. _ d ' · ,4•2 - 4 (y '
2
+ e ' y')
2
In these fams calculations such as an area given by /y ' dx' or intersect:.i.ats
of the cucle with the ll.ne y ' a ltD(' + b can be rrade using rrat:henattcal tec::h-
ru.qucs.
As an exanplo of the generation of a na1paranetric conic sectioo, an al-
• gorit.~ far generat.ing a m1iplete circle nonpararretrica1 ly is given in Appendix
c. 'Ihe ba.sic oonoept behind the algorit:lJn is that near the x....axis equal
incrcm:mts in t.y are used. '111us, between y =0 and y = .t r 12 equal increments
!JX are used, and between x ... t r 12 and x == 0 equal 1.nc:rercnts in t:.y are used .
This algOrithm allows only multiples of eight f.Oints . Further , to avoid prcbl ems
with the square root of negative nurrbers , the absolute val ue of the square root
ar~t is used . 'lhc algorithn is carplicated and inefficicnt. An exanple
of a full circle generated. with this algoritl'ln is shown in Fig . 4-4. It gen-
erates reasonable circular se<;Jrel1ts in the middle third of each quadrant , but
very cnrle segrrcnts elsewhere. t-bre points can be nsed to i.nprove the result.
If a sttt:X)th gra}:hical output is the prirre consideration, the pararrotric repre-
sentation subsequently discussed in Sec. 4-7 is rec:anronded.
using the double-angle f orrrulas allows Eqs . (11-24 ) and (4- 25) to be rewritten as
xn+l = x 0 oosde - y0 sinde (4-26)
Fran the results £or the circle ,.~ note thAt a fi.Xl:'d n~ of points pro-
Vlded a tp:)d representation of the circle w1len <XX'U'lCCt.ed by short straight vector
\<r'ith a circle, the distributi.a\ of that fixed nurber of points 1.S obvicus -
equal-angle increments. Jb..~ve.r, for an ellipse, i f equal angle increm:mts
are ns«'' to calculate the display points, an unacceptable rosul t will be obta:ineC
'lhis ls particularly true for el 1ipses with high eccentricities (E: = 1) , as stn.1r
m Fig. 4-6. Here we see that the ends are not lldequately represented. 'lhl.s is
because ncar the ends of the ellipse the curvature is too large to be representee
by a f(!.N points.
An alternate rrothod might be to use equal perirretcr lengths . For a suffi-
.. •, cjent. n\.J!li:)cr of lengths this ~d give a better representation. Ha.--eve.r, the
ell1p5e would be overspecified a.l.ong the sides, "nere the curvature is stall,
with a resultant waste of cxxtputer t:ine. Further, as pointed out in Fe!. 4-5,
deten'ninatioo of the equal per.im::ter l engths involves calculation of an elliptl.c
\
I
/
/
e is near 0 or n, 1.. e ., near the ends, \ole have ldxl ;. 0 and jdyl • bde~ and ~
e is near Tf/2 or 311/2 , i.e . aloog the sides , jdxj .: ad6 and =
jdyj o. 'nlus,
near the ends ~ have mre p:>ints and alOJYi1 the sides fe~~~er (Xlll\ts. In fact
the ratio of the peri.Jreter l.ncrerre'lt size at the ends to that a lon<J the sides
is approx:irrotely b/a. Further, note that in the case of a circle where b = a
the optinun representaticn also results ,
i.e., equal peri.rreter or equal angle in-
•• crements •
)
Since equal l.OCrcrrents in the para-
meter e, i.e., a fixed nurber of points,
is to be used , an efficient algorithm can
be developed by again using the double-
l = 4ax (4-40)
A parat~Ct.ric representation of F.q. (4-40) is
x = tan2e (4-41)
y = • 2/itAniJ (4-42)
'
P~ CURVES 107
X= a62 (4-43)
Y 2ae (4-44)
~'here 0 ,S_ e s_ CD 'Ihe parabola, ~Vcr 1 unlike
5"'-eeps OUt the entire parabola.
the ellipse, i.s not a closed curve. Thus, the arrount of the parabola to be
displayed must be limited by ch:losing a nruci.murn value for a • emax. '!his can be
done in a variety of ways; e.g., the range of the x-cootdinato c:ou.ld be l..uru.ted.
If this is done then
e
max
=/~
a (4-45)
If the range of tha y-c:oordinate is limit.ol, then
Yrrex
emax; 2a (4-46)
Once emax is established, an algorithm to calculate N rcpresentatl.ve points for
the parabola in the fl..rst. quadrant can be de~loped. Once the parabola is obtair
ed m t:re fl.I'St quadrant, the rest of the parabola Wich appears in the fourth
)
•
f ocu~
•
I
~ 1 ~ aen2 + 2a9nd~ + a(de)
2
~1 = ~ + y0 da + a(d9)
2 (4-47)
-
0 -< t < 1.0
Here the paraxreter is t, and the t:'NO end points of the paral:x:>la are P = (Px PYJ
arx:l Q • (~ ~~. The pomt R • 11\c \-)
is the point of lntersectlOn of the t..o
end ta.'1getlts. ~ call this rethod the vertex definitjon of a paral::ola , since
use of t.hrcc vertices P, Q, R defi:~es t.~ paral::ola as s.l-o.n ln Fig . 4- 11. A
rrore general method o=
defining a C"..!n't! by use of vertices of an CJFetl £01)'901"1
was developed by Bezier and is d.lsc.lSsed iT t:he nex-c chapter.
Pll\NE ClJRVES 109
;. - ~cl
a b
which inplies that the vertex is at a
and the asynptotic slopes are th/a. A
parametric representatia'l is given by
x "' tasece (4-49)
where 0
y • fbtane
s e ~ n/2 yields the desired
(4- 50)
,,
't R ( R~ Ryl
'b+-1 • !asec
(e + d e) = ..- bOOseab/_cose
- btaneswe Figure 4-ll Vertex definition of
a parametric parabola
and
btan" + btarrl6
~·n+l c ~ btan (5 + d 6) = t l - tan6tand"
(4-52)
b(y + btand>-) •
Yn+l D + r--~"'---::::-:---....,--
- b - yntand6
•
' 'nlese allow wrib.ng tqs. (4-53) and (4-54) as
~
1 = a(cosh6coshd6 + sinh'-sinhd6)
or
~l = x0 coshd• + ~ y0 sinhdt1 (4-55)
•
yn+l = ~ x0 sinhdfl + y0 coshd6 (4-56)
1\swas the case for the paralx>la, the trax.iJtun value of e = enax nust be set in
order to limit the extent of the hyperoola. I f we coosidcr the branch of the
hyperoola in the first and fourth quadrants and wish to plot the portion of the
hyperbola for a .S. x ~ a + c, then
e =cosh-l f-+c)
max a (4-57)
SWlarly other l.ilnits can be det.e.rlnlnErl. 'Ihe Algorit:J"'TT ~2 given in Appendix
C uses F.qs. (4-55) and (4-56) . Since nost cx:r:puter systems do rot have hyper-
OOlJ.c nn:tions, the cxpone..'ltial relatl.ons haw been used, i.e. ,
d6 -dj:j
coshd6- e + e
- 2
dtl -dr•
sll\hdB = e - e
2
and ths .:..nverse hypc:rbolic cosine has been .,..Titten as
PLANE aJRVES 111
it is.
COO.sider three arbitracy points P , P , P in the x,y,-cx:xm::hl'lilt~ sysl811,
1 2 3
as shown in Fig . 4-13. 'l1le general , na1pararretric equatl(Xl for the circle
t:hrou;}h these points is
2
(x - h) + (y - k) 2 ... r 2 (4-58)
Since P , P , P IJ'ay be an~e in the xy-plane, direct substitution into
1 2 3
Eq . (4-58) rMY yield cxtrernely large rn.nbers . 'Ihis ''"Ould rna.'<e solution of the
resulting equations difficult. \'E! therefore translate the origin of the coordi-
nate syste:n to the first point P • As we shall see, this will also make the
1
,,
~
•
. l
I'
I
l
0
0
-
' \.
These are ttNo linear cquatJ.oos in the tw:> l.ll'lknc1wns h' and k ' \ohlich
be solved CdR
directly. 'llle radius r can Ulen be det&mi.ned fran the first equation r 2 =
2 2
h' + k' . '1hc locaLion of tl1c OUltcr of the circle and its rOOius ar,- I"'CMi kno..n.
To draw the arc of the circle, we first translate diroctly to the center
of the circl e, i.e., to h ', k ' or h, k , as si10n'n in Fig . 4-13. Hith
-1 yl* -1 y3*
e1 = tan
,_
• and e2 = tan
x3
,
(4-61)
1 = Jilds (4-63)
The prcblem of rninimi.zinq the value of I by use of variational calculus was
solved by ~eh.l~ (Ref. 4-8). kl iJtp;rtant result of this solution , expressed
as a theorem, is stated as follows:
•
Assure that such a curve is to be drawn~ 0.0 specified end points and
several interrrediate data points . The curvature profile be~ these points
mic;ht loo.lc like that s~n in Fig. 4-lSa. ~. as pointed out by t-hhl.um,
K
•
I '
•
a Ltner \OHJ;;ItOil
r• I
k.,_,
"·
REFEROCES
4-1 07\TASAAB, "Fornela General Descripcicn, " Reg. No. 917-E, 51\1\B 1\KTI.EOOV.G,
58188 , Li.nkopi.rq, ~ . 1965.
4-2 "cat:puter Graphics Arrangerrent Progrcm~, CCGAP Systems Manual," NAVSIU.PS
090o-OJ7- 9030, e:AEll1>C 233083./MFTS, Naval Ship ~ing center, Washingtor
D.C., Nov. 1972.
4-3 Gottfried, B. s ., PrC?gramning with Basic, Schallll' s Outl.ine series, McGraw-
Hill Book COrpany, Ne" York, 1975.
4-4 ~sford , P. A.., "Mat:herootical Metrods in c.atputer Graphics- 1\ Survey,"
Gesellschaft f\1r Inforrratike , vol. 5, Synposiun on catputer Gr~cs,
IKE HAYDEN
CHAPTER 5
•
SPACE CURVES
•
•
•
'
As was the cage for plane curves, sp.~ ~ rray oo reprosc.>nted either
mnparaztw:·trically or pararretrically. '11l.ree-ditramsional spaoo c:urves expressed
•
y • f(x)
2 = 9 (X)
Alternately a space curve rray be expressed in a nonp.trMPt:.nc, ir.phcit fonn.
In this case the space curve is represen~ed rnther'atically by the Lnter-sectioo
of the t"-0 surfaces g:Lven by
f (x,y ,z) 0 {5-2)
g(x,y,z) =0
As an exan-ple, consider the t-..-o second-degree surfaces given by
f(x,y,z) y - z2 = 0
e {So-3)
g(x,y,z) - zx- y2 ~ 0
Fbr z ~ 0, x ond y can be expressed l.l'l terms of z to obtain the explicit Conn
of the curve defined by the intersecting surfaces
2
x = L,_
z
z3 (5-4)
y = z2
Notice that tho intc.rscct.i.oo o£ two secc:nd-degree surfaces l oads to a
th.ud-degree ~ curve. 'l1u..s techn.iquc of solving for z fran the ir.plicit
surface functioos is valid provided that
~~
X y
at a poi.'1t (x,y,z) which satl.Sfios tho c.~ surface equations. A similar argu-
rrent applies when sol vi.ng for x = f (y) , % = g (y) or y - f (x) , z g (x) .
In general, a pararrctnc space curve .lS expressed as
x ~ x(t) (5-5)
y ;: y(l)
z = z(t)
where the pararrotcr t varies over a given range _ t ~ t 2 • Roconsidaring ~
Eq. (5-1) we see that x itself can be considered a paraneter, X,. t, and the
sarrc curve is then expressed in param:!tnc fotm by
x=t (5-6)
y = f ( t)
z • g (t)
Further, i f we reconsider the oonparat"Ctn.c l.rrplicit representation given in
FJ::i. (5-4) we see that we can let z t:.,; t, and the paranetric equations for that
curve arc
)( - t3 (5-7)
y =t2
z = t
~useful ~ic space curves have 1cno1,..n analytic solutims . For
exa.-rple, a para!:et.ric space curve that is shaped like the seam a1 a tennis or
~1 ~ s expX'eSSCd by the following equations:
.. l., and the parameter 1 21ft , where 0 ~ t ~ 1.0. If d • 0 and c 2 • 4ab, then the
I space curve lies on a sphere o f radius a +b. I f a = 1.0 , b = 0 . 5, c .. /2,
and d = 0, then the curve lies a1 a s~ of radius 1 . 5.
'I
J\rother exa.-rple of a parametric space curve is the ci.rcular helix. 'Ihe
pararrotric equatims are given by
x = acost (5-9)
y ~ asint
z = bt
for a and b ~ 0 and _..,. < t < ao . 'Ihis curve lies oo the surface of a right c ir-
cular cyli.n.dor of radius lal . The effect of the equatioo z
is to nove the = bt
• points of the curve uruforml.y in the z-di.rect.lal. After each 211 interval in
the pararreter t , the variables x and y return to their initial values, but z
increa.s es or decreases by 2n b l , depending upon the sign of b . 'lhis change in
z i.-; callro the pitch of the helix.
l'lben an ahalytlcal description for a curve is not known , an interpolation
scherre may be used to fit a curve through a given set of data p:>ints . This
invol ves specifying boundary conditioos for the space curve in order to deter-
mine the coefficients for a given polynomial curve form and establ ishing a
s•oot.hness criterion.
r-'.any considerations enter into the decision of ho.l to represent a space
curve. 'l1le form of c:xrrputer input desired, the type of nanipulat.ials required,
the ava.1lablc interface ~ user and cx:rtpUte.r, and the display device used
for c;ral=hl-cal output can all introdoce oonsideratims and limitations. ~
the input is a series of po.mts which lie a1 t:llf!" desired curve , spl ine se<pents
arc often used to forr a szrooth curve through the p:>ints . 'nlese are discussed
in the next sectial.
SPACE aJRVES 119
where t-l(x) is the banding na1ent, E is Young ' s m::xlulus, r is the J:l'al'Cl'lt of
i.nert.La, and R(x) is the radius of cw:vaturc. For small deflect.Lcns the radius
o f curvature R(x) may be replaced by 1/ y", where the pr.irre denotes differentia-
tion with respect to x. Thus, we have
P(t) = Bl + B2t + s 3t 2 + s 4t
3
(5-11)
let:a given pair of points throu<;h \ohlch a curve ~'lt passes be the vectors
P , P.. (see Fig. 5-la) . COrresponding tangent vectors at these given points
1
are indicated by Pi, Pi,
the derivatives with respect to the parazreter t . With-
U1 the cubic segncnt the pararreter t varies betw-een t:'"'=> end-point values ,_ and
P(t ) = P2
• 2
~~
dt t=O
• P'
1
~lt=t =pi
2
Four relationships follow fran ~ . (5- ll) and (5-U):
P(O) = Bl ~ P
1
(5-D)
dP 4
- ~ L: (i-l)ti-zB. =B = P' (5-14)
dt t=O i=2 l.t=O 2 1
(5-15)
dP
- = L~ (l. - · 2B.
l)tl.- I (5-16)
dt ,t=t i=l l. t=t
2 2
SOlVl.ng tor s3 and s4 yields
(5-18)
along with 8l = Pl
P' . 'nl(>Se val'lf>S o f 8l, 8 , 8 , and 8 fix the
1
and 8
2 2 3 4
curve for tho cubic SC."<Jient. 'nlC shape o f the cubic sphnc scqrrcnt crpezds en
the erXI-point (X)Siticn and tangent vectors. Furthe r, notice that the value of
the pararreter t =~ at the end o f tre sec.;nent oocurs .Ln the results. SlllCe
each of the end-point vectors and end tangent vectors has three m•p:Jncnts , the
pararretric equation for a cubic space C\ttVO depends up::lO 12 ~'Ct.Or component s
and the pararreter value ~ at the end of the S~e<pent.
Substituting F.qs. (5-1 3) , (5-14) , (5-17) , and (5-18) into l:q. (5-ll)
yields the equation for a cubic spline segment:
)(P2 - Pl) 2Pi P2 2 2 (Pl-P2 ) P'
P (t ) = Pl + Pi t + ( - t.._ - t)t + l ) + 1 I (5-19)
2
t2 -l 2 t2 ~2 J
Equation (5- 19) is for one cubic spline SC<JICnt. It can be genera.h :r.ed
for any two adjacent cubic ~ts PK(t) and PK +
1
(t) , 1 ~ K _ n - 2 , wrerc
n is the nll!l'ber of data pomts throlgh \oohlch the curve J'IU.1St pass (sec Fig. 5-lb).
'the gencralizerl equations are of the form
p {t ) C ( + pIt. •
)(PK+l - PK)
2 -
2PK
- -
PK+l] t
2
+
[ 2 (Pl<- "K+l) PK I'K+lJ
+ '""! • 2 t
3
j
(5-20)
K K K [ t ~ t2 t t t..
2 2 2 -~
and
2
.HI'Y•2- Pl<•ll ''~•1 PK•2J 2 [ 2 (1"1<•1- Pt<+21 Pi:•l r ;.•2] 3 (5-21)
PK•llt) - r K•l ~ I'K+l" •
r 2
.. 1
- t
l
• t
)
t. -
l
- + 2
tl
• 2
ll
t
Here we assl..l!te that the paraneter variat1.on is 0 ~ t ~ t for the h.rst segrrent
2
and 0 ~ t ~ t for the second secpent, etc .
3
For ex;:urq:>lc, if only three position vectors (data points) are specified ,
the Jov..tn conditions for the entire curve betl.'eCO P arc the position and P
3 1
vectors P , P , and P and the tangent vectors at the ends o f the curve, i.e. ,
1 2 3
Pi and P)· To ensure second-order continuity for a cubic spline, we inposc the
conditioo for <XI'lStant curvature at the internal joint between the 0..0 spans .
'Ibis in'plics that the second derivative, i.e. , P" (t) , be cantinoous across the
joint.
Fran Eq. {5-10) we have
4
P" (t ) .. E ( i - 1) (i - 2) (5-22)
i =l
At the end o f the first cubic spline segrrent, ~re t = ~·
P" = 68 t._
4"G
+ 2B3
and at the beginning o f the secxn:1 spLine se<.J•ent, where t-0 ,
122 Mr\11iD'Wl'lCAL EIWmi'S FOR cx:MPl-TER GRAPHICS
P" • 2B
3
~t.lng these ~ results and using ~ · (5-17) and (5-18) yields
l (Pl - P2 Pi] pl[l(P2 - Pl) 2Pi 3 (1>3 - P2) Pj ] pi] [ 2Pi (5-23)
6~ [ t3 • 2 +~ • 2 ~ - ~ - t; • 2 t2 - t3 - tl
2 t2 2 -~ 3
~t
f.lll.tiplying by
3 and collecti.'lg terms gives
...,h lch can be solved for Pi, the unk:rloNn tangent ·vector at the internal joint.
Again nouce that the end values of the paran-eter t, i .e . , ~ and t , occur in
3
the resul ti.N3 equat; oo .
For n data points the results given above can be g~eralized to yield n - 1
cub.tc spline ~ts wit.l) position, slope, and curvature continuity at all the
internAl JOints . The narenclature for multipl e spline se<pents is ~n in
• Fig. 5-lb . In the general case Eqs. (5- 20) and (5-21) apply for any 0..0 adja-
cent data points. The secx:n:i-derivat.ive continuity condition Eq. (5- 24) ~
alizcs to
t.,-. 2r; • ' t ,. l ' '1 -1 "K•l ' ly.lr;. l • rl'.:"l<•:1'~...:, 1P)'•2- PK•l '~•2(1'1'•1. P"'ll .s, K1 11 -., (5-25)
(5-26)
..
, • • • •
I~ • • •
• l'' •
n
t) t rt~l(Pn
n-1 n ~
. pn·ll .. t~ F'n-1 - l'n-2]
B = P' (5-28)
2 K
SPJICE CURI1ES 12 3
2r; PK-+l
(5- 29)
- 'i<.. l- ~+1
, .~ P'
----::-- + K (5-30)
r,
P~
- - 2
lK+l
)----- - ).
Finally, each etbic SC<}"'\!nt is gen-
3 erated by use of Eq. (5-10 ) , with
0 ~ t ~ tmax. Before t:.he c::urvr can be
generated, the JTa'<im.Jn pararrcter value
tmax for each seqn-ent., i.e. 1 t. , L31
2
,'\
(':
,,n ,..n • • • 1 t , must be chosen. 'I'his do1ce
0
,._ 'n will affect the curve snoothncss.
Continuity of second danvaUves at
.,.,. ' the internal joints docs rot in i tscl f
P. P.' ,,
I I
produce a srooth spline in the
ro.iniJ:run curvature along the curve .
S<m.SC
To
of
'
y
/ obtain a mininun, and hence nwd11tJm
SlOCXJthness, the ex>efficients 8 and 8
3 4
oust be minimi?.ed for each seqtYmt by
Figure 5-1 CUbic spline . cl'x:losing tre correct wloos of the par-
aneter range within each SC<JilUlt. This
additional carputatl.onal effort is normally not required. Swpler nethcds
for c:OOosing tmax can be used to generate cuxves SII'OOth coough tor rrost practi-
cal purp:>ses.
One approach is to set the rrax.im.Jm parazret.er valms equal to the chord
lengths be~ sucx::cssive data FCints. This has proven to 91ve acceptably
srrooth curves for graphical display. A se<:x>nd approach is to rormalize the
variatioo by choosinq trrax '"' 1. 0 for each cubic segnent. As can be soon fran
the previous cquatioos, each choice of t;, will prodooc <!iffcrent coefficient
rnax
values and , hence, different curves through the given data fX>ints. As the
M2Jnitw:iP of the tanqcnt vectors is changed, the slope of the cubic 5eC}tents
bet;:...JPcn data FC11lts is changed. On the other hand, the di l'Cc~il'm of the t.aJ19ent
vectors controls thc shape of the cli>ic seqments at their cmd p...i ,. ~s .
l 4 1 0 0 • • P3•
• •
• • • • • • •
• • • •
• • • •
'i.'le four ccxllf1cients for each paranetric cubic equation, givcn by F.qs .
l;(P - P
r. n- 2
> - P'
n-2J
B4 ., • r 2 -2 1 1 r-PK l 1 ~ K ~ ·n - l (5-32)
a3 -3 3 -2 -1 PK+l
B2 0 0 1 01 PR
l
BlJ 1 0 0 OJ _PK+lJ
\',"ith the nonr.llizcd fo.arulation the tridia<;Utal matrix in Eq . (5-31) need only
,
' be i.•wtj...--ted ~ to dete.rmi.ne the ta.ngent \:ectors at the inte.mal joints.
a set of n positioo wctors , tlu.s represents a cxnsiderabl e savmgs of m 1p.1ter
For
tire. ~. l.f the positi.cn vectors are oot un.i!or:rnly distributed, experience
uxlicates that t:ht! resulting curves a_Y'@ not as st:mth as w-hen each segrrent. par-
l.lreter length J..S m:lde equal to 1.ts local chord. The nomallzed forna t 1an does
fi.'ld use ~"~ creating cubic bo\.ll'XB:ry curves for three-<:l.lmmsiCXlal surface patches
.. (see Chapter 6) •
Although par~l.c C\i:>ics have rr.any advantages for representing and
nanipulating curves, there are also disa&rdl1tages \.hlch limit their usefulness .
Parametnc cub1.cs never reduce exactly to a c:u:cular arc , and so true circles
can only be approximated. Also, t.~y do not closely approximlte rrat:herretical
curves whlch are asynptotic. Nevertheless , they are widel y used for many
appliCliUons, expccially in the shipbuilding and aircraft industries.
h~ Eq. (5-26) l.S used to determine the tangent vectors at the internal
JOl.nts o! a curve definod by n points, a nonsquarc rratri.x with n - 2 rows ar.d
n coll.lmS results. 'It.c tangent vec:---....or colum matrix contains n r:o..rs and the
coefficient cohr.n rratrix tx:Jnta.ulS n - 2 roo-'S. Thus Eq. (5-26) tndY be written
in~ forrn
rm IP' 1 - 1a1 (5-33)
SPN:E 0JRVEs 125
- is an n -
M 2 x n matrix
P ' 1.S an n x 1 nattix
B is an n - 2 x 1 rr.rt.r.ix
'Ihe only nonzero terms at each ro.~ o f the nonsquar:e [l-l) -1rat.rix arc
M(.J, .J-1), M(J, J) , and M(J, J+l) for 2 ~ J ~ n - 1. Hence the expanded form
of F.q. (5-33) is
M(2,1) M(2,2) P'(I<,l) • R(l\,2) (5- 34)
r:ic3,2> 11(3, Jl • P ' (1<,2} U(t\, 3)
• • •
• • •
• • • •
• • • •
• • • •
• • • •
'Ihis c:~ql~'ltion iJrplics that P ' (J<,l) = B(K,l) as is required. NOtice that the
rcsult..lng square (M)-mat.n.x .LS also t.ndi.aqonal. nus system of equauons can
ro.xiily be solV('d for the unl<noorn tangent vectors P ' (K, 2) ••• P ' (J<,N - 1) . Since
this (t-1)-nutrix is t.rid.iaqa\al, the solution can be obtainod very conciscly by
rne.'Vl..c; of recurs1on fornul..as. nus procedure is \lSed in the a l gorithm \o1u.ch
appoars in llppCndbc c.
Other CJ¥i cxn:htialS will increase the nlrl'ber of I'O'Izero terms lJ\ the first
and ln'lt ro.15 of the M-matrix. Fbr ex<L"Tple , o::nsider the mathematical c:nd oon-
2 2
ditLoo that d P/dt - 0. 1bis oondition .LS called c1t:her relaxed or natural.
to zero for the first span (J< .. 1), wi th t "" 0 , and
SettlJ"'C} Eq. (5-22) cqt.oal
using Eq. (5-17) lwd!. t.o •
(P - p )
P' +
1
!
2
P'
2
= 1_2 2
~
1 (S-30)
... If th('> s<tnv:• end cx;r,diti.c:n is used for the last span (K • N - l) , with t • t ,
I I 0
u then with the help of f:):Js. {5-29) and (5-30) one obtains
' It follows that the 11002m'0 terms in the first row of the square (11)-mat.rix are
M(l,l) 1.0 ard t-1(1,2) - 0.5. The nonzero tcnns in the last row are
P(N,N - 1) .,. 2.0 and M(N,N) = 4.0. In the [B)-natrix , B(J<,1) equals the right
s1.de of ~. (5-38) and B(K,N) equals the right side of Eq. (5-39). Notice that
this relaxed (natural) end condition also produces a tridiagonal (MI-mltrix.
otmr C!l1d concli.tions of practical use are the cyclic end oondition and
'l\oA':>
the antlcyclJ.c end candl.tion . A cyclic spl ine can be used to prodUce a closed
curvo or a portion of a C\J.t"Ve which repeats at intervals . It is based on the
follow.t..nq end oonchtion specificatialS
Pi (O) P ' (t ) (5-40)
n n
These ~ equatioos can be cxxtbined to yield a single equation "'hlch when com-
bined with the l+iratri.x yields a (n - 1) x (n - 1) square nntrix. Note that
the order of the square rratrix has been x:ed•rerl by one. 'lhi.s is because the
sl.q)e and curvature oondi tioos inposed at t:\..'0 of the n JX>ints are no longer in-
dependent. 'lfuls, there are only n - 1 independent slopes to be dctem.i.nod.
We cxx1bine Eqs . (5-42) and (s-43) by nultiplying Eq. (s-43) by t and sub-
n
t..racti.ng it fran El:). (5-42). This results in
·~] 2 (5-44)
li n
1\
t t t
2(1 ~ t2
n )Pl -1 P2f-2 + p~-1 • 3(P2 - Pl)-1- 3(Pn-l - p )!_ (5-45)
t2 n tn
Using this result allOw'S writing ~- (5- 35) as
t t
2(1 + ~) -t2n 0 • 1 P ' (1<, 1) = B(l<, l) (5-46)
• • •
• • •
Equation (5-47) s!nols that the only effect of irtt=osing the anticyclic end
oonditioos is to change the one in the M(l,t~ - 1) position of the f.t-matrix for
the cyclic spline boundary oonditioos (cf Eq. 5-46) to a minus one, as 'n"Cll
as the sign on the second term of B(K, N-1) . 'lhis type of spll.ne is useful for
produc.ing parallel end spans with end tangent vectors which are equal in magni-
US K\nm-MICAL ELEMEN1'S FOR CX:NFUI'ER GAAPHICS
'ilili1<> .._ l
Dld Ccnd.LtlCI!\9 for Cl:blC Sphll'.cz
l'rllbtrl.X
Nonzero ElAn.lnts lt\ B(K,ll
U.J Q:J'IIilti oo ~~t. First and IA.It Polo'S. B(K,NI
1. Cl."'f¥1 (onc4Sbl.Z'Odl • B(l<,l) I 0(J<,l)
cpcc1ty P' !0) , P' It J
0
~ (1,11 • 1 M(N,NI =l BIK1 1>) ... U(K,NI
2. ~~ :urod Ir.a t..ural
n:<JU!Z'I d 2P; dt 2 - o I
.Mil,ll - l M!N,N - 1 )
H(1,2 ) ~ 0.5 K<N,m • 4
2 B(K,l)
n
A(K,N) - 61Pn- P 1
n-
~
1
l (l/t
(3/2)!P - P
_ (1/~)
0
)
0 1
1
J. ()'r;L ~u.1n: M( l,l ) 211 • t,!t2 > BIK, l ) - 3CP2 - P l (tnltzl
- -
ell /at. e-o C!l / dL t•t I '4(1 ,2 , - t n/ t 2
1
-liPn-1 - r n 1 11/tn l
• •;o.l
n
····rl-l ~(1 ,1{-1) = l
.ro
d
2p 2
/ dt ~ ~ ~
~
/ dt
2
je-tn !'I (I< • " ) : IZidl!f i.nad
K•1 t..-..c'l-1
<t,!t2 >
'· MU-cyclic ~e
Cubic splines will have CXJntinuous first and secc.rld derivatives w.1.th any of
these end ccrditions. Hc7Never, if the nuroer of data. points is J.arge , 1:00 ~
r;;utaticn t.in'O required to invert the (t-lj-matrix can be excessive when cyclic
spline or anticyclic splines are generated . Additl.onal spline end conditions
are discussed in .Refs. S-3 and S-4 .
Ccrrparisons of the effects of the varicus erd conditions is shown J.n
Fig. 5-2. 1'hcse results ~ obtained with the SPLDlE subroutine given in
AppE:ndix C. In Fig . 5-2a, the "claaped" curve has a specified slope of dy/dx •
(dy/dt)/(dx/dt) equal to -1 at the beginning and a slope of +l at the end. The
other C\.I.I"Ve has relaxed boundaJ:y conditions so that d 2P/dt2 = 0 at each errl
poi:"'t. 'Ibere is a s1.gnificant variation in curve shape, especially near the
bcqi..nrung. &:>t.h curves consist. of three ctbic spans throlXJh the four indicated
dates powts . ~ c::arp.1ter progtarn qenerates 10 wterm.."<liatc powts per span
for thl.S ptl.rt icular output .
'
lr-----------------------------~-----------
I l't• I
t
I
•
·~--~--~--~--~--------~--~--~--~--~
•
Figure 5-2a
l 2 J • I
COOpari.son o f cl.alrped and relaxed end oonditioos .
l l r---------------~--~--------------~----~--------~
•
. ...
•
' ..,
-u _,
e L---~----~----L----L--~~--~~--~----._--~----~
-'l \1
Figure 5-2b
2
'
catplrison of cyclic and antiC}'Clic end corrlitioos .
F~gure s-20 sb:lws bole closed curves, a curve with cyclic end coocli.tions
through the U data (X)ints, the first and last (X)utt being identical at x = 0 ,
y • 0, and a curve, also closed, with an anticyclic end condition at x • y • 0 .
Notice that the di.rectioo of the initial end tangent vector is vertically up.tard,
while the cli.rectial of the final end tangent vector is vertically da.mward.
f'iqure 5-2c OCI!p9.res a relaxed end boundary cx:n:litioo to a cyclic end or::nli-
tioo. This illustrates ~ a cyclic en:3 conditioo can be used with an open
curve. Uoweve.r, the di.rection of the initial end tangent vector on the curve
with cyclic end conditions is the same as the direction o f the final end t::angent
vector.
•
+ {2)2
and t :
3
= IS
•
t3 = ~x3 - ~)2 + (y3 - y2)2 = ~3 - 1)2 + (0)2 • 2
Usi.nq fl:!. (5-26) and the relaxed ero conditicn F.qs . (5-38) and (5- 39) I the
rMtnx equaticn required to find the int.ernal. de.rivativc P 2 is
3
1 0.5 0 Pi • vS (P2 - P1)
2
2 8.472 2. 236 P' 3/5(5(P - P ) + 4(P - P l)
2 2 3 2 2 1
0 2 4
Solvi.nq for the derivatives by invert.inq the 3 x 3 square mtrix and rultiply-
i.nq yields
l • 1 . 1574 -0 . 0787 0. 0440 0.67l (P2 - Pl)
P2 - 0 . 3148 0.1574 - 0.08798 0.671(5(P3 - P2 ) + 4(P 2 - P1 )J
Pj 0.1574 -0.0787 0.2940 3CP - P2 )
3
Thus,
Pi= 0. 5654(P2 - P1 l - 0. 132(P3 - P2l
= 0. 5654[1 2) - 0.132(2 0]
• (0.3013 1.1308)
SPICE CURVES 131
Pi • 0.2112CP2 - P ) + 0.264l(P - P )
1 3 2
0.2112[1 2] + 0.2641(2 0)
- (0.7394 0.4224]
Pj; -0.1056CP - P ) + 0.618(P - P )
2 1 3 2
• -0 .1056(1 2] + 0.618(2 OJ
= [1 .1305 -0. 2111)
Recalling EkJs. (5-11) and (5-27) to (5-30) allo,.,s calculatioo of the ci.Dic
spline segmmts. fbr the first segrumt
P(t) = B + B t + a t 2 + a t 3
1 2 3 4
and
B • P • (0 0)
1 1
pi -
82 ;
3
(0.3013 1.1308)
2Pi Pi
,
8 3 "" S(P2 - Pl) - IS" - 7s
= o. 6(1 21 - o.a944IO.J013 1.13081 - o.4472[0.7394 o. 42241 = ro 01
•
= 0. 17889(-1 -21 + 0.2(0.3013 1 .1308) + 0. 2(0 . 7394 0.4224)
• [0.0293 -0.0472)
Oxx>sing t/~ .. 1/3, 2/3 yields t = o. 745 , 1.4907' and
oc:cur ~th cubic spl::.n~ mves l.S the use of sp:ines ~ ter.sion. OscJlla-
tions occur since the cubic S?line .l.S influer-..oed locally by each data p:>1r.t
• - J lie:
- I
-2 ~--~~--~----~----~----~----~----~----~----~--~
• 2
Figure 5-2c Cc:r.pariscn of re~ and ~'Cllc ' •
crd conditions for
11
open c.n::ves .
SPJlCE CURVES 133
where t is the distance between P4 and P • 'nle coeff!cients of P(r) and Q(s)
0 5
act as blending functions , varying linearly be~ 1.0 and 0 , and 0 and 1.0
respect.ively.
'11-.e {XlSition vectors P , P , P , and Pabove are specified in teJ:rns of
5 6 3 4
tlle cartesian xyz-<:OOrdinate systern, whereas the blendin:J parabolas P(r) and
Q(s) are specified in terms of a local cx:ordinate system. To derive the para-
rretric, parabolic equat.i.oos in tems of the xyz-<:OOrdinate system, the gearetry
)
Solving for x in the xyz-<:OOrdina te sys-
tem yields
"I (P4 - P3) • (P5 - P3) (5-54
x=
I ';
<Ps - P3>
2
--;.-;- -
. .t-./ ~
\
\)' , _, ... , '6
=
(P4 - P3) • (P5 - P3)
PI d2
•
With this informatioo tho vector equation
for a EX>int P on the parabola P (r) , rela-
tive to t:00 xyz-<:OOrdinatc system, is
given by
,I
Figure 5-4 Parabolic blendin:J.
SPACE; CURVES 135
r
P(r) = P + d(P - P ) + ar(d - r) (P - J ) (5- 55)
3 5 3 4
or after using Eq. (5-52) for J,
r
P(r ) = P3 + d(P5 - P3) + ar(d- r)((P - P ) - x (PS- P )) (5- 56)
4 3 3
It remains to deteonine a arrl the pararretric equation f or r ( t) • Since in the
~rdinate system P(xd) o P , it fo.l.la..os that the vector equation for P - J
4 4
is
or
Q - 1 (5-57)
- 2
d .x(l - x)
'l1le required relatiooship for r = r(t) can be obtained fran the C}ealctry
shown in Fi g . 5- 5. It follows that
r = J<d + tcose (5-58)
Ps - PJ
cosO= (P - P )·( t d ) (5-59)
5 4
0
For the paratola Q(s) , similar equations can be derived using Fig . 5-Sb. For
the parabola Q(s) , the relaticnship s = s(t) is
p6 - p4
s = toos6 = t [ (P - P4 ) • ( t e )) (5-60)
5
0
and
(5-61)
+ (- l ) (Q - P) (5-63)
to
At point P4 on the ble.'lding curve, t = 0 and P • Q. 'lbus
ck:: dP
<at> - <at>
p4 p4
"nlat is, the slope of the blerv:ling curve
nique that can be used with paralx>lic blencling. Qloe the sketch is defi.Iw::ld in
a OCill'Uter, then the vectors definin<] the points can be qwc..-. ly displayed in a
variety of ways . In sare applicaticns it rray be desirable to sketch a shape
by using parabolic blend.ing and then use the resultinq junclia'l (X)ints as data
for other techniques.
Assure that the positioo vectol:'S P [0,0), P4 (1,1), P (3,2) , rud P6 (4,3)
3 5
are J<nown. We wish to dcte.rmine a curve between t:.he t:o..'O po1.nts P and P usmg
4 5
parabolic b l e..,din}. The procedure is
1. Fbr each span catp:)Se(i of three points
a. calculate x
b. calculate (lor e
c. calculate r or s for given t
2. calculate the blended curve
fbr the first span E):j. (5-54 ) yields
c~+j>·<3i+2jl 3+ 2
- - - 0 . 3846
(9 + 4) 13
1
(13)(0.3846) (1- 0. 3846) = 0 • 325
~l ing Ek}. (5-58) \ole first calculate
2 2
t
0
= fc2> + (1) - IS
cose=
= (2i + j) . (3i + 2j) .. 6 + 2 = 8 = o. 9923
IS l.i3 /5 10 IS li3
and
For t/t
0
- 2/3, t • 1.4907, and r = 2.8659, &J. (5-56) then yields
P(2.8659) = (2.279 1.7487llt/t ~2/3
0
For the secocd span
(P5 - p 4) • (P6 - p 4) 8
X= 2 :::; IT = 0 . 6154
(P6 - P4)
B• 0.325
t = ~
0
•
e = II3
(PS - P4 ). (P6 - P4 )
oos6 • t e • 0 . 9923
0
I s = tcose = 0 . 9923t
For t/t .. 1/3, t •
0
o. 745, and s • o. 7392 , &J. (5-61) yields
I
Equation (5-62) rray now be used to b l em the bNo parabolas to yield the
desired curve between P4 and P 5 :
C(t) .. (1- f0
) P(r) + <-£=->oCs)
0
unaffected .
'The mathematical basl.S of the Bezier curve is a i:olynomial blending func-
tion 1</tuch lJ'Iterp::llat:es bebleen the first and last vertices . 'The Bezier p;>ly-
nanial related to the Eernstein polyranial.. 'Ihu.s, the Bezier curve is said
l.S
J . (t)
n,~
= (~)ti(l
~
- t)n-i (5- 64)
where
,n n!
I 1i) ~ i! (n-1}! (5- 65)
with n being the degroo of the p;>lyocrnial and i the particular vertex in the
ordexed set (fra11 0 to n) • In general an nth order p;>lync:rnial is Sf'ECille::l by
n + 1 vertices. The curve points are then give."l by
n
P(t) = P.J . (t) 0 < t < 1
i=O ~ n,1
L (5-66 )
where P . contains the vector COtfXJne.,ts of the various vertices . At the start-
~
1.n9 point of a curve segrrent,
3n,O(O) ""
nl (1) (1 - O)n-O
n! . 1 (5-67)
l\t the end point of a curve se<;rent,
n n-n
J (l) = n! (1) (0) (5-68)
n,n n! (1)
Equatioos (5-67) and (5-68) along with Eq. (5-66) sl'x::7N that P (0) = P and
0
P(1) = Pn; .1..e., the vertices P and Pn lie on the actual curve seg;rent at the
0
starting point and the e."ld point respa:tively.
Another characteristic of the interpolatioo fln::tioo is tl-.at max:iirun
values occur at t =. i/n . '1'his maxirrun is g'iven by Ref. 5- 12 as
(5- 69)
-- 4
9
SPACE CURVES 141
2 4
J3,2(3) - 9 1',•
As an e.xa.'Tple, consider cubic
Bezicr curves, as sha.m in Fig. 5-8. r
Table 5-2
Results for Bezier Curve
n=J
•
1 J n,i
0 l/3 2/3 1
(5-73)
'lhls illustrates that the first derivative of the Bezier curve at the initial
and fi.nal points is tangent to the initial and final pol}'90n segtrents, i.e.,
the end s lopes are fixed by the directiat of the line jo:i.n.ing the two end
vertl.ces.
These results illustrate that the second derivative of the Bezier curve at the
initial and final points depends en the nearest two polygon segmnts or on the
nearest three polf9C11 vertices . In general the rth derivatives at an end point
or start.ing point are detenni.ned by the end or start.ing point and its r neigh-
boring poly<p1 vertices.
Continuity carlitions beb.'teen adjacent Bezier curves can thus be sirrply
specified. If one Bezier curve of order n is defined by vertices P1 and an
adjacent Bezier curve of order m by vertices Q . , then first derivative oontin-
J.
uity at the joint is obtained when
P' (1) ,. g:J' (O)
o r where 9 is a scaler . Using F.qs. (5-72) and (5-73)
Sinoe the curve must be ccntintDUS at the joint, 0o "" P0 • Thus, the end of
ooc:; sec}'l'ent is equal to the starting slope of the next segrent when the three
points 0 , P , P are col.i.near . FOr the particular case of two adjacent
1 n n-1
cubic Bezicr curves (cf Fig. 5-9) , n = m = 3. If both diroctioo and JTa911itude
of the JOint tangents are to be equal, Eg. (5-75) yields
0 1 - 0 o = P 3 - P2 = ~ - P3
SPJICE ~ 143
•
Exanple 5-3 : BEZIER aJRVE
Table S-3
)
Coefficients for a Bezier CUrve
1',
J P, •
t JJ,O J3,1 J3,2 J3, 3
0 1 0 0 0
, 0. 15 0.614
•
0. 325 0. 0574 0. 0034
•
0. 35 0.275 0. 444 0.239 0. 043
0. 5
I .L
I
pl 0. 65
0. 125 0. 375
0. 043 0. 239
0. 375 0.125
0.444 0.275
o. 85 0.0034 0. 0574 0. 325 0. 614
1 0 0 0 1
0~----~----~------~----~
I ~ ~
noted in the prev1.0US section, the Bernstein ba.eis prod11ces &...-z.ier curves gen-
erated by Eq. (5-66) . 'lle;e have several useful properties.
'1\.o chAracteristics of the Bernstein b<lsis, hc:Mever, limit. the llexibility
of the resulting curves. First the nll!Tbar of spec1fied polygon vert1ces fixes
the order of the resulting polynomial which defines the cw:ve. For exnrrplr>, n
cubic curve nust be defined by a polygon with four verttces and three spans.
A polygoo with six vertices will always produce a fift:h-dcqree curve. 'Iha only
'Wa¥ to .reduce the order of the curve is to reduce the n\.'Ulber of vertices, and
cnwerse.ly the only way t:o increase the order of the cur:vc is to ux:reasc the
m.1tbe.r of vertices.
'Ihe second limiting characteristic is due to t..he global nature o( the
Bernstein basis . 'Ihls rrcans that the value of the \<o~ght.ing function J . (t)
n, 1
given by Eq . (5-64) is nonzero for all pararreter values over an entire span of
the curve. Sinoe any point on a Beder curve is a resul.L o! ~<~eighLing th!= val-
ues of all defin.ing vertia-s, a change in one vertex is felt 1:hrougl'xlut the
entire span. Practically, this elim.inates the ability to produo:! a local chango
within a span.
Fer e.xaJTPle, siJ1c:e the end slcp:s of a Bezier curve are established by the
directialS of the first aoo last polygon sides, it is (X)Ssible to change the
middle vertex of a five -point pol}'900 witOOut changing the di1•ection of the
end s l opes . However, tha shape of the total curve .LS aff~ duo to the qlobt,l
nature of the Bemst=Pin basis. This lack of lcx:a1 span oontrol can be detri-
rrental in sate applications.
'n1are is an:>trer basis, called the B-spline basis, \orhlch C<XItains the
Bernstel.ll basis as a spec1al case. 'lbis basis is generally nooglobal. The
nonglobal behavior of a-spline curves is doo to the fact that each vertex P. is
l.
associated with a unique basis functiCX\ . '111us, each vertex affects the shape
of a curve only over a range of parMeter values where 1.ts associated basis
function is nonzero . 'lbc a-spline basis also allows the order of the resulti.nq
to be changed without changin9 the mmber of defin:ing polygon vertices.
C'\.lt'VC
The theory for a-splines was first suggested by Sc:hoenbe.rg (Ref . 5-13). A
recursive definitioo useful for nt.Drerical cmput.ation was published by Cox
~- 5-14), and by de Boor (Re£. 5-15). Reisenfeld (Ref. 5-16) applied the
B-spline basis to curve defiru.t.lCI'I.
If \<o'e again let P(t) be the positioo vectors alon<J the curve, as a fmction
of the parall'cter t , a curve gererated by the use of the B-spline basis is given
by
n
P(t) = L P.N. k(t)
i-o l. l.,
(5-77)
146 l·~ICAL EII:'0ll'S FOR en~ GRAPIUCS
othexwise
•
Fbr cx.a."tple, the vector (0 l 2 3 4) indicates that the par.uroter t varies fran
0 to 4. 'lhe m.aTber of inte.nred.iate knot vectors depends on the nmbe.r of spans
in the defi.n.i..ng polygon. A d\~licate interrrcdiate knot value indicates that
a nultiple vertex (span of zero length) occurs at a point, and an int:ei.1rodiate
knot value in triplicate indicates three coocurrent vertices (bot> zero-lenqth
spans) . The actual point on a B-spline curve which corresponds to the value
of a paranetric knot (t • xi) is called a gearotric knot. It is convenient to
use evenly spaced knots with unit separation between roncoincident knots. 'lhls
gi VI!S integer values for the a:J"IPC)nents of the knot vector . In addition to the
knot vector values, the order of the curve must be specified. I f the order k
equals the nunber of polygon vertices, and there are no multiple vcrt1ces, then
a Bezier curve will be generated. As the order dccre-1ses , the curve produced
lies closer to the defining polygon. '~ k =2 the generated curve is a series
of straight lines which are identical to the defining polyqon .
'l'hc order of a curve is reflected in the knot vector that ls used to gen-
erate the curve. It is necessary to specify knots of nultiplicity k at both
til" begl.M.i.ng and the end of the knot set. For exarrple, oonsider a hve-point
pol~'qOI"l (n + 1 - 5) with no duplicate vertices. h1lcn there are no duplicate
vertices, the p.u-aneter t varies fran 0 t..o n - k + 2 over the entuc curve.
SPJ>a: CURVES 14 7
• •
'• •
• • • u
Figure S- 11
'
B-spline curves .
• •.----~--~----~----------~---------------~--------~
•
5/S
'
'
fL---._--~--~----~--~--~--~----~--~--~
• 2
F'l.gUre 5-12
4 '
Multiple vertex B-splinc curves.
•
"
SPliCE CURVES 149
Figure 5-U shows the effect of rrultiple vertices in the defini.ng polyyoo.
For each of the four curves shown, the order of the curve is equal to the n\.r.be.r
of vertices in the defining polY90fl. 'lb! lower curve m fig. 5-12 is identlc-al
to the lo..er curve in Fig. 5-ll, a fourth-order curve defined by four polyqa1
vertices. 'Ihe seo::::nd curve l.n Fig. 5-12 is a fi.fth-arder curve with a double
vertex at [3,9) . 'Ihe third curve is a s.ixt:h-ottler curve with a triple vertex
at (3,9). The fiMl seventh-order curve has a defining pol yqon given by
001
3 9
3 9
3 9
3 9
6 3
6
e . g., four nultiple vertices at [3 91. 'lhis figure clearly shows how a curve
can be pulled clo$er to a speci fjc vertex positjoo by use of nultiplc vertices
while rraint:aining the sa~re end slopes for each curve. ()) the other hand,
decreasing the order pulls the curve closer to all polygoo vertices.
In Fig. 5-13 the defining vertex lS
l l r---~----~--~r----r----~--~----~----r---~----,
'
e L---~----~--~----~--_.----~--~----~--~--~
I 2 • ' • II
ro o
2 5
I4 8
6 3
6 3
8 6 •
l1o 1
for each curve. '!1lat is, \>'e keep a double vertex at the fourth ele!l'ellt in the
polyr;p1 . Hen! the curve is al t.ered by chanqi..ng the order of each curve, ~
ing the defining p:>lygon constant. The first curve is of order seven , equal
to the m.:'li:er of vertices in the polygon . The second curve is of order five .
'lhls curve shape is closer to the polygon shape, expccially O('ilr the double
vertex. The third curve is of order 3 . Notice that a "knuckle" occurs at the
double vertex since the slope and curvature are discontinoous. A duplicate
vertex is required to create a knu::kle in a third~mer curve . A triple vertex
creates a kmx:k.le in a fourth order curve. This ability is a mmLll"1 requirement
in stup desl.gn.
• Figure 5-14 deronstrates ~ local changes can be .rrade without a£fecting
I
the enUre shape of a curve. Each curve is a fi.fth~rder curve, defined by a
I
seven-point polygol"' with oo multiple vertices. 'llle only difference bebolee.n
r~cu. l:lnZt
""...........:lr.
~ r.ulll:.lle ~
.....t )"~
• 1
' • ll
each curve 1.s that the fifth vertex is rroved to a new posiUoo, as shewn in
the figure. It can be seen that the first part of each curve is 1.11'\Chanqed.
'1llis behavior is a result of the nonglOOal. (local) nature of the B-spl ~
basis.
Figure 5-15 shcJo...'S curves of order 2 through 5, generated by a six-point
polygcn with no nultiple vertices. 'the fourth order curve is a cubic spline.
'1lle &-spline curve technique all.oNs a orne spline to be generated witll three
or nore pol ygon vertices . Since there are five spans in this polyc:pt, the
fif~rder curve is the Bezier curve. 'Ihe third-order curve may be of special
interest since it is tangent to the midpoints of the internal polygon spans .
nus characteristic is also sh::Jwn in Fig. 5-16, where a third-order curve is
generated with an eight-point polygon.
Cl:lnsidcr lhe sarre four polygon positioo wctors tLc;ed in the previous
exanp1e for a Bezier curve . 'lbese are P (1 1) , P [2 3), P (4 3), and P (3 11 •
0 1 2 3
The knot ~tor set for a second-ordP..r curve &!fined by four polycJOn vertices
is [O 0 1 2 3 3) , where we denote ><o = o, ~ = 0, X:z"' 1, •• • , ><s • 3.
\ohm using Eq. (5-78) the conventioo 0/0 = 0 is applied. ~ N. k values
l.,
needed are
(t - O)NO
1
(t) (X:z- t)Nl,l(t}
N0 , 2(t} c: +
~- xo X:z-~
(t - 2)NJ , l (t) (x
5 - t>N4 , 1 (t)
N3 , 2 (t) = x4- ~
+
><s - x4
Specifically, fior t = o, N , 2 (0) = 0(1)/0 + (1 - O) (1)/1 • 1 . 0 and
0
N , (t) a 0(1)/1 + (2 - 0) (0)/l = 0. Fort= 0 . 5 we find N , 2 (t) = 0.5(1)/1 +
1 2 1
(2 - 0.5)(0)/1 = 0 . 5 , and fort= 1 we calculate N , (l) ~ 1 (0)/1 + 2(0)/0 = 0
3 2
other values of N. k are found in a similar manner. Table 5-.4 gives the COir-
J. ,
plete results. By usmg tl1e values of N• . given in Table 5-4, points oo the
l.,)
seoond-order curve can be detennined. Ftun Eq. (5-77) , in general,
P(t) PON0,2 + PlN1,2 + PiN2,2 + PjN3,3
152 ~TICAL E:I.EME:Nl'S FOR CCt1Pvn::R GWIH!CS
1 ~ ~------------------------------------------------~
'
•
•
•
I S
t L---~--------~------------------_. ____~___.____J
•
• F~gure
• '
5-15 Varying order of B- sp1ine curves.
I u
'
I L---~----_.----~----~--~----~----~----~--~-----J
I ? 4 ' • ll
Fl.gure 5-16 'lhird order a-spline curve.
SPACE O.I'JM:S 153
Table 5-4
'oJeight.i.ng f\mctions for a second-Order B-Spl.tne
N0,2 1 0. 5 0 0 0 0 0
N2,2 0 0 0 0. 5 1 0.5 0
N3,2 0 0 0 0 0 0.5 1
For t = 0,
Similarly
+ P (0.5) + P2 (0) + P3 (0) • O. S(P + P )
P(0.5) • P (0 . 5)
0 1 0 1
P(l) = P (0) +
P (1) + P (0) + P (0) = P
0 1 2 3 1
P (0.5) + P (0. 5) + P (0) ~ 0.5(P + P )
P(1 . 5) = P (0) +
0 1 2 3 1 2
In a like rranne.r the last three points are P(2) ,. P , P(2 . 5) • 0.5(P + P ),
2 2 3
and P(3) = p3 , 'l1lese points obviously fall on the straight lines joining the
polygon vertices.
Now, i f the order of the curve is increased frau two to four tor the sane
four defining polygon vertices, a Bezier curve will be obtained since lhe order
l'lCW equals the nt.nbe.r of vertices. 'lb! knot vector set (with tmax •
3 - 4 + 2 ... 1) is [0 0 0 0 1 1 1 1). Values of the weight.ing function.s given
by Eq. (5-78) are
(t - O)NO 3 (t) (1 - t)N , (t)
1 3
0 - 0 + l- 0
(t- O)Nl , J(t) (1 - t)N2 , 3 (t)
t> •
Nl, 4 < ---.rr----;:o~- + 1- 0
( t - 0)N , (t) (l - t)N) , J (t)
2 3
N
2 14
(t) a
1 - 0 + 1-0
(t - O)N) , ) (t) (1 - t)N (t)
4 3
N3 ,4 (t) = 1- 6 + 1 - 1
Proceecling with the requ.u:cd N. evaluations,
l. , 3
(t- O)N , 2 (t) (1- t)N , (t)
0 1 2
0 - 0 + 0- 0
(t - 0)N , ( t ) (1 - t)N , (t)
2 2
1 2
N , (t)
1 3 = 6- 6 + 1- 0
(t - O)N2 , 2 Ct) (1- t)N , (t)
3 2
~
13 (t ) II
1- 0 + 1 - 0
(t - 0)N , (t ) (1 - t)N , (t)
3 2 4 2
N3,3(t) :a 1- 0 + 1- 1
(t- l)N , (t) c1 - t>N5 Ct>
4 2 12
N4 , 3(t) = 1-1 +- 1 - 1
'lhese N. equations in turn requi.n! N. values given by
~. 3 ~. 2
(t - O)NO,l (t) (0 - t)Nl,l (t)
N0 , 2(t ) "' + 0 - o.
0 - 0
(t - 0)N ,l (t) {0 - t)N , ( t)
1 2 1
Nl,2(t) "' 0- 0
+ 0 - 0
(t - 0)N l (t) (1 - t)N) (t)
2 1
N2, 2{t) = 0 - 0
+ 1 - 0
uJ ( t - O)NJ, l (t ) (1 - t)N , (t)
4 1
N3 , 2(t) = +
1- 1
(t - l)NS , l (t) (1- t)N , Ct )
6 1
N5 , 2(t) • +
1- 1 1- 1
Let us evaluate the point on the curve at t • 0 . 5. Since the pararreter
variation as specified by the koot vector fa ll s between 0 ~ t ~ 1 for this case,
the value P (0 . 5) slx>ul.d oorrespcnd to the value P (O. S) found in tho Bezier
example in sec. 5- 7. For t • 0 .5, NO , l • N1 , 1 • N2 , l • N4 ,l • N5 ,l & N6 ,l ~ 0,
and N3 ,l • 1 . 0. Thus , N0 , 2 = N1 , 2 = N4 , 2 = N5 , 2 = 0 , and
N2,2(0.5); 0 + (O . Sl(l) ~ 0 . 5
N3 ,2 (0 . 5) = (O.Sl(l) + 0 =0.5
tt~rk.ing backward it follows that N , 3
0
= N4 , 3 = 0 , and
Nl,3 = 0 + (0 . 5i(0 . 5) = 0 . 25
(0 . 5) (0. 5) + (0. 5) (0 . 5) - 0. 50
N2 , 3 = 1 l
N3,3 = (0 . 5 )1(0 . 5) + 0 = 0 . 25
Likewise
N0,4 D 0 + (0 . 5)10 . 25) = 0.125
N1,4 = (0 .5) 1(0 .25) + (0.5)1(0 . 5) - 0.375
SPN::I:. C'tJR\.1&S 155
N
3,4
~ (0 . 5)i0.25) + 0 = 0.125
Finally, the point an the curve at t = 0.5 is given by Fq. (5-77) as
or
P(O.S) • (l 1]0.125 + [2 3)0.375 + [4 3)0.375 + (3 1)0.125
= [2 . 75 2.5)
'Ihe x~t is then P
X
= 2. 75 and the y~t P
y
= 2. 5, \oohlch
agrees with the ee~:ier curve results.
Algoritl'lm9 which will generate the required B-spl.ire rusis knot vectors
and the corres{X>nding B-spllne curves are given m Appendix c.
REFERENCES
ic.U controlled rmchine tool tapes can be obtained. The feasibility of produc-
ing a surface chrectly from a c:x:r:p..rt:..e stored representatioo of that surfo!lee
has been denpnstrated by Bezier (Ref. 6-1), Sabin (Ref. 6-2) , Peters (Ref. 6-3),
and others .
Various techniques of anal.ytically and nurerically representlng a three-
din'ensicnll surface are discussed below. To begin the discussicn we oons1.der
a SlJ!'Ple spherical surface .
158 Nl\THEM\TICAL EI.F2'.ENTS FOR <XNPUI'ER GRAPHICS
~ + y 2 + z2 • 1.0 (6-1)
Thus,
-.
'\
• \
•I • •I ..a I
/ --
,~ I )
~I I
I
I
/ I
I
I
I
, "'
, ~"
• b
where ~ · e2, am e) are unit vectors l.Il the rectangular coordinate system, and
s is a p:>sition vector 01 the surface of the sphere as shown in Fig . 6-2. '11\is
surface patch can be thought or as the locus of a p:>int in three-ditmnsional
space whi ch rroves with two degrees of freec1an cxmtrolled by the two pararreter
vari.llhles e and ~.
y
/D
•
as ..
ai = -c3
At oomer C, ~ • n/4, E = r:/2 , and
as 1 ....
'aif .. -If~
as 1 " 1 +
3i = n e2- 12 c3
Here the rragnitude of as;ae is 1/12, and the IMgnitude of ilS/il4> is
Table 6-1
Tangent Vectors for the Spherical
surface of Fiq. 6-2
The cross derivatives, or twist vectors , at the oomers are also useful
in describing the boundaries of a surface patch . For the unit S{:tlerical patch
these are
(6-7)
c:os2Poos2~ .. COSQ
Note at oomer A,
Ia2s;aea¢.- o
a2s
aea~
- .C2eoos2¢ +
vectors and their rr.agni. t' !des for the comers of the spherical and surface patch
are sho.m in Table 6-2.
St.JRF'ACE DESCRIPI'Irn AND GFNEPATIOO 161
Table 6-2
Twist Vectors fur the Spherical
surface of Fig . 6-2
0 0
c -1/12 e 1 l/~
0 0 0
SUt'face normals can also be u9¥1 to indicate the shape and orientation
of a surface patch . 'lt.e surface nonrals are given by the vector cross prc<}t.ct:
of two tangent vector s . For the SFherical patch ,
as
N=aexa¢ "'
as ~
e1
.
e2
...
e3 (6-9)
-sin6sin9 cos9sin4 0
ocx~ sin6cos~ -sin¢
+ ~ +
0, N • ~ ,
It follo,..ts that at comers A and
+ t
2 at corner B, N = -l/2(e1 + ~) and
•
a t comer C, N a - 1I 2 (e + e ) . 'nle no:mals at c::o~rs Band Care slno.n l11
2 3
Fi g . 6- 2 . 'nle out"...'al'd drawn normals for the surface patch are the negatives of
these values.
A unit s urface nornel is defined by ;:; • N/INI . Expanding F.q . (6-9) gives
(6-10)
and
(6-11)
'lllus,
(6- U)
where
lnl = 1.0 (6-13)
A f.i.nal vector operation which is useful for surface descdpt.i<n is the
dot procb::t. For the surface patdl under cxnsideratioo,
;;s · ~
~ as • ( C-uinl.llin01e• • (001i:t~le• J • ( ((X)Gf.C015;)e
.. .. (5.Ul'c.oa.tle
· .. - (sin~le• 1 • 0 (6-14)
1 2 1 2 3
Si.nce the dot product of these tangents vectors egual.s zero , the b.o tangent
vectors are perpendicular to one another. 'll\us, lines of ¢ r constant (par-
to lines of 9 = constant (rreridians of
longJ.tu;!e) on the surface.
HaVl.nCJ used a spherical surface to illustrate a nmber of useful oouoept.s
for surfaces, e.g. , tangent vectors, twist vectors and surface normals, "-'E! now
consider rrcthodc: for describing rrore arbitrary surfaces .
1 y • g(u,w)
, 'Ille funct.i.als in Fqs . ( 6- 15) are chosen such that the four bouOOacy cuzves are
described by the follc7wd.."lg four oonditi.als :
u=c c ~ w ~ c (6-16)
1 1 2
u=c c 1 .5.. w ~ c2
2
w·~ c ~ u ~ c2
1
w .. c c1 ~ u ~ c2
2
'lhls defines a square in the tr,..._plane, as ~ in Fig . 6-3. The functiCI'ls
"''hich represent the actual surface are t:OOse which map this square in the u..~
dy=fuou•~
These equations can be written in matrix form as
[dxl = ax ax du1
r au~ I' (6-17)
ldyJ = ~ ~ awj
Equatioo (6-17) relates a differential change in the trN'-plane to the corres{Xltld-
inc; different •al change in the xy-plane.
E-::xmtple 6-1 : PlANE SlJRF7ICE
c, .c,
~--~------------------
~ ~VED ~FACE REPRESENTATION
L •
c.,• Before~ with the details
of the rcprcscntatioo of curved three-
F'i.<JUre 6- 3 Pararretric surface d..i.rmnsiala.l surfaces, it is necessary to
rectan9le . make several deM s1ons. First, we ass1..11re
a surface representatloo h:tserl oo a vector-valued para:retric oonoept. 'lllere
are several reascns for this. 'lhis type of representat..l.cn is axis-.in:iepe.ndent:
it avoids infinite slope values with respect to sare arbitrary axis system, it
all~'S the unarrbi<Ju:>US representation of llllltivalued surfaces or space func-
t.ials , it facilitates the repz:esentatioo of space curves in ha ogeneous coordin-
ates, and it is oonpatible with the use of the iooal. harogeneous
ooord.il\ate t.ransforrnatioos discussed in Olapter 3.
We will assme that a surface may be represented in a ~se fashial;
i.e., a surface l.S cac!V)Sed of a nlreber of patches which are joined together
in sore fashioo at the boundaries . No attenpt will be rMde to represent a
oatplete surface analytically.
In order to efficiently represent a surface, sane notaticnal dctcils are
necessary. For consistency we represent a curve as a vector valued function
of a SiJ19le variable; i.e., the cuxve P(t) is
P(t) - fx(t) y(t))
for a planar curve and
P(t) = (x(t) y(t) zCt))
for a space curve. Here t is a paraneter. As we have seen in the previous
two sections , n:presentatioo of a surface requires two parmreter values . 'lllus,
we assurre that a surface nay be represented by a bivariate ~-valued
•
y
b l
y
4 • • J•••
y•1'U •"" •\I._
•'
f
n • • b I • J
b
Ql -~~01.11
PtU 1Sll:!5t
Pl0.01
•
p ( I 01 u •
QtfJ.O)
l •
Qr flJ -•
• • a., •• • •
.. .. ,_ . •
- . .. • ""L ' .., • • •
\\•COnSI:lOI
I
O.S / )
10
I'll 01
II I
lj
I
•
u- con~tant O.S
z
I
'
If
i
)
I
I
I
I Pcu.IJ
Q f)l.tnc
Plu.lll
'I\.'0 curves P(u, O) and P(u,l) are given by cubic spline se<.JrellW {cf
sec. 5-3) .
Ne wish to find the equation for the lofted surface bebo.U!ll these two
l.xlundarlcs. 'l1'le cubic spline 5Cg~Ml'lt.s are assu-ned to have cl.arrped ends.
1\.ssi.M:! for
P(u,O) and P(u,ll
p1 -- (0 0 0] pl. [1 0 0]
p2 .. [0 l O! p2 = [1 l 1]
P'1-
- [0 1 1) P'1-
- [0 l 1]
- (0
P'2- 1 1) P' • (0 1 -1]
2
1-l..ence, csi."\g &i . {5- 19) ,
P{u,O) = [0 0 0] + [0 1 l]t ~ [0 0 -3]t2 + {0 0 2]t3
P(u,l) • [l 0 0) + [O 1 l]t • (0 - 0.6213 0.7929)t2 + (0 0.2929 -0.707}t3
Equation (6-20) then yields
ocu,w) . lw 0 0] • (0 l l)t + {0 - 0.6213w f- 3 + 3 . 792~~)]t 2 - [0 0.2929w (2 - 2.707W))t 1
'Zhi.s is the surface ~ in Fig . 6- 6.
If the four bounda...-.y curves P(u, O) , P(u , l), P(O ,w), ar.d P(l,w) are I<J1a.m,
then it rni~t be assuned that a si.'Ipl e S\:1\ of the lofted surfaces r..qs . (6- 20)
and (6-21) in the ~ di.rections w::>uld yield "t:re desired result. If t:lus 1.5
dale, then
Q(u,w) • P(u,O) (l - w) + P(u,l)w + P(O ,w) (1 - u) + P(l,w)~ (6-22)
tk::Me\.-er, examinatioo of F.q. {6-22 ) at the ex>rners of the surface patdl yiel.Cs
Q(O,O) = P (O ,O) + P (O ,O) , etc .
arxl at the edge.s,
Q(O,w) • P(O,O) (1 - w) + P(O , l)w + P(O,w)
neither of which oorrespoods to the original data as they should.
Examination of F.q . (6- 22) sh::lws tl-.at the problem occu..""S because t.~e
corner points are oounted bdce, since P(O , O) is contained in both the P(u ,O)
and P(O,w) be~ curves.
'lhe oorrect result can be cbtained by suhtracting the excess contributicn
to t~
surface due to duplication of the oorner points. 'Ihis yields
Q(u,w) • P(u,O) (1 - w) + P(u,1)w + P(O,w) (1 - u) + P(l,w)u (6- 23)
- P(O,O)(l - u) {l- w) - P(O ,l)(l - u)w - P(l , O)u(l- w)- P(l , l)uw
An exarrple of such a surface is ~ in Fig. 6-7. It can be readily stn.n
that at the oorner,
Q(O , O) = P(O,O)
etc.
ard Along t"le bo..ndaries,
Q(O,w) ==- P(O,w)
Q(u, l) • P(u,l)
etc.
\\hlch .inplies that the interpolation is oorrect at the oorners and bo\.t\daries.
'Ihis linear blend of the four boll'ldacy curves is +Xe s.inplest Coons surface.
A rrore general COOns surface is discussed in Sec. 6-17 and Jef. 6-4. In vector
notation, at. (6-22) may be written ctS
Let the four boundary "curves" be the d.iagc:nals of four of the sides of
a unit cuve as sha.m in Fig. 6-7. '''e wish to fiM the center point on a linear
Coc.ns surface between these boundaries.
For the oenler point oo the surface, ~· (6-24) yields
~(0.5,0 . 5) • [0 . 5 0. 5 1) 0 0 01 0.5
-1 -1 lJ
0 . 5 0. 5 0
0.5
l
and letting t • 0 or 1 i.n B:Js . (6- 25) a.nd (6- 26) yields
P(O) = ~ (6-27a)
P(l) : 8 + 8 + 8 + 8 (6- 27b)
1 2 3 4
P ' (0) = B (6- 27c)
2
P' (1) = 8 + 2B + 38 (6-27d)
2 3 4
Writing Eqs. (6-27) i.n matrix fonn yields
SURF71CE OESCRIP'rim h.\10 GENF.:AAT!Gl 171
P(O)
P(l)
1· 0 0 0 1
1 1 1 1 83
rs4 (6-28)
p. (0) J 0 0 1 0 82
P' (1) 3 2 1 0 (J31
or
p.,. MB (6-29)
Solving~ . (6-29) for the coeffid ents, l.• .e . , !or B, yields
B !.f"lp (6-30}
-1
M = 2 -2 1 l (6-31)
-3 3 -2 -1
0 0 1 0
1 0 0 0
'lhis agrees with F.q. (5-22) . S\Dstituting F.q. (6-30) into F.q. (6- 25) tlnd re-
arranging yields
P(u) = F1 (u)P(O) + F2 (u)P(l) + F3 (u)P' (O) + F4 (u)P ' (l) (6- 32)
tioos along the edges where u"" 0 and u = 1 and than construct another surface
whidl will satisfy boundary cxmditions ala1g the edges where w = 0 and w ~ 1.
~ then carbine these results to obtain the bicubic patch.
\F\li
p (0,11 r 1CwJ j (6-36)
P(l,O) P(l,l) PO,l(l,O) ~O,l(l,l) f";> (wl
0 1
p-• co,OI P '°CO,ll rl.lCC',CH .,t,IIO,II Cw)
l
f
3
1
P '°Cl,O) P1 ' 0 (l,ll r 1 •1 c1,01 P1' 1 Cl,l) r 4 (w)
1
u-t.angcnt Twist
I
vectors 1 vectors
Table 6-1
Bounda!y Corxli.tion Inposee Constraints on
Surface Blending fUnctions
u =0 or w = 0 u = 1 or w = 1
•
Fl 1 0
F2 0 l
F3 0 0
F4 0 0
F' * 0 0
1
F' 0 0
2
F'3 l 0
F' 0 l
4
b
0
a t>
VU utll o n o r IOO f:e OI \ a rt <lllllfl ul IIIIIScnl
\'Cli<H ma,n uudc ~<Cllol dared tun
P0 .1(0.11
...-......
pO.I(O.Ol
[)
c
Ze ro I\\'"' a t C I 11\ II C ' " ' ' ' B l (
pected behavior occurs when inc:rerenting twist vectors . EquAl dlanges in all
twist vectors cause qJpOSi te surface beOOs at the (0 , 1) and (1 ,0) ex>rners
cmpared with the effect at the (0 , 0) and (1, 1} oorners . Thus, manipulating
the ~ts o f the P boundary ex>ndition matrix can be cxm.fusing.
An algorithm which will generate the bicl.lbic surface patch described by
F.q. (6- 37) is giwn in Appendix C.
z A
description . In all cases the tacit
as5\ltPti.on has been made that the neces-
sary mathematical infoxmaHoo such as
1
b. f1 nal tunc position, tangent, or 0.1.st vecton; or
blend.in; functicns is available. l:b..>-
Figure 6-11 Effect of change in ever , providing this infoorat.ion may be
end tangent vectors an
the bo\.l'daxy curve ext:.renely difficult for the user, espe-
shape. cially a nonmat:heiMtical or 11011-Caq:lUbeJ:-
oriented user. A mnber of sc:he!nes have been devised to overocJTra this di ffi-
culty . Prd:>ably the rrost S\ICQ?Ssful o f these is the extension of the Bezier
curve (cf Sec. 5-7) to surfaces (Ref. 6- 8) .
'lhc surface equation for a Bezier surface patch can be written in the
form of F.q . (6- 36) . Osing the biocmial rep~entatioo of a Bezier curve given
• in Sec. 5-7, the equation for a surfac::E patch with boundary CUI"VeS described
by four point Be-zier polygons, i.e . , a 4 x 4-point Be2ier s urface patch is
given by
3
P(u,w) = [(1 - u ) 3(1 - u) 2u 3(1 - u)u2 u 3)18) (l - w) 3
3(1 - w) ~
3(1 - w)w2
w3
8= ~( 1,1 )
8 (1, 2) B(l , 3) 8(1, 4)
8(2 ,1) 8(2 , 2) 8(2 , 3) 8(2,4)
8 (3 , 1) 8(3,2) 8(3,3) 8(3,4)
LB(4,1) 8(4,2) 8(4,3) 8 (4,4)
'lhe B-tcnsor is O::Cip::>scd of the position vectors of the defining polygon
points , as sho,..rn in Fig . 6-U . In the Bezier fornulation , only the oorner
points A, 8, C, and 0 octua..lly he en
the surface. Thc {X)int 8 , 2 dafines the
1
slope vector fran the first to the sec-
end p:>int on the first Bezier p:>l}'9XI in
the u-di.rection . The {X)int 8 , de.f.ines
2 1
the slope vector fran the first to the )
P(u,c )
1
~ 3
[(1- u ) 3 3(1- u) 2u 3(1 - u)u2 u ) P
1
(6-41)
p2
p3
p4
giws the e>cpressioo for a point oo tbe surface along the curve w .,. c1 . For
eadl value U1 F.q. (6-41) gives the oorresponding position 1.>ector for the point
on the surface.
The bol.lldary C\.IJ:'-~ for a Bezier surfaoo can be defined in an analogous
mar.ner to the Coons surface boundaries. In fact, a Bezier surface can be placed
within the family of generalized Coons surfaces described in sec . 6- U . For
exauple, aloog the boundary u = 0 1 0 ~ w ~ 1.0, the Bezier curve is
c = (51, 1' 52, 1 ' 53 , 1 1 84 111 (1 - w) 3 (6-42)
3(1 - w)Zw
3(1 - w)wl
w3
or alternately,
(6- 43)
z.
~
'Ihe Bezier boundacy curve for 0 ~ u ~ 1.0 1 w = 1. 0 is
c • [(1- u) 3 3(1 - u) 2u 3(1- u> 2 u3J 54 , 1 1 (6-46)
8
412
8
41 3
84 ,
'Ibe equations for the other two boUI".dal:y curves can be written directly 1 with
the aid of Fig . 6-12 .
It is saret.iJres desirable to create a surface patch that is rot described
by a square tensor. 'lhi.s can be used to al lo,.r sinple curves to be bounded by
• a couplex surface. As an exanple, the surface sho.m in Fig . 6-13 has three-
point Bezier curve boundaries along u • 0 and u =1. 0 and five-point Bezier
curve l:x::undaries along w ..., 0 and w • l. 0. The equation for the bo\.U'&ty along
w • 0 is given by
C e [(1- w) 2 2(1 - w)w w2J (6-47)
scalar funct:.ioo B
r,1. (u) . 'lbe e.r ,1• •s serve to blend the boundary oanditions
and/or boundary curves to fonn a surface.
The r subscr ipt indicates that the general blen:l.i.ng functioo is TNeig.hted
by a single-valued function representing a bourx1ary derivative of o.rder r .
For curves , r = 0; for tangent vectors , r = 1; and for curvature or twist vec-
tors, r ==- 2. 'I1le i subscript indicates the position on the unit l.ll.'-square of
the function bel.llCJ weighted by the sr,i . Here we assi.Ure that u = u
1 is inplied:
e . q .,
Forrest (~f . 6-10) has pointed out several properties of these blending func-
tions. If a patch is specified by boundary curves alone, then
f .(j) =6 ..
0, 1 lJ
~ Oij lS the Krooecker delta , i.e., 61 j ::. 1, l = j and 6ij • 0, i -,J j ·
As an exanpl e , recall the cquaticn describing the bilinear surface, i.e.,
182 M'M"HEMb.TICAL EUM:mS FOR CXl-1PtJI'ER GRAPHICS
~<~here the blendi.ng furx:tioos , i.e., the Bij ' s, cbey the relatioo.s
p
6 (B
r ,1. (u) 1 p
= Br , l.• (Uj) = 6
pr . 6l..j
\.F\1,
)
Thus
80 , 0 co> • 1 , 80 , 0 <1> - s0,0 co> - s0,0 cl> • o
s1 , 1 CO) = Bl,l (1) = Bl, l(O) = 0, Bl,l (1) a 1
catparisoo of F.qs. (6-55) and (6-56) with E):}s . (6-34) , (6-35) and r ecalling
D:j . (6- 33) shows that
3
(8 , Cu) & , 1 Cu) f\J,O(u) B , tu)J,. (u i u 1) 2-2 1 I • (F (u) F2 (u) P3 (u) F~ (u) J (6-57a)
00 0 11 1
-3 3 -2 -1
0 0 1 0
1 0 0 0
and
3 w2 w l)
(w 2 -2 1 1
-) ) -2 -1
0 0 1 0
1 0 0 0
'l\lrru.ng no.t to the bicubic surface patch itself, we see that ~. (6-36)
nay be written in the general notatioo as
l l 11 11 1 1
OCU,v ) .. L E pr 'OU ,w)ll • lui • L ~ PO,e(u,j)l!• •'"'' - L }' L L rr,all.)l r llul • J""' (6-58)
1-<l ,.0 r,. TO ~ •• l~ 1";1) roO ..0 ' '
0 o,l(i, j) • PO,l(i,j)
. ') -- pl , l(l.,
0 1 , 1(1.,) . J' )
ard aloog the boundary curves
O(i,w) = P(i,w)
Q(u,j) • P(u,j)
1,0(.1. W) -_ Pl'O(.l. W)
0 1 1
N:)tice that since r =1 here, normal derivatives can be satisfied across patch
boundaries to first order i.e. , bicubic patches may be joined with first order
CXI"'t.inuity acruss the boundaries.
Forrest (Ref . 6-ll) has sho.om that it is p:lSS.ible to generalize U1e Coons
surface descriptioo su::h that higher order bollndary cx:n:litians can be satisfied.
Assuning that we wish to satisfy nonml derivatives to order m oo u "'
1 llt and to
order n . oo w = wj , then the surface boundary curves are given by the functicns
pr, O(i,~) , with 0 ~ r ~m1 , and P0 ' 5 Cu,j) , with 0 ~ s ~nj , and the blending
funct.ioos by ar , .1.. Cu) and B . (w) .
s,J
The surface equation is then
1 .l 1 "1 1 l ., 01 6-59)
Q(u,wl • L
1o.()
~~
,:::()
r• 0 ct,w)llr
,1
(U) • L
~ ..
Lo 0 1
P ' Cu,jlf 11 , M-
,'
L 1:
E 1: riO()
110() }II()CP()
Pr'
8
(1.,)1&,. 1 cuHI8 M
, ,1
1 fi'i
PO , s(u, j) • L L pr , s(i,j)Br i (u)
i•O r=O '
then the last two t:ems of Eq. (6-59) cancel am the surface equatioo is
1 rn.1
r 0
o<u,w> = L: L:
i=O r=O
p , <l,w> a . <u>
r,l.
(6-61)
1 n.
Q(u,w) = E :f: PO, s(u, j)f;s
j ::{) s::::O I
J. (w) (6-62)
Ccmpilrison of Eq. (6-63) with Eq. (6-58) sho~~S that it is of a rrore limited
form. In particular, the bicubic surface patch described by Eq. (6-63) depends
only en oomer infoanation - positicn , tangent, and twist vectors , alalg with
the cubic blending functions to determine the interior shape of the patch . The
bicubic surface patch described by Eq . (6-58) a l so takes into acoc:unt the
boundary curves which outline the patch when det:e.rmi.ning the interior shape of
the surface patch. The bicubic surface patdl described by Eq. (6-58) is thus
rrore qeneral.
Notice thllt in Eq . (6-56) and its special cases, 5\.ITI'IUtion occurs for
i 0 and 1, j - 0 and 1, i.e., fran one boundary curve to the other. This
in'plies that the interior of the surface patch is govemee entirely by the boun-
dary CUl"V'Cs, oomer points , oomer tangent and twist wc:tors , and the blending
functi.cn. That is , the interior of the surface patch is controlled by the ex-
terior boundary conditions . lf, however, "'~ 5\.IITl flan 0 ~ i ~ M, 0 S.. j S.. N,
thr>...n all curves P(u ,w) and P(u,wj) between the boundary curves, and in fact any
1
SURFACE DEOCR.IPtiOO AND GENERATIOO 185
nox::mal derivatives on these curves, cs.ro accounted !or. '1hi.s a llows specifying
interior curves and bound!uy ccnditioos to assist in controlling the inter ~or
shape of the surface patch. In this case the surface is ~ represented by
w .,
1 n .,
0 u,w) •
"
E )~
1-o M
,.c. 0
(u1,VIt r •'"' •
•
~
IJ
)'<! ...0
l:
l 0
I" ,c (u,wjiO
.J
'wl -
w
o_.,
~
l.. L ) ~ [
"-<! .:;()
~
IMI
,,r,,l<l •" )
I ) r' &
•t
li •
."'1 (6-64)
and P(u.OI
(6-67)
This is a young and dynamic field with Figure 6-14 Exterior and interior
rte.J ideas and techniques cx:nstanUy "blended" surfaces.
appearinq in the literature.
To actually inplerrent these techniques in a production or desi gn environ-
rrent requires nany rrore considerations than can be discussed here. specific
requ.irerrents will depend \pln the needs of specific applicat.J.oos. Px001errs
such as jo.ininq surface patches, calculating cutter path offsets, determining
intersections of ll.nes ard surfaces, designing data and file structures in
\oohi.ch to store and r.-anipulate the infollt'ation , writing analysis programs to
calculate neoded paraneters, rEITOV:i.ng hi.ddE.>.n lines ard surfaces for proper
graphical dl.splay, etc . , are the types of requ.irerrents that will arise. Sere
solutions to these problem5 can be fo\D'd in the current c::atpUter-aided design
liau-ature. The reader of this book sOOuld be able to build upon the founda-
tion presented herein to create a capahil i ty to rreet his needs.
R£FERENCES
6-1 Bezier, P. E., E?tploi des Machines a Cunnande 1'.\Meri~, r.u.sson et Cie,
Paris, France, 1970; Bezier, P. E. , "Exanple of an Existing System in the
.t-btor !Mustry: 'lbe Un.isurf System," Proc. ~ - soc. (London) , Vol. A321,
pp. 207-218 , 1971.
6-2 Sabin, fot. A., "An Exi.sti.ng Systen in the Aircraft Industry. '1he British
Aircraft CO.rporatioo NumetiC31 M3st.er Geatetry Systan," Proc. !by. soc.
(Is:rdon), Vol. A321, pp. 197- 205, 1971.
6-3 Peau-s, G. J ., "Interactive Curputer GraJ;i'U.cs Applicatioo of the Bi-<::ubic
Pa.ranetric SUrface to Engineering Design Prob1ens," !-tD::nnel1 [):)uq1as
II Autatetion Conpany. St. Ionis , Ml.ssouri, presented at Society of Indus-
II
trial and Applied Mathematics 1973 National l'leet.ing, HMpton, va., 18-21
June 1973.
6-4 COons, S. A. , "'Surfaces for Cooputer-Aided Design of Space Forrrs, " t-1. I. T .
Project tW:, t-W:-TR-41, J une 1967. (Also as MJ 663 504) .
6-5 Annit, A. P. , "Curputer systems for Interactive Design of Thrce-Dimmsiona1
Shapes," Ph. D. Thesis, Carrbridqe University, NoveTber 1970.
6-6 Lee, T. M. P. , "Analysis of an Efficient liCl'togeneoUS Tensor Representatioo
of Surfaces for Catputer Display,• in Advanced Carputer Graphics. Edited
by Parslo..r, R. o. , and Green, R. E. , Plen\Jtl Press, New York, pp. lll9-ll41,
1971.
6-7 Ferguson, J. C. , "t-l.lltivariable CUrve Interpolation," J. Assoc. Cooprt:.
Mach., Vol. no. 2, pp. 221-2.2 8, April 1964.
6-8 Bezier, P., Numerical Control-fo'.athematics and Applications, (translated
by A. R. fbrrest), John Wiley & Sons, Inc., Laden, 1972.
SURFJICE DESCRIPTTQI1 1\.''-m GEl!ERATICN 187
COMPUTER GRAPHICS
SOFTWARE •
IP
lit
I~I
Ill taken. In general, the st.q?part catpUter is the system on \olhich the data base
exists and on which software manipulation of the data base occurs. However , in
•
~re syst:.ems this function rray be t:hysically split ootween tw::> or nore CXXJp..lter
systcns. 'Ihe gra[i\ics device is the hara..mre which actually produces the picture.
A concoptual view of a c:x:JTpUt.er graphics software system is sho.om in Fig . A- 1.
'1\.o sofb.ve systems produce an interface between the support oonput.er and
the graphics device. 'nle first is the data base manipulation software. 'llle
mathematical basis for this system is the topic of the main part of the book.
It consists of routines to translate, rotate, clip etc . ~ data base. Speci.fic
algoritms to perform nany of these functions occur later in Appendix c . 'Ibis
software system is mtpletely device-independent since it is only <XI'lCCrTled with
mathcm!ltical manipulations.
The scoond is a software system ~hlch provides an interface betweer. the
noiTI\ll "drawing functions" and the hardware associated with a particulnr graphics
device. It is this system which causes the neoessnry codes (infomatioo in
t:.erns of binary bits) to be sent to the grar:hics devioo to cause that ~ce to
CXMVl'ER GRAPHICS SOF'IWARE 189
draw lines, plot FOints, etc. Although as outlined in Sees. A- 1 cUrl A-2 t.Alw,
this software system can be made minimally devi.oe-<Jependcnt; it cannot be made
cocpletely dcvioe-~t.. Because of this Sees. A-1 and A-2 ally conocpt-
ually discuss this software system.
For sare gra~cs dev:Loes , particular nodes ZMY not be appropriate and for
others additional nojes are required. For the latter ease a particular exanple
might be a color CRI' graphics device ...mere blue, red, and yel.l.o,..r ll'Odes ~uld
also be regul.red . Ho.r.-ever, the above list represents those required for a
I
~ < > is used to represent optional variables. '1hc control variablP in CJIO'F
<XIllld be an integer with a 0 or 1, indicating that the. cursor is eit:.hc!r o ff or
oo respectively. 'lhe control variable in f-OE could be an int.eqer assiyned a
specific nean.inq, as indicated above in parenthes.is to the right of each indi-
vidual f\lJlCtion . These four graphics pr.iJnitives can be cutbined into ~al
cntpound graphic elcrrents which are of nnre intel:'est to the general user.
1-bve Absolute
1-blle Relative
Point Absolute
Point Relative
Draw Absolute
Draw Relative
In addition the user will want to b! able to print textual nnterial at a speci-
fied location in the picture , say,
Text Absolute
Text Relatl.ve
In each e-lse it is <:nlvenient to oonsidcr t:hbt the action initiates fmn
the current !X)Sit ion of the cursor. Functionally each o f these g:rcq:hlc elc:mmts
can be described in terms of grapuc primitives. For exanple 1 the t<love Absolute
algorithm might be
'The four relative coord..mate el.c:!rel\ts have the sare algoritl'ITsl except that the
tlu.rcl oc::mnarrl sets relative nrxk• ~mE 5) . Tho above algorit:tm; set each required
<nnvrER GHAPI!lCS SOF'!WARE 193
graphic primitive every t.iite it is used and loove the graphic device with t.he
cursor off and in alpha 11\'XE. 'lhis is good i.n.surana::. Hon1Cvcr 1 ilJl .increase in
the efficiency of data transmissicn can be achie~-d at the expense of ~
additi<na.l cattplc.xity. For exwplel the alqorithm for the Point J\bsolule cu:nmcl
might be
'lhi.s schere requires that a small storage b.lffer \o.hich oootains infonnaHon
representing the "state of the device" at the end of the previous graph1c OJIIm:md
exist. ~. the potential exists for reducing the nlll't:>er o! data stroam
e1emmts which nust be camunicated to the graphic device. Further, analysis
of the orlgin.:al algorit:lTn sl-oJs that if a rrethod can be devised to antic1patc
lo.hether the next camand will be a graphic c::cm'l\'md or a 110'\C]raphic (alphd) ca:~
mand, then addi ticnal efficiencies result. Before cmt.inu..in<.J it should be noted
that although functionally identical, these alqorith!1\s might be structurod
differently for different graphics devices .
Terminal or picture CCI'ltrol g:raphic elerents are associated w1.th initia 1iz-
ing the graphic device, erasing the screen for storage tube CRr graphics devices,
start.ing and ending frarres for refresh CRr graphic devices, and buffering the
data stream and on CXl01'TIClOO sendiJ'lg it to the graphics device . For exanple, the
graphic elerrents
Begin Fraire
~Buffer
could serve these purposes. runcti<nally, the Initialize the Oevicc cx:mnand
serves to set the default ccnditioos and zero the outpUt buffer; the Begin Fra!re
COII'and serves to erase the screen for storage tube CRl' grapuc devices , to
indicate a new plot for pen and ink devices, am to rotify a refresh grapuc
devioe that the picture is curplete and a new frmre nust be started. 'lbc 0\Ilp
Buffer CXX'I'ITland serves to send the stored data stream to the graPrics device and
leave the device in alpha rrode.
Fran the user ' s point of view the control of interactive devices rrust be
rrore explicit than a siiTple cx:rmand to read the cursor p:>sition . As discussed
in Sec. 1-5 there are several interactive gr<q:h.ic devices avail&>le. As a
mi.n.inun the input gnqiUc elesuents sOOuld include
'llle other graphic elenents would have simi..lar algorit:Nns. Again ec:cnanies in
the data strean can be obtained by using sq:histicated chedti.ng procedures for
Ill
the various nodes, etc .
•
A-3 CANoorCAL SPACe
(\. )') r
1024
area in one c:lim!nsioo , nost often the
vertical dinen.sion . In this case , the
rhi~ area may not be '•cwablc viewable area is assured to be 0 ~ Xv ~ 1.0
o ~ Yv ~ o.a.
780
-- and Further, llWlY ploLt.ers
have the ability to extend one axis in-
definitely. In this case the vi~'able
area is asS\.J'!9i to be 0 ~ Xv ~ a , where
a is SOli! nurber ...,hich is greater than
one. Q1e oould, of oourse, argue that the
addressable area slnl1.d then be rectangular.
HQJ...-ever, unless extrete care was taken
with scale factors , distortioo of gearet.ric
MATRIX OPERATIONS
•
I!
I
II
A few sirrple rules fran natrix algebra are given here for convenience. A
matr-i:t is si.nply a rectangular array of nurbers \llh.ich are governed by these
rules .
8-1 T~Itn.OGY
II
'Ihe array of nll'lbers \o."hich make up a natrix are called its elements . 'Ihese
elements form rows and oolum.s within a natrix. If the nl.ll'ber of rows and
ool ums are ogual, the matrix is cal l ed square.
COnsider the 4 x 4 square matrix given by
all ~2 8
13 ~4
~~2~3~4
a31 a32 a33 a34
a41 a42 a43 a44
'lbe first subscript refers to the natrix l"CM ard the second refers to the JTatr.ix
oolum. Thus, a 34 is the element in the thixd reM and fourth oolum. A natrix
of m l"CMS and n oohrm.s is cne of order m x n . In the square nstrix abo\.~ ,
m • nand the ele1ents '\!• ~ 2 , ~ ,
3 44 are called its dia./'r:at cl.<- Pttc .
and a
'lhe sun of the diagonal elements in a square natrix is called the trace .
'IATRlX OPEAATI<::I\'5 197
If b.Q matrices are of the sa~re order, then additioo and subtracb.on are
defined. To a&3 or substract tw:> matr.ia>s , the operation of addi t ioo o r sub-
tra ct.i.oo is applied to each o f the corres£Xlnding eletelts. As an e.xanple :
1 2 3 1 4 7 2 6 10
4 5 6 + 2 5 8 = 6 10 14
7 8 9 3 6 9 10 14 18
and
1 2 3 1 4 7 0 - 2 -4
4 5 6 - 2 5 8 = 2 0 -2
7 8 9 3 6 9 4 2 0
t-latrix n'lll.tiplication is the nost useful matrix cp"ra tioo for cnrputer
graphics . Consider one matrix of order n1 x m1 and a semnd rmtrix of order
n2 x "'2· For n'lll.tiplication of t:\<\0 matrices to be deflned, the value of "1 rrust
equal the value o f n • '111at is , the nllt'ber of co11.11V\S in the first natrix must
2
equal the nl.ll'b:!.r of rows in the second matrix.
'lhe rules for matrix nultiplicatioo are best described by the follCMi.ng
exanp1e. If [A] is a matrix of order 4 x 3 and [B) is a square matrix of order
3 x 3 , then the matrix prodoct (A] (B) is defined by the following op?ratial .
•u •u •u ~1 bll ~) ~~~• • ~t'n ' 4 1~1 ~lbll. 'l.P22 • •lf>ll •ubu • •1/>n • 4 lf'JJ
. 21 .,16 2J b21 b2l 1:.2]
~
·~1bu. • "2i'n • "2/'n -,lbU • a,_f7J -+ "J/>J~ •ubu • 'lt'll • •,fl33
"'ll on 6 )] l>ll bJl b)l ~l~l • •)-/>'ll • ~i>ll il11bu • •1i'22 • •rJ>u ~)lbll • 3 3ZD2J • 4 lJbJJ
•n •u 010
43 •c1~1 • •ct'7l • 0 ct>ll 6
clb17 • 0 cib22 • 4 cf>12 <~~c lbll • .ac:l'cJ • oc/>llj
Not.ice that a 4 x 3 matn.x !tl.ll tipl ied by a 3 x 3 matrix produces a .; x 3 Matn.x.
In general, a f1. x ~ n1trix U."':£S a ~ x ~ matn.x, "'here ttt = ~, produces a
'1. x 11'2 rratrix. l..s a nurerical exa:-ple , o::nsl.der
general, [A) (B] is rot equal to [BJ (A). Thus, the order (sequence) of mllti-
phcatlal 1.s izrpor...ant. Matrix operatior.s folla..r tt.e fust and second disc:i-
butive 18:'..'5; e.g., A(B + C) e N3 + 1C. and (A+ B)C • AC + a:. Also, t.~ asso-
ciative law A(OC) '"' (AB}C applies .
1
'Ihc det.en:'J.nant of a square rat:rix (A] l.S denoted by AI . 'lbe det.e.rrni.nant
has rrany useful properties in rratrix theocy . For our ~ . it 1.s suffic1.ent
to illustrate the nethod for find.inq the det.enninant of a 3 x 3 square rnatrix.
lf
M= r all en ~3 1
a21 a22 ~3
~1 a12 ~3
21 ~2
4 8
23
a31 a32 a33 !
6 1 81
12 5 3
'lhe result is
3(3 - 40) - 9(18 - 16) + 4(30 - 2}
= 3(- 37) - 9(2) + 4(28) a -17
1'11\TRIX OPEAATia~ 199
There are many techniques for cal culat.i.nq the inverse of a squara trotrix.
t10St catp.lt.er languages have fmct.ions or subrouunes "ni.ch will perform U1e
repetitive calculations necessary t:o evaluate the clCJI'Nlts of the inver$(. o f '
given matrix.
In algebra, where single variabl es are ccnsidered , if ax:. Y 1 then x "' a- 1J',
1
...nere a - 1 is s imply the reciprocal o f a, e . g ., a - • 1/a. In 1ratn.x al<)Cbr::ll,
divisioo is not defined arothe reciprocal of a matrix does not exist. Ho..IL~r,
if (A)(X) = (Y] 1 the [X) = [A ) -l[Y), where (A) -l , is called the inverse of tre
square matrix fA} •
A matrix inverse will exist i.f the matrix is square wid i f tho nntri.x is
noosingul.ar. 'Dlus, not every square IMtri.x has an inverse. l:bNever, if the
determinant of the square matrix is nonzero and an inverse exists , then that
inverse is unique.
'Ihe inportant property o f a matrix uwerse that is used 1n thi s book is
that, for any square matrix [A), the equal.J.ty (A] (A]-l = {I) is valid, where
[I) is the irlentity rratri.x.
Coosider the matrix product o f the G.o folla.t.i.ng 3 x 3 tMtrioes :
1 2 3
6 -2 -3 1 0 0
1 3 3
-1 1 0 • 0 1 0
2 4
-1 0 0 0 1
1
If this p.roduct is represented by £1\1 (B] = fil, then (Bl is equal to (AJ- •
APPENDIX C
DATA BASE
MA IPULATION •
ALGORITHMS
II
II
2DSCf..LE
100 SUB"2DSCALE": P, X() , Y() , A, O,S ' 2-D SCAlE
110 ' P:MJHBER OF X, Y-PAIRS
120 ' X():ARRAY CGNTAINING X-COOJIDINATES
130 ' Y{):AJIRAY CONTAINING X-COORDINATES
1 ~0 ' A:X STRETCHING FACTOR A>1 STRETCHES A<1 CONTRACTS
150 ' D:Y STRETCHING FACTOR D>l STRE'ICHES 0<1 CONTRACTS
160 ' S:OVERALL SCALING S< 1 fl~LARGES S> 1 REDUCES
170 DIM S(100, 3} ,Q(100 , 3) '100 POSITION VECTORS
180 II.AT S:ZER( P, 3) ' REDIMENSION S&C FILL WI~ ZEROS
190 ~~~T O:ZER(P, 3)
2CO FOR 1:1 TO P ' S£1' UP tn100ENEOUS
210 LET S(I , l }:X(l) I POSITICtJ VECTORS
220 Lei S(I , ~):Y(I)
230 LEi S(I , 3):1
240 NEXT I
250 HAT T:ZER(3, 3) 'RED!ME!\Siot~ 1 FILL WlTr ZEROS
26G LF.T T(1 , 1):A ' SET X STRETCHING FACTOR
270 LET T(2 ,2}:D ' SET Y STRETCHING FACTOR
280 LET T(3 , 3):S ' SE1' OVERALL SCAWKi
202 l'tl\niEMM'ICAL ELEMEl1I'S FOR a:l-lPlJTER GRAPHICS
2DREFLT
If
100 SUB"2DREFLT": P, X() , ¥ () ,N ' 2- D REFl£CTION
110 ' P:Ntt-!BER CF X,¥- PAIRS
120 1
X():ARRAY CONTAINING X-COORDINATES
130 ' Y():ARRAY CONTAINING ¥-COORDINATES
1 ~0 ' N=REFLECTION CODE 1=X-AXIS , 2:Y- AXIS
150 Om S( 100 ,3) ,Q(100,3) '1 00 POSITION VECTORS
160 HAT S:ZER( P, 3) 1 REDIHENSION S&Q FilL Wrni ZEROS
180 1
S:OVERALL SCALit:C S> 1 ENLARGES S<1 REDUCES
190 DIM U( 100, 4) ,V( 100 ,4 ) 1 100 POSITION VECTORS
3DXROT
100 SUB" 3DXR0'!": P, X( ) , Y() , Z() , Tl ' 3-D ROTATION ABOUT X- AXIS
110 ' P:~WM81:.R OF X, Y. Z- TRIPLETS
I~ 120 ' X():ARRAY CONTAI NING X-COORDINATES
130 ' Y():ARRAY CONTAINIKG I -COORDINATES
140 ' Z( ):ARRAY CONThlNit-.'G Z-COORDINATES
150 'Tl:ROTATION ANGLE IN ~GREES
160 DIM U( 100 , 4) , V( 100 , 4) '1 00 POSITION VECTORS
17C HAT t:ZER(P , 4) ' REDINENSlON U&V FILL WITH ZEROS
180 MAT V:ZER( P,4 )
190 FOR I=l TO P ' SET UP lO'.oGENEOUS
200 LET U( l , l ):X(l) ' POSITION VECTORS
210 LET U( I , 2):Y(l)
220 LET U(l , 3)=Z( l )
230 LET U( 1, 4): 1
240 t.EXT I
250 LET TZ:Tl/57 . 2957795 ' CONVERT TO RADIANS
260 ~~T T=ZER(4 , 4) ' REDIMENSION T FILL WITH ZEROS
270 LET T(l , 1):1(4,4 ): 1 ' SET UP TRANSFORMATION MATRIX
280 LET T(2 ,2) :T(3,3)=00S(T2)
290 LET T(2 , 3): SIN(T2)
300 LE~ T(3, 2):- T(2, 3)
310 ~~T V:U1 T ' CALC . TRANSFORMED POINTS
320 FOR 1=1 TO P ' CALC. PHYSICAL ODOR.
330 LET X(I):V(I , 1)
340 LET Y(I ):V{I, 2)
350 LET Z(l):V(I , 3)
360 NEXT I
370 SUBE.~D
The algorittln given below as a BASIC language sut:program p.rovides far three-
diJrensional rotation about the z-axis .
3DZROT
C-11 /'Jt4 Al.GORJlH"t FOO lt-REE-Dit-e4SIONAL ~TAT I ~ Ainrr Pt~v ARBI'TAARY Axis IN
SPACE
3£X;ENROT
100 SUE" 3DGEN~':P , X{) , Y() , Z() , Nl , N2 , N3,T1 ' 3-D GENEFAL ROTATION
11 0 ' P=~R OF X, Y, Z-TRIPLETS
120 ' X()=ARRAY CONTAllll~~ X-COORDINATES
130 ' Y():ARRAY CONTAltllt~ Y-cooRDlNATFS
1110 ' Z():ARRAY COt.TA!Nlt;(; Z-OOORDlNATES
150 ' N1:DIRECTION COSINE OF ROTATI~ AXIS W.R.T . X-DIRECTION
16G 1
;2:r-II<EC1ICN COSH<E C.f pJTATiot. ~.JIS w'. q . 1. Y- CI PECTICN
1
170 ti"':!;lfrECTIC~. ~l':E <F F"JTA:liY.• A.X!S W. P. ~. Z-!;IFECTIG!~
1
1BlJ Tl:P.OTAT!C~. I..!.'Cl.E 11 IZ;PEE:
19~ o1u uct~ . ~>.vc · c~ ,~ ~ ' lOG f":.>.'"IT!UN VECTOPS
2r P~T L: ZE?(f , ~) ' FEDIY.E'lSlGtl ~'J FILL '.OITH ZEfiOS
21~ P~T V:ZEF.(r l 4)
nr FOr I= 1 ro P
2Y LET UCl 1 l):Y.(I)
2~0 LF: UCI , 2):Y(I)
~5r ~-r U(I , 7 ):Z(I)
2£0 LE1 Ull,~J:l
nr t-."EYT 1
2er I'J 7 T:ZEP( I. , u) ' ?EC:P.I.f1,!:IC'! 1 fill \HI'!" ZE.~S
?jC LI='T T2:T11!:7 .29':,7795 ' a;!NEF.l Tl TO RAtlANS
30" Lf.T 1(4,4):1 · ~r:; UP Tr·ANSFCF ~.ATlO~: ".ATPIY
;,r l.E7 TC 1 1 • J :~;l • ',l+( ,-t.1 1 fol} 1 COSC12J
~2G lEI' 1( 1 ,2) :Nl • t;2 1 ( l-COS(T2) J•'f» !:;IN(T2)
3')f' LE1' 1( 1, 3J=~i1 1 1·3 1 C 1- COHT2) )- 1~~ "'1!.(1'2 )
3140 Lf.T 1(2 1 1):•,1 1 !.2 1 ( 1 -CGS(T2)H\3- :.It~(T2l
"'SG LET TC 2 ,2) :'.2 1 1.2+( 1-t.~• t;2) 1 COSCT2)
3~0 LI='T T(2, ;):t.c•:;··•( 1 -CUSCT?J> + ~:t • Sll.(T2)
37r LET rc3, '>=~l ' N!' <t-ecsl~),.~;i?' sr.cr2J
t 3e('l LE!' r(3,2>=~f'IN:~ · c t-ccs<u»-•·t•sn.cr?>
;r;,o ti.T TO, ~):~;~ • •(;( 1-!.!1 'l!J 1 CVSCT2 )
llQt W,T V:U 11 ' ':I.LC. TFM;:FOf"EC FC!t\TS
~tr FOr 1:1 T~ r ' C~LC. fP.Y~IC~L coo~.
1,2f' LET Y( 1 ):V( I I 1)
~~G LET l(l):V(l , 2)
~uo LET Z(I):~(I,!)
I< 50 t.'EY.T 1
J~ f.O suwm
PFGJ
lif. ..UE:"HCJ" : P, Y.(), Y( J , Z{) 1 t1 ' I'FOJE.CTIOtl
11C •r-=r:uveEP or x, YI z- TRIPL'!S
12C ' Y( ):AP~AY CGtm,H\HC Y-COORDINATES
1~" ' Y( ):APPAY CCI;TAININC Y- COJFCINATES
lt:C ' l( ):APf<AY CCNTI.lNir.C z-cOOFDINATE.S
1SC ·~. : CCir..E ~l...11H .R r:;IJICATI':C PEFPEl:CICIJLAR liYIS:
lG~ ' 1=Y-AY1S, 2=Y- AYIS , "'=Z-AXIS
17C DIP U( 1CC , ll) , V( 100 , q J ' 100 POCITICI: VECTCPS
1
1H t'.Al U:ZE.P{r , 4) PECI,.,~;SI0.'• U~\' FILL \.ITH ZEFOS
i~ t'~T 'J=ZE~(P,4)
2r' FCF I= 1 Th P ' SET UP ~~E.'~ctiS
21~ L£: UC: , l):X(J) ' ?r~!TIO\ VEC7C~S
nr 1..£7" uc , l' J='f CI J
2~0 LET U(1 , 3}=ZC!)
2~r LE7 Uf! , ~):l
2Sr Pt'E>'T I
?'f 111\l T:ll~(IJ,t) · ~EDl"~PlSICti T Fill IOI'ni ZETtOS
270 LET T(1,1):T(2 ,2)=1 ' PUT 1' S 00 AlL Ot A ELF-Y.ENTS
280 LET T(3,3):T(~ , Q):1
290 IF N= 3 THEN 350 ' SET APPOOPRIATE DIAOOt~AL TERt1:0
300 IF N:2 THEtl 330
310 LET T(1 ,1 ):0
320 00 TO 360
330 LET T(2,2):0
3110 rn TO 360
350 LET T(3 , 3): 0
360 ..-.AT V=U•T ' CALC. TPAt:SFOFME'D POI NTS
370 FOR 1:1 TO P ' CALC. P~YS!CAL ODOR .
380 LET X(I):V(l,l)
390 LET Y(l):V(I, 2)
QOO LET Z(I):V(1,3)
410 NEXT I
1120 SUBENO
tive project.icns, say, tw:> fh:::>togxafi\5, \orilen the natrix transfOll'IVltion e.l.elrents
are known is given bela.~ as a BASIC language sutprogxam. It is based Q'l Elg.
(3-48) .
3DRECON1
100 SUB"3DRECON 1":T( , ) ,S( , ),X1 ,Y1,X2 ,Y2,X(, ) ' 3-D RECONSTRUCTION-I
110 ' T(, ):4• 1l TRANSFORMATION ~lATRIX FOR THE FIRST VIEW
120 ' S( , ):tl1 4 TRANSFO~ATION mTRIX FOR THE SEX:OND VIEW
130 'X1 , Y1:000RD1NATES OF POINT IN FIRST VIEW
140 'X2,Y2=000RDINATES OF POINT IN SECOND VIEW
150 DIM A( 4, 3) ,B(4 ,t ) ,C( 3, 4) , D(3 , 3) , E(3,3) , Y(3 , 1)
160 ~AT X=ZER( 3,1 ) ' FILL X-MATRIX-WITH ZEROS
170 FOR J: 1 TO 3 ' FIND POOJEX:'TIOt~ PLANE
180 FOR I: 1 TO tl ' IN T-t".ATRlX
190 IF' T(l,J)<>O niEN 220
200 NEXT I
2 10 00 TO 250
220 NEXT J
230 PRINT "TRANS T IS rm A PROJECTION"
240 00 TO 660
250 ON J 00 TO 260 , 290 , 320 'ELIMl~ATE 0-COL~J
260 LET I 1=2 I FR(Xo1 EOOATIONS
270 LET 12=3
280 GO TO 340
290 LET 11:1
300 LET I2=3
310 ac m 3110
320 LE1' 11:1
330 LET 12:2
3il0 FOR J=l TO 3 'F'IND PAOJE'CTION PLAr.E
350 FOR I: 1 TO ll ' IN s-f".ATRIX
360 IF S(I , J)<>O TPEN 390
370 NEXT I
380 GO TO 420 •
390 NEXT J
400 PR!tii "TFANS S IS NOT A PROJECTION"
1;10 ro ro 660
420 Oll J GO TO II 30, 460, 49C- ' ELit'IMTE D-COLl11 N
430 LET J1:2 ' f'PO~l EctJATIONS
IIIJO LET J2=3
450 GO TC 510
IJ6C LET Jl: 1 •
470 l-...t'T J2::3
460 CO TO 510
490 LET J1:1
500 LET J2=2
I 510 FOR 1:1 TO 3 ' SET UP A-fo'ATRlX
520 LET A(1,I):T(I,I1) - T(I,4) X1
1
530 LET A(2,I):T(I,I2)-T(I,4) 1 Y1
540 l-~ A(3,I)~S(I,Jl)-5(I,4) • X2
550 LET A(4,l):S(I,J2) -S( I, 4) 1 Y2
560 h"EXTI
570 l-~ E(1,1):T(IJ,4)'X1-T(4 , 11) ' SET UP P-1-'.ATfiiX
580 LET E(2,1):T(Il,li) 1 Y1-T(IJ , I2)
590 LET e(3,1):S(4 ,4 )1 X2-S(4,J1)
600 LET 8(11,1):S(4,1J) ' Y2-S(4 ,J2)
610 ~AT C::TRN(A) 'TRANSPOSE' A
620 ~:ATRIX D::C1 A ' fORM SC ('IATfllX FRO~ A & lT' S ~ANSPCSE
610
• fJ.AT E:li\V(C) ' INVE~T SCOARE VATRIX
640 fo'AT Y:C1 E ' FORM A TRANSPOSE • E
650 ~:AT Y.=E'Y '08TA IN SOLUT!Ot.
660 SUEElJO
3DF£CON2
1C<> SlJ8"30REX:ON2" :X(,) , ll( , ) , TC , ) '3-D RECONSTRUCT!Oti- 2
110 'X( , ):61 3 fo'ATIHX COIITA~lt.G n!E LOCATIO.\S Of' nzE SIX POif.liS
120 ' lN PHYSICAL OOORDI~ATES I~ ORDER
130 ' U( , ):6• 2 ~ATRIX COUTAINING WE LCCATIOt,S Of' TilE SA:-'E SIX
140 ' POH:I'S IN 1liE PEPSPECTI\'E VIEW I~ nzE SAt--E OROEP
150 'T( , ) :TJJE ll• 4 TPAt~F'OR."'.ATlON HATfllX
160 DDI. A( 12 , 12) , 8 ( 11 , 1l ) , C( 11 , 1) , D( 11, 1) , E( 11 , 11 )
170 MAT T::ZER(4 ,ll ) ' FILL T&A ~ATRICES ~ ZEPOS
180 MAT A=ZER( 12,12)
190 FOR 1=1 TO 12 STEP 2 ' SET UP A~.ATPIX
200 LET J=J+l
210 LET A(I , 1):A{l+1, ?):X(J , 1)
220 LET A(I,4):A{I+1 , 5):X(J, 2)
230 LET A(I , 7):A(I+1,8):X(J,3)
240 LET A(I , 10):A(l+1,11 ):1
250 LET A(l , 12):U(J,1 )
260 LET A(I+1 , 12):U(J , 2)
210 LET A(l , 3)=-X(J, 1) 1 U(J ,1 )
280 LET A(l+1 , 3)=-X(J , 1) 1 U(J , 2)
290 LET A(I , 6) : - X(J, 2) 1 U(J ,1 )
300 LET A(I+1,6):- X(J,2) 1 U(J,2)
)10 LET A(I , 9):-X(J, 3) 1 U(J , 1)
320 LET A(l+1 1 9):-X(J , 3) 1 U(J,2)
330 NEXT I
340 FOR 1=1 TO 11 ' SET UP P.&C t'.ATRICFS
350 FOR J:l TO 11 ' FOR~ e-~ATP.IX
360 LET B(l ,J ):A(I,J)
370 h"EXT J
380 LET C(I , 1):A(l,12) ' fORM C~ATRIX
390 NEXT I
400 MAT E:lNV(8) 'CALC. TRANS. ~~TRIX
410 MAT D=E*C
420 LET T(1 , 1):D(1 , 1)
430 LET T(1 , 2):D(2 , 1)
440 LET T(1,4):D(3,1)
450 LET T(2, 1):0(4 , 1)
460 LET T(2 , 2): D(5 ,1 )
470 LET T(2, 4):D(6,1 )
480 LET T(3,1): 0(7 , 1)
490 LET T(3 , 2):D(8,1)
500 LET T(3 , 4):0(9,1 )
510 LET T(4 , 1) : D(10 , 1)
520 LET T(4 , 2):D(11,1 )
530 LET T(4 , 4):1
540 SUBEND
An algorithm to generate a stereo pair for an abject ....nich has been posi-
tiooed and rotated to fonn the desired view and perspective is given bel.c7.ol as
a 81\SIC language subprogram.
STEREO
PAf\A80L.A
100 SUE" PAIW30I..An :A, PI, N,X () , Y(} ' PARA."ETRlC PARAOOU.
110 ' A:VlSTAtiCE FRCJ1 FOCUS TO VERTEX OF P~ABQLf,
120 ' Pl:I~.AXll-lUM ANGLE (DEGREES) (CF. EO. ~-45 OR 11-116)
130 ' N: Mlt'.SER Of POINTS ON PARABOLA
140 ' X():ARRAY CONTAlNII."C WE X-COORDINATES CF POINTS Cf: PAFAfCLA
150 ' Y():ARRAY COt-'TAlNlt.:c TilE Y-COORDINATES OF f>ClriTS Ct, PARAECLA
160 LET P:P1/((N-1 ) 1 57 . 295)7795) ' CALC. l~CREY.E~T IN THF.TA
170 LET X( 1): 0 ' INITIALIZE
180 LET Y( l )=O
190 LET Al:A*P*P
200 LC~ B1:2*A*P
210 FOR ~·=z TO N ' ll!t!ER LOOP
220 LET X(~I):Al+X(M-l)+P*Y(N-1)
230 LET Y(M):Bl+Y(I'.-1 )
240 NEYT M
250 SUBEND
l1YPE.I1b 1
Sec. 4-10. '1his alcprithn yields the port.ial of the hypcrlx>la in the first
quadrant. 'lbe port:.i.als in the other quadrants or nonorigin-oentered hyperlx»as
can be obtained by appropriate .rotation, reflect..i.oo, and translatioo operations .
HYPERE.2
100 Sub"hYPERB2" :A , B,C,N,X(), Y() • PAJWIETI\IC HYPEf\BOLA
110 'A::DISTMICE fRGI CE~'TER OF HYPERECLA TO VERTEX
120 •&:DETtRHI~ES SLOPE fO ASYM~ES=+-B/A
130 ' C::LltUT OF X-COOi1D:U ATE
140 ' lY::Ml-lEEk Of POlhTS CU HYFERBOLA
150 ' X():ARRAY CON1AINI~G
X-COORDINATES OF POINTS ON HYPEI\BOLA
160 ' Y():ARkAY CONTAlNH.C Y-CC<JRDINATES Of POINTS Ot\ HYPERBOLA
170 LET P2:(A+C)/A ' CALC. PARAMETE!i ItCftEliDtr
180 LET P1::((LOG( 1+P2)/LOG(10))- (LOG(P2-1)/LGG(10)))/(2*(K-1 ))
190 LET C2:(EXP(Pl)+EXP(-P1 ))/2 •CALC . GOSH P1 -
200 LtT S2:(eXP(~1) -EXP( -P1 ))/2 ' CALC . S:U1H Pl
210 LET X(l)::A ' lNITlALIZE
,
I
220
230
2110
LET Y(l)::O
FOn M=2 TO t. ' lJ:t,EJi LOOP
U.T X(M):Ci_>aX(M-1)+(A/E)*S2*Y(N- 1)
I 250 LET Y(M):(b/A) *S2*X{M-l )+C2*Y (~~1)
260 t.£XT M
270 SUBE!\L
I( 3PClhAkC
It
li
If
100 SUE"3PCIRARC" : X(),Y() , t- , H,K, R,S(),T() 'ARC ntRU THREE POINTS
II 110 I X(). Y( ):COORDINATES Cf THfiEi POll\'TS
120 ' N::NW.BER OF STRAlChT UNES TO REPRESENT ARC
130 I H' K::); . ¥- COORDINATES Gf CEt'fTER ( RETURf,ED)
An algorithn for generatin<J cubic spline fitsto n lax:Jwn data r;oints with
various end bounda.ry cxnlitioos is given belCM as a 81\SIC language subpX'OgUim.
'1be algorithm calculates the paran-eter range based upon chord di.stance between
II data r;oints rather than usi.nq noonalized splines .
I SPUhE
180 'll:AJITICYCI..IC
190 ' C2:Fit.AL E~D OONDITION
200 '!:RELAXED
210 ' 2:CLAMPED
220 · ~mE: IF A CYCLIC OR AA'TICYCUC TIIITIAL EllD CONDITION
230 ' IS SPECIFIED TI!F FINAL EJJD CONDITION IS ALSO SPECIFIED
21l0 'N(,):MltiZEliO El.FI~ ENTS OF M-t-'..ATRIX, SEE EX). (5-33)
250 'f~ MUST HAVE Dlf'ltflSSIONS OF ( N, 2) OR 01 , 3)
260 ' 8( , ):ELEMENTS OF B-11ATRIX , Sfl: EO. (5-33)
270 ' B ~lUST HAVE Dll'l.ENSIONS OF (2 ,N) OR (3 ,N )
2b0 ' l():SPAN CHORD LENGTiiS
290 ' L ~11JST HAVE DlJffiNSIORS OF ( N- 1)
300 ' Z.:tru'~BER CF IrrTEf\f1.EDIATE FQHITS PER SPAN
310 ' U( , );;ELEI".EtJTS IN TANGENT VECTOR MATRIX , SEE EO. (5-33)
320 'U MUST HAVE D~NSIOtlS OF (2 ,N ) FOR 2-D AND (3 , N) FOR 3- D
330 'U( 1, ):X-COMPQt,J:lrr
31.0 'U(2, ):Y-COOPOt~Etrr
350 'U(3 , ):Z-COMPOl f.l,T IF APPROPRIATE
360 'f.oTE: IF CLAMPED El\0 CONDITIOt-JS ARE SPECIFIED
370 ' 1FFJ~ 11fF VALUES FOR TilE TANGFUT VJ:X:TORS FOR
380 'lliE fiRST ao Cl>tiDITION tiUST EE IN U( 1 , 1), U( 2 , 1), U( 3 , 1)
390 ' AIJD FOR WE LAST El~D COliDITiotJ IN U( 1,tl), U(2 , N}, U('3 , N)
!IOO ' C( , ):ARRAY rorrrAINnx; GEltERATED FQlllTS Al..Of<G CURVE
ll10 ' C 1-'UST Hf..VE D111EriSIONS OF (2,P~+(N- 1) • Z} OR (3 ,N+(t-1-1)•Z )
!120 ' C( 1, ):X-eot-'POf.o"Ef,T
1130 •c ( 2 , ) : y-cot-'.POfJ-..1rT
!;llO ' C(3 , ):Z-COt-'FOf!ENT IF APPPOPRlATE
ll50 LET Z=Z+1 'ADD a\E TO 00. INTE!lMEDIATE POINTS
ll60 IF C1 >2 THEN 560
ll70 ' GENERATE OiORD L.ENGn1S AND El.rnEt-.TS IN B-,u-, At..n 1"-t'ATRICES
l!8o ' \t.'HIOI DEPEt.D l1POl\ Th"E SPa:IFIED El>L rotUHTIOt~S.
ll90 CALL" EhDP~T": S ,N,P ( , ) ,N(,), H( , ) , L(),Z,U(,),C1 , C2
500 'D~.PLEME~i GAUSSIAN EllMINATION TO S)LVE FOR WE
510 ' U"1<l~C7tt"h TAPliEtlT VECJ'ORS.
520 CALL" CAUSS" : S IN , P( I) ,N( ' ) , E( , ) ' LO , U( ,)
530 co ro sao
51l0 'INVERT ~:ATIUX M AltO SOLVE FOR m;K~tl TANGEUT \lECTOR ~IATF!IY U.
550 ' (CYCLIC AND ANTICYCLIC SPLThES ONLY)
560 CALL''MATINV": S , N, P( , ) ,N(,), I1(,),L() , U(,),C1,Z
570 ' GENERATE ll!E POl US Clf TliE SPUUE CURVE
580 CALL"CURGEN":S , .. ,P( 1 ) ,L() , Z, U( , ) , C( , )
590 SUBEND
600 SUB"Et.DPNT'' :S, N, P( I ) ~ ~< ' ) , B( ' ) ,I..() IZ , U( I) ,C1 ,C2
6 10 lF C1: 1 THEN 680
620 LET N(1,2):1 ' FIRST POW OF t'-~ATRIX
630 LET N( 1,3):0 ' FOR CLAMPED INITIAL fllD COIJDlTlotl
61lO FOR K:l TO S
650 LET B(K 1 1):U(K ,1 ) ' SET B(K, l):U(K,l) FOF CL»1PF.D END
660 NEXT K
670 GO TO 700
680 LET M1 , 2) =1 'FIRST ROW Of t-1-MATRIX
690 LET tl( 11 3) : . 5 ' FOR PELAXEC D;D CO"DITIOI~
700 FOR J:l TO N-1
710 lF C):3 THEt 760
720 ' CALCULATE TliE 2- D SPAN CEORD l..EttcniS
730 LET L(J ):SCR((P( 1,J+1)- P( 1,J)).2+(P(2,J+1 )- P(2,J))-2)
71lO GO TO 770
750 ' CALCULATE iliE 3- D SPAN CHORD LEtm-P.S
760 LET L(J)=SCR((P( 1,J+1 )- P( 1,J))-2+(P(2,J+1 )-P(2,J)).2+(P(3 ,J+ 1)- P(3 ,J))-2)
770 NEXT J
7&> IF C1:2 THEN 820
790 FOR K:!l TO S ' SET B( K, 1) FOR RELAXED END
8oo LET B(K , 1):(3/(21 L(1)))• (P(K ,2)- P(K,1))
8 10 NEXT K
fl20 IF C2: t TH~ 890
830 LET ~(N , 1):0 ' LAST RO',J OF t-1-MATRU
840 LET N(N, 2): 1 ' FOF CLAl-lPED FINAL DJD CONDITION
850 FOR K:l TO S
860 LET S(K , t~):U(K , t-t) ' SET E(K,N):U(K , N) FOR CL.Afo'PED EJ.ID
870 NEXT K
880 GO TO 9ijO
890 LET N(N ,1):2 ' LAST ROW OF 11-MATJU)(
900 LET N(N 1 2):1l ' FOR RELAXFD END CONDITION
910 FOR K:1 TO S ' SET B(K ,N) FOR RELAXED END
920 LET B(K , N):(6/l.(t\-1)) 1 (P(K , N)-P(K , N-1})
930 NEXT K
940 SUBEND
950 SUB"CAUSS": S, t, , P ( , ) , ~ ( , ) , f( , ) , L() , U( , )
960 FOR J:2 TO N-1
970 LET N(J,l}:L(J) ' CREATE t.()t\ZERO VALUES FOR
980 L.ET N( J , 2):2i'( L(J)+L(J- l)) 'ltiTERNAL RO\t.'S CF ~1-!·'ATRIX
990 LET ti(J , 3):L(J- 1)
1000 FOil K= 1 TO S ' CREATE flOWS 2 nillOUGH r.- 1 OF P41ATJHX
1010 LET B(K , J)=3• (L(J-1)~2' (P(K,J+1) -P(K,J)) +L (J)-?'(P(K , J)-P(K , J- 1 )))
1020 LET B(K ,J):B(K ,J)/(L(J)*L(J- 1))
1030 ~~T K
l OllO NFXT J
1050 ' THE FOU.<J"ll~j I S TilE GAUSSIAN El.II-~ThATION ,
1060 FOR 1:2 TO ~
107C IF ft( 1 , 1) :0 TrEN 118C ' ll>PHALIZ£'
1o.80 l..E'T ():?~(1- 1 , 2)/1;(1 , 1)
1090 FOR K: 1 TO 3
1100 LET MI,I<):N(I , IO*C-N(l- 1,K+1) ' RE'DUCE
1110 L-~ B(K ,I):B( K , I) • C-8(~,1- 1)
1120 t~XT K
1130 LET C:N(l,2} •
1140 FOR K: 1 TO 3
1150 LET ~{I,K}:N(l , K}/C ' t.OR~1ALIZF
1160 LET B(K , l):B(K,l}/C
1170 NEXT K
1180 tiEXT I
1190 FOR K: 1 iO S ' SOL\'f FOR UNKtl>\iN TA~ENT VECTORS
1200 FOR J:O TO N- 1
1210 LET U(I< , ~-J):{B( K, t•- J)- N( ~-J , 3) 1 U(K , Jl+ 1- J) )/N(N- J , 2)
1220 NEXT J
1230 NEXT K
1240 SUBEND
1250 SUB"CUflCEN":S,N , P(,) , L() , Z, U( , ) , C( , )
1260 LET 1:1
1270 FOP J:1 TO N- 1
1280 FOR K: 1 TO S ' SOLVE FOR n'E FOUR CUEIC SPLD;t: COEFF .
1290 LET F{1 1 K):P(K,J)
1300 LET F(2,K):U(K , J)
131 0 LET F(3 ,K): (3/L(J)A2) 1 (P(K , J+1)- P(K , J})- ( 1/L(J)} • (U(K , J+ 1)+2*u(K , J))
1320 LET F(4 , K}:( - 2/L(J}-3)*(P(K,J+1)-P(K 1 J))+( l/L(J)-2) *(G( K1 J+1) +U( K1 J))
1330 t.EXT K
1340 FOR T:O TO L(J) STEP L(J)/Z
1350 IF J: 1 THEN 1380
1360 IF T<>O THEN 1380
1370 GO TO 1490
1380 FOP K: 1 TO S ' CALC. POI.trTS ALOI~ COEIC SPlliE
1390 LET R(K):F{1,K)+F(2 , K) 1i+F(3 , K) ~ (T-2) +F(4 , K) ' (T-3)
1400 NEXT K
1410 IF S=3 THE~ 1450
1420 LET C( l,I}:R( 1) ' CREATE C( , } MATRIX OF RESULTS
1L30 LET C(2 , I):R{2)
1illl0 GO TO 1480
1450 LET C(1 1 I):R(1)
1460 LET C(2,l):P(2)
1470 LET C(3,I):R(3)
111~0 LET 1=1+1
1490 h!XT T
1500 NEXT J
15 10 SUBEJ.'D
1520 SUB"!oC.ATit•V":S , N,PC , >IN<,> ,o< I>,L( >,u( I> ,c1 , z
1530 Dltl. t{(70 ,70) ,C(70) , V(70 , 70) ,W(70 ) ' DIYENSION WTE11NAL JJ.ATRICFS
1540 ti.AT f-': ZER(N- 11 tl- 1) ' l1UTIALIZE AND ~EDIHHiS!Otl
1550 MAT C:ZER(N-1) ' EACH INTERNAL t'.ATRIY
1560 MAT \or:ZER(f,- 1}
1570 HAT V:ZERO.-l , tl- 1)
1560 FOF J:l TO ~1 ' CALC. SPAt; CHORD W~TPS
1590 IF S=3 THE'N 1620
1600 LE·r L(J)=SCIR( ( £-{ 1 ,J + 1) - P( 1 1 J}) -2+( P( 2 ,J• 1)- P{2 , J )) - 2)
1610 OG TO 1630
1620 LfT L(J):SCR((F(1 1 J+l) -P( 1, J))-2+(P(2 , J+ l} -P(2 , J })-2+(P( 3 , J+1) - P(~ , J ))-2 )
1630 t.'EXT J
1640 LET S):L(N- 1)/L( 1)
1650 If' Cl : 4 TBEN 1730
1660 U:T f" ( l , 1):2+?*S3 ' FIRST RO" Of fi-~ATRU
1670 LET H( I , 2):S3 ' FOR CYCLIC SPLINE
1680 L...!:i 1·:( I , t~ l): 1
1690 FOR I<: l TO S ' SET B(f , 1) f'U~ CYrUC Sf-Llt.F.
1700 LET S(K, 1) :(3/L(l)) * (S3 1 (P(K,2)-P(K,1))+(1/S~)t(p(r,,N)-P(Y. N-1)))
1710 NEXT I< '
1720 GO TO 1800
1730 LET P( 1, 1)=2+2*S3 ' fifiST POll OF t'~IATfflY
1740 l.FT ~( 1, 2):53 ' FOR AUTICYCLIC Sf'LltlF.
1750 LET M( 1 , t,-1 ):-1
1760 FOR K=1 TO S ' SET E{K ,l) FOR ANTICYCLIC SPLH•f
1770 LET B(K , 1 ):(3/L(1)) 1 (S3 1 (P(K , 2)-P(K,1))-(1/S3)'(P(K,N)-P(~,N-1)))
1780 NeXT K
1790 I
PARBLEND
lin alqoritl'ln which Will generate BezJ.er curve segronts is given belo.t as
a BASIC language subprogram. It is based oo the discussioo of Sec. 5-7 .
BEZIER
Algorithms "'hlch will generate the required B-splinc basis knot vectors
and &-spline curves are given bela.~ as BASIC l.ar¥Juage s\bcrograms . 1lley are
Msed oo tOO di.scussion of Sec. S-8 . Note that tha subprogram B-spl 1ne CAlls
1<1\'01'. 'nlc 5\.bprog:ram a-spline uses the Cox and de Boor algorithm to generate
the a-spl ine curves o r various order.
PSPLINE
________________________________________.....
C-28 fw AlroRlnt'l FOR A Blllt£AR ~ACE PATOi
BlUNEAf,
100 SUB"BIUNEAR":N , ~I , P( ,),0( , ) ' BILINEAR SURFACF
110 ' N:N~IBER (F IhCRFJIDiTS Of U
120 ' t-::N\n'IBER Cf' ThCRf.MENTS (F W
130 'P(, )=CO~TAHIS THE COORDINATES OF n!E OORNER POitfTS
140 ' P HAS DIY.ENSIONS Of 11 1 3. FIRST COlJ».'N OOIITAINS X-
150 ' COI~PONENTS , SECOND Y-<:Ot-'.PONENTS , THIRD Z-cQI-'.PONENTS
160 ' OF THE CORNER POSITION VEX:TORS. •
170 ' 0( , ):CONTAINS THE COORDINATES OF n!E UfTERPOl.AttD SURfACE
180 ' C WlLL HAVE DIHE~SIONS Of (H+1HN+1) 1 3
190 ' TiiE FIRST 11+1 COORDINATE PAIRS COIIRESPOtiD TO U:O: CONSTANT
200 ' THE SECOtiO M+l COORDINATE PAIRS CORRESPOND TO U:l/N:COtJSTANT
210 ' THIRD M+1 COORDINATE PADS COIIRESPOND TO U:2/N:CONSTAN-T
220 ' NOTE: 0 MUST BE DD'.ENSIONED I N DRIVER PROORAP
230 MAT O=ZER((N+l)*(M+1) , 3) ' J\EDIMENS!Otl C & FILL WI'nl ZEitOS
2110 FOR 1:1 TO N+l ' SET UP U:CONSTANT LOOP
250 LET U:(I- 1 )/(t~) 'CALC. INCREMENT FOR U
260 FOR J: 1 TO M+ t ' SET UP ~ LOOP
270 LET !<:K+ 1 ' 1~1CREMEh1' POINT CCUlnER
280 LET W:(J-1 )/M ' SET W
290 LET Q(K , l ):P(1 , 1) 1 {1- U) 1 {1-W)+P{2,1 )*{1- U) 1 W+P(3 ,1 )*U*(1-W)
300 LET C(K, 1):C(K,l}+P(4,1) 1 U1 W ' CALC. X- ca-PONENT
310 LET O(K , 2}:P(1 , 2} 1 (1-u) 1 ( 1-W) +P(2 , 2) * ( 1-U) 1 W.P(~,2)'U*(1-W)
320 LET 0(K , 2):Q(K , 2}+P(4 ,2) 1 U1 W ' CALC. Y-CCl·lPONENT
330 LET O(K , 3}: P(1 , 3) 1 (1- U) *( 1-W}+P{2,3 )1 (1-U}1 W+P(3 , 3) 1 U1 ( 1-W}
3q0 LET O(K, 3):Q(K , 3}+P{4 , 3)' U1 W ' CALC. Z-~PONE~T
350 NEXT J
360 NEXT 1
370 SUBEND
COONSLIN
100 SUB"UfiEAR COONSLHI" : N, M,A( , ) , B(,) ,C(,) , D( , }, 0( , ) ' LINEAR COONS SURFACE
110 · ~=NUMBER OF POINTS Qt, THE P(U , O) AND P(U,l) POUNDARY CURVES
120 ' M.:NUMBER a: POUlTS Qt, THE P(O ,~I) AND P(l ,~ ) EOUNDARY CURVES
130 ' A( , ):ARRAY COiflAININC THE POINTS Of\ n!E P(U,O) CUflVE
1!10 ' HAS DD'ENSIONS OF til 3
150 ' B( ,):ARRAY <XlNTAitliNG n!E POINTS ON 'mE P(U ,1 ) CURVE
160 • HAs DIMENSrOt,s OF tJI3
Dt\TA B.Z\SE N11NIPI.lL1\TIW ALC:XlRI'I1f>1S 229
eiCUBI C
1\n algorithm which will generate a cartesian prcxhx:t Bczier surfaoe based
on F..q. (6-48) is given below as a BASIC language subprogxam. Bezier curves are
usoo as the blending functials.
FI:ZSUflF
•
•
llall•roK1 i Vf•, I, :l
llrx ~ ·, 190 .Jt'fol [,IJrY, H, 10, lO
P· U lVI • , 14, HJ
parallel, 29 l>buSe, 8, 20
surface, pararretrlc, 163 f\bve absolute , 192
transfox:mation of, 27 t-11LTIOBJF.X:T, 180
Local tracking, 194 ~tiple vertices, 146, 149
IDeal tracking node, 190
Lofted bicubic surface, 182 t-:atural end, 126
Lofted surface, 166, 18~ Nc::llc:CrmUtati ve, 50
Loft:sn:ms spline, 119 Nonpararretric circle, 214
Longl.tude, 158 Nonpa.rarretrlc ronics , 102
tionparmnetric curve , 90
l'lachine tool, 1 NOnsi.ngular, 199
•
Manipulation software, 188 Nontridiagcnal matrix, 127
~~pping, 34, 41, 162 Noxrral., 160
~~them:ltical curves, 89 unit surface, 161
!'\athematical spline, 119 NormllizaHm, 39 , 93
Matrix, 24, 196 Nornalized parMeters, 123
addition, 197 Nf'C!K!F. f 214
algebra, 196 t-.'Urerical control, 157
iden~ty, 25, 41, 197
inverse, 41, 199 Cbl.ique perspective, 72
inversion, 122 Cblique projectim, 65
multiplic:atim, 5 , 25, 33 , 197 Order, 196
multiplier, 2 ()rt}x)g'raphic projection, 208
nontri.d.i.agc::l'la, 127 Oscil1osrope, ll
product, 177 OUtward normal, 161
square t 421 1251 196 OVerall scaling, 40
subtracticn, 197
tranSfonnation, 28, 47 PAAABOLA, 217
tridiagonal t 124 1 126 Parabola, 95
zero, 197 parametric, 106, 217
l1idpoi.nt transfoDM.tion , 28 arc, 108
Minicxxrputer, l blending, 133, 137, 223
r-bde control , 189 Parallel lines 1 29
f>bde: Parallelograms, 30
curved line, 190 ParaJreter, vector valued, 164
erase, 190 Pa.rarretrlc circle, 103, 215
graphics, 190 Paranetric caries, 103
1ncrerrental, 13 Panuretric cubic, 170
loc:Jsl tracking, 190 Pararcetric cubic spline, ll9
standby, 190 Parmretric curve , 92
Im.EX 237
•
Cover photos: DAVID F. ROGERS
The cover photographs show parametric
solut1ons of the compressible boundary
layer equations. Photos 3, 4, 5 show
vanous v1ews of the shear stress as a
tunct1on of the pressure gradi ent,
parameterized with surface temperature.
Photos 1 and 2 show the surface heat
transfer rates as a function of the pres-
sure gradient, parametenzed with
surface temperature (Ref. Phys. of
Flu ids, Vol. 12, No. 3, 1969)
I
I
I
0-07-053527-2