You are on page 1of 260

,

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

ftf.Mw-HILL BooK Ca1>ANY


New York St. Louis san Francisoo Auckland
DUsseldorf Johannesburg Kua la Llr'r(:lUr I..ooda'l
t~oo M:lnt:real New Delhi Panazra Paris
S3o Paulo Singapore Sydney Tokyo Toronto
-

Copyright@l976 by ~w-Hill ' Inc. All rights


reserved. Printed in the united States of Merica.
The prtXJian ~ of this publicatioo may be reproduced.
No other part of this publication may be reproduced ,
stored in a retrieval system, or transmitted , in any
form or by any rre.ans, electraric, ~ .
~t:ocnpy.ing , recording, or ot:heiwise, without the
prior written permission of the publisher.

3 4 5 6 7 8 9 0 FGRFGR 7 9

Fairfield Graphics was printer and bi nder .

Ll.brary of Qn]ress catalogirq m Publicat.ioo Data

~. Oa\nd F 1937-
r.\"lt:hesratica.l elencnts for o:xt~ter graphics .

Incl1rles blbliographical references and index.


t. Cl.:rput.er graphics. I. Admns, Janes Alan 1936-, jowt autl-or.
II. Tt tle
·;)85.R6 001.6'443 75-29930
ISBN o-o7-o53527-2
CONTENTS

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

OW'T£R 2 romrs liND LINES 24


2-l Introcb::tioo 24
2-2 Representation of Points 24
2-3 Transformat:.ioos and t-'.atrices 25
2-4 Tranformation of Points 25
2-5 Transformation of Straight Lines 27
2-6 t-tidr:oint Transformation 28
2- 7 Parallel Lines 29
2-8 Intersect.ing Lines 30
2-9 ~t.Jtlcn 11
2-10 ReflectJ.on 31
2-11 scaling 32
2-12 canbined Operations 33
2-13 TransformatScn of a Unit Square 34
2·14 Arbitrary 2 X 2 ~tati.on Mat rix 35
2-15 '1\.Q-Dlr.W'm.Si.ooa.l 'J.'ranS1at.ioos and Hcnogeneous Ox>rd.inates 36
2-16 Points at Infinity 41
2-17 '1\.o-DllT'enSl.OOal Jbtation about an Arbitrary Axis 43
References 44

CW\PJER 3 'ruREE-DINENSICN\L 'I'Rl\NSFOR>'.ATlQ.:S 1\ND PRml:TICN; 46


3-1 Introduction 46
3-2 'lbme-Dinensional Scaling 47
3-3 'nlrec-Dirrensional Shearing 49
3-4 'furee-DiJrensional IOtations 49
3-5 Reflection in 'I'hree Dimensions 51
3-6 Translation in Three Dilrensions 54
3-7 Three-D~ional lbtations about an Arbitrary Axis 54
3-8 Elerrcnts for the General JOtation r-~trix 55
3-9 Affire and Perspective Gect~etry 59
3-10 Axooc:rretric Projections 60
3-11 Perspective TranSfonMt.ions 66
3-12 Techniques for Generating Perspective Views 73
3-13 Pomts at Infinity 77
3-14 Reoa\stn.ction of 'Ihree-Dirrensional Information 78
3-15 Stereograriric Projection 84
References 87

QW1fER £t PLANE aJRVES 89


4-l Introduction 89
4-2 Nonpara.rrctric curves 90
4-3 Param:>t.ric CUr\tes 92
4-4 Nonpa.ram:?tric ~resentation of Conic Sections 94
4- S Nonparanetric Circular Arcs 98
4-6 Parar-etric Representation of Conic Sections 102
4-7 Pa.razmt.ric Reprcsentatioo of a Circle 103
4-8 Para~TW!tric ~presentation of an Ellipse 104
4-9 Pararrctr ic Rcprescnt.:ltion of a Parabola 106
4-10 Paranetric RaprcSUltation of a Hyperbola 108
<nm:NI'S VII

4-ll A Prooodure for the Use of Conic secti.als ill


4-U Circular Axe Inte.q:olation ll3
References us
OW'TER 5 SPACE a.JRVES 116
5-.l Int.rodu:tion ll6
5-2 Representation of Space o.uves 116
5-3 CUbic Splines 119
5-4 N<mralized Paraneters 123
5-5 Bourdary COnditions 124
5-6 Paratolic Blending 133
5-7 Bezier CUrves 139
5-8 a-spline CUrves 144
References 155

ffiAPTER 6 S'llRFACE IESCFUPI'IClil 1\ND GENERATIClil .157


6-1 Int.rodllct ioo 157
6- 2 Spherical surfaces 158
6-3 PlanE: 'Jurfaoes 162
6-4 CUrved SUrface Ieprescntation 164
6-5 Bilinear Surface 165
6-6 IDfted or Ruled Surfaces 166
6-7 Linear COons surfaces 168
6-8 Bicubic Surface Patch 170
6-9 'Ibe F-Patch 175
6-10 Bezier Surfaces 176
6-ll &-spline SUrfaces 180
6-12 Generalized Q)ons Surfaces 181
6-13 COOC1usions 185
References 186

APffNDIX A CCI.fiVI'ER GRAPHICS SOFniARE 188


A-1 Carp.Iter GraJirics Primitives .189
A-2 Catplter Graphics Elarents 191
A-3 canonical Space 194

IWENDIX B NM'RIX <PERATI(N) 196


B-1 Te.oninology 196
B-2 Mdi tion and Subtraction 197
B-3 Multiplicatioo 197
B-4 ~t of a Square Matrix 198
a-s Im-erse ot a Square t-1iltrix 199

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~

as the catplex problems of the mat:.hem:ltical eleuents . rurthemore, the full


operational potential of catputer graphics is often ~izcd whenever the
rMt:he'natic.u relationships , constraints, and options are inadequately expl oited.
By the.u: authorship of this text, D:rs . Jt>gcrs and 1\dams have rea:xpuzed the
valuable relevance of their back9XOU'ld to these przlctical consl.derntioos.
'lbUr text is oaJCi~, is ~ive, and is written in a style unusually
oonducive to ease of rcacUng, , iUlCl use. I t exmplifi.es the rare
type of '-Ork that rrost practit.iooers stould wish to place in a prominent locatioo
within their library since it should prove to be an invaluable ready rcfarcnce
for rrost disciplines. It is also well suited as the b<lsis for a oourse in a
cx:rtputer science educatioo curriculum.

I c:n1gratul.ate tho autn:>rs in producing an excellent and needed text,


"Mat:hernat ical Elecrents for Cotp..lter Graphics."

s. H. "Olas" 0\ascn
Locl<heed Georgia Calpmy, Inc.

PREFACE

A new and .rapidly expanding fjeld called "CXJlPUter gra~" is errerging.


'Ihis field cxxrbines roth the old and the new: the age old art of graptucal
cx:mtU'licatioo and the re11 technology of catpUters. AlJrost everyone can expect
to be affected by this rapidly expanding techoology. A new era in the usc of
CXITpUter graphics, not just by the large mrpanies and agencies \\ho ml'.lde rra.ny
of the initial advances in software and hardware, but by the general user, is
beginning. Lc.w-cost graphics terminals, ~ sharing, plus advances in mini-
and miCJ:O<XXIPUters have made this possible. 'lbday, <XIlputer graphics is
practical , reliable, CXlSt effective , and readily availAble.
The purpose of this lxlok is to present an introdtx:ti.on to the rro.thanatical
theory underlying cx:.op.rtcr graphics techniques in a unified manner. Al.trough
new ways of pt:eSentlng material are given, no actual ''new" mathematical TMterial
is presented . All the material in this boolc exists scattered throughout the
technical literature. 'Ibis lxx>k atterrpts to bring it all together in one place
• •
111 CTM notatJoo.
In selecting material, ~ dlose tecmiques \Jtich were fund.alrentally nath-
ematical in nature rather than t.rose \olhi.dl <Nere rrore procedural in nature. For
this reason the reader will find rrore extensive discussions of rotatioo, trans-
latioo, perspective , and curve and surface descriptloo than of clippi.ng or
hidden line and surfaro rerroval.. First-year college rratheratics is a sufficient
prerequisite for the major part of the text.
After a discuss:i.on of c:urront cxnpoter graphics tochnol.ogy in Olapter 1,
t.~ manipulatIon of graphical elEments represented in matrix form using haro-
CJI=OOOUS a:xn:'din.ate5 is described .
A discussion of existing techniques for
reptesent.iN} p:>mts, lines, curves, and surfN"PS within a digital CXITpUter, as
'Mll.l as c:utpUter sofO.'are procedures for rmnipulatinq and displaying mcputer
output in graphical form, is then presented in the following 0\aptc.rs.
!'lathematical tcchniques for pt:oducing ~ ard perspe:ct.:ive views
are given , along with generalized tec::hn.iques for rotation, translation, and
scall.ng of qearotric figures. CUrve definition procedures for both explicit
aro palCiretric representations are presented for both and three-
ditrcnsiooal. curves. C\.U:\Ie definition techniques include the use of conic
sec:t.ials, ci.rcul.Ar arc interpolation, C\bic spl..ines , parabolic bl ending , Bezier
curves and curves based en a-splines. An int.roduct.i.a'\ to the mathematics of
surface description is inc:ltxied.
catplter algorlthns for uost of the fundarlental e.l.arents in an interactive
graphics package are given in an appendix as BASIC* l..anguaqe subprograms . HeM-
ever, these algorithns deliberately stop srort of the coding necessary to
actually display tre results. U'\fortunate.ly there are no standard l.anqua<Je
carmands or subroutines available for graphic display. Although sate prel.imi.nary
discussioo of grapuc primitives and graphic elem:mts is given in .Appendix A,
each user will in general find it r..eoessary to work within the oonfines of the
cx:nputer system and gra{il.ics devices available to him or her.
'1h:l furx1aJmnt.al ideas in this book have been used as the foln}ation for an
introductory oourse in c:utp.~ter <Jraphics given to sb.rlents ~mjoring in technical
or sclcntific fields at the undergraduate l evel. It J.S suitabl e for use in this
nann<:r at both I.D1iversit..ies and schools of technol ogy. It is also suiUible as
a supplene1taxy text in rro:re advanced c:utputer programning courses or es a
SH{l>letre:1taxy text in sore advanced mathesratics courses. Further, it can be
profitably used by ind.iviCbals engaged in professiooal programning. Finally,
tho docurcnted c::onputer ptograms srould be of use to m1puter users interested
in developing mcputer gra(Xlics capability.

The authors gratefully aclo'lc:Mledge the enoourageucnt and support of the


Urited States Naval Academy. 'llle acadatu.c envi..roon:ent provided by the aaninis-
Lratial, the f<-~t."Ulty, and espcc:ially the midshipnen was conducive to the
de~lop<r.nt of the rmterial in this J:xxX.

*Msrc i.s a regiStered trade nurk of nu:U.OUt.h COllege


PREFACE YN

No book is ever written without the assistance of a great ~mny people.


Here \ole \lo10Uld like to acknowledge a few of them. First, Steve COOns \lh::l reviewed
the entire m:umscript and made rrany valuable suggestioos, Rich .Reisenfeld \lh::l
reviewed the material on B-spli.ne curves and surfaces, Professor Pierre Be2ier
\lh::l reviewed the 11\llterial on Bezier curves and surfaces and Ivan Sutherland ....no
provided the iupetus for the ional recont.roction techniques discussed
in Olapter 3. Special aclcncwled~t is due past and present rre•bers of the
CAD Group at ambridge University. Spec:Hically, \oOrlc Cklne with Jti>in Forrest,
Olarles Lang, and Tcny Nutlx:Jume provided greater insight into the subject of
CCJ1l",rt:er graphics . Finally, to I.Duie Knapp who provided an original FORmAN
program for B-spline curves .
'!he authors would also l..iJ<e to aclo'¥:Mled<;Je the assJstanoe of many individuals
at the Evans and Sutherland CQipUt.e.r Coqx:>ration. Specifically, Jim can an who
a uthored the ~t fran ....ru.c:h many of the j deAs on representing , preparing1
presenting and interacting with pictures is based. Special thanks are also due
Lee Bil101o1 "*'o prepared all of the line drawings.
t-t.ach of the art ...orlc: for Chapter l has been provided t.hrough the good
offices of •:ui.ous c:otputer graphics equiprent nanufacturers . Specific acknor.ol-
led<Jrent is tmde as follows :
Fig. 1-3 Evans and SUtherland Caq;luter Corporatim
Fig. 1-S Adage Inc.
Fig. 1-7 .Adage Inc.
Fig. 1-8 Vector General, Inc.
Fig. 1-11 Xynetics 1 Inc.
Fig. 1-12 CALO:l-1P, California eoopurer Prochx:ts, Inc.
Fig. 1-15 Gould , Inc.
Fig. 1-16 Tektronix, Inc .
Fig. 1-17 Evans and Sutherland catFuter Cox:pxaUon
Fig . 1-18 CAiaM.', california c:atputer Prodttts, Inc .

David F. JO]erS
.1. Alan Adams

CHAPTER l
INTRODUCTION TO
COMPUTER GRAPHIC
TECHNOLOGY

Since o::rrputer grafhi c:s is a relatively new technology, 1.t is neoassa.ry


to clarify the current ternu.rology. A nmber of t.e.rTTs and defl.nitioos are used
rather l OOEiely in this field . In particular, carpucer aided design (CJ\D) ,
interactive graphics (IG) , m1puter graflh.ics (ex;) , aro conputer aided manufac-
turing (01'.) are frequently used interch~ly or in such a rrlU'lner that
considerable confusion exists as to the precise rrean.ir¥]. Of these tcrrrs CAD
is the nost general. CAD rra.y be defined as any use of the caTpUtor to aid in
tr.e design of an individual part, a S\.i::)system, or a total system. 'Ihe use
CJocs not have to involve gra._oh.ic:s . '1he design process rroy be at tr.e systen
cxmoept lcw.l or at tho detal.l part design level. It nay also involve an in-
terface with CA.'i.
~ ai<X-d manufacturing is the use of n CX>IIPJter to &d in the
manufacture or production of a part exclusive of the design pnx:::ess . A direct
interfaoo between the results of a CAD application and the neoessacy part
pr~xi'lmling using su:h l anguages as APT (Autooatic Progt'W11l..>d Tools) and lNIAPI'
(United' s APT) , t.ht" direction of a IMChine tool using a haroNircd or softwired
(miniconputer) controller to roae eata -f'ro•·• a OUI'd"lCd pa._?Cr tap: and CJC!llerate
the necessary ~ to oonLrol a l"aChi.r.e tool, or the direct control of a
oochine tool USir¥J a minicarprt:.er nay be involved.
Cbrputc.r graphics is the use of a ca•puter to define , st:.aro, nunipulatc,
i:."ltcrrogate, ar.a PLesent pictorial output. 'lhls is essentially a passive oper-
ation. Th' a:rputer prepares and presents stored infonration to an observer
in the fo:::r.. or pictures . 'lhe cbsetver has no direct conLrol over the picture
bo.inj presented. 'lhe application~ be as sirrple as the presentation of the
qrll{:h of a silrple C1lnCtion us~ a hicjl-speed line printer or a ·
te.let.~ t.emi.nal to as m•plex as the simulation of the autaMtic reentry and
landU'lq of a space capsule.
Interacti"\:! qrapucs also uses the <X1TpUt:er to prepare and present pictor-
ial rote..-ial. llc:Uevar, in interactive grapti.cs the observer can influence the
picture as it is being presented; i.e., t:ht:! observer interacts with t:hc picture
m real t:.in!. To see the inportance of the Yea! ~ restriction, consider the
pJ"Cblcm of rotating a cotplex · onal picture a:xtposed of 1000 lines
at a reason.tlble rotation rate, say, 15°/second. As we shall see subsequently ,
the 1000 lines of the picture are JTOSt oonveniently represented by a 1000 x 4
nutrix of hooogeneous OX>rdinates of the end points of the lines , aro the rota-
tion is n::~St oonveniently acca,plisbed by nultiply:ing this 1000 x 4 matrix by
a 4 x ~ tran.sfornation rratrix. Accntplish.ing the required natrix nW.tiplication
roquin.... 16 , 000 aultiplicatialS , 12,000 additions , and 1000 divisions . I f this
m'ltrix rrultipUcation is acx:n1plished in soft..lare, the tirrc is significant. To
soc t.ltis, consider that a typical miniconputer using a haxd.-ta.re floating-p::lint
pt~~sor requires 6 microseconds to nultiply 0.'0 nurbers , 4 microseconds to
add O..'O fl\rlbers , and 8 rnicrosecorxls to divide t\\'0 nurbers. 'Ihus the matrix
nultlpl.ication requucs 0 .15 seconds.
Sin~ mtputer cti.splays that al lo;,· dynamic notion require that the picture
be redram (refreshed) at least 30 ~ each second in order to awid flicker,
i c 1s cbvious that: the picture canmL change snoothly. Even if it is assured
that the picture is recalculated {\4?d!lted) only 15 times eadl seoond, i.e.,
ever)' tlcqrec , it is still not [X.>SSible to aco:JJtplish a sncoth rotation in soft-
Hare. 'Ihus this is T"DN no lollC}er interactive graphics . To regain the ability
to l.ntcractivcly present the picture several th.i.ngs can be oone. Cl ever pro-
rJrarwli..ng can n:duc:c the t.irre to accntplish the required matrix multiplication .
lfodever, 0 pOlnt will be reached wnere this is no longer possible . 'llla <Xlllr
plexlty o! t:hA.; picture ~ be reduced. In this case, the resulting picture
m'ly not I~ accept.ab lP . Finally, the matrix multiplication can be acxntpli.shcd
by using a Spcclal-pl.ll"pC)Se digital hare);.;are rrut.riJ< nultipller. 'Ihi.s is the
r-osL prouU:sing CIR'road\. It can easily handle the prcblcm outlined l!b:>ve.
lnt:h this tcrmioology in mind the renainder of this chapter will give an
OVCIViL~ of cx:r·put.er gratillcs am discuss and c lassify the types of gr~ic
displhJS ~va.i 1<-bl,.. ~h.... nt:Cl!SSary ronsiderations for devel~t of a soft-
W<lre S'fllt..an for the f~tal drcr,...l.T\g, device-control, and dato-handl:ing
aspects of c:atputer grapucs is given in J\ppe1rli.x B.

1-1 CNERVIEW !J: ~GRAPHI CS

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.

1-2 la>REsa-rr1 ~ P1<:n~s To BE PREsENTED


F'\lndaJrentally the pictures represented in cnTpUt:er cp:aphics can be con-
sidered as a collection of lines , points, and textual material. 1\ line can be
(~,y ,z 2 ),
represented by the ooordinatcs of i ts end points c, , y 1 ,z1 > and 2 a
point by a s.i.ngle-ooordi.nat:e triplet (xl'y , z ) , and textual material by col-
1 1
l.ect.ions of lines or points .
'Llle representation of textual material i s by far the rrost c:atplcx, involv-
ing in many cases cw:ved lines or dot matrices . IICMever, unless Ule user is
concerned with pattern ['C(X)(Jnition, the design of graphic tmrd.,'are, or unusual
character sets , he or she need not be concerned with these details, sinoe al-
Iro6t all grapuc &vices have built-in ..harc},:are" of software c:ha.r.!K:ter gen-
erators. 'Ihe representation of curved lines is usually l!o:::ouplishcd by approxi-
rating them by short straight-line segrrcnt.s . Iio..Jever, this is sarctiJros acxntr
plished using hard.-lare curve <]CJlerator:s .

1-3 PREPARING PtcrtR:s FOR PRESENTATION


P1ctll.rCS ult.i.r.ately oonsl.St of points. The ooordinatcs o! these poirlts
are qererally stored 1n a h.le (anay) prior to beJ.ng used to present the plc-
t:ure. 'nlis file (array) is called a data base. Very mtplex pictures require
very m::plex data bases wtudl require a oocrplex Pn'XJrM\ to access them. 'l1lese
<n1plex CaUl b-'lSCS ruy inwlvc rinq st.ruccu:res, tree st:nx:turcs, etc., and the
data bast. ~tsclf !"~·
contain powts, slbst.ructures, and olher ronqraphic data.
T"e des i<Jl" of ~ data bases and the program; which at:..'mss them is an ongoing
top1.c of .research, a topic which is clearly beyond the ~of t!lis text.
fb:ever, JT1AnY m•puter graphics applications inwlve much sinpler p1ctures for
which the user can reddil} invent sinple data base structures \\lhich can be
easily a~sed.

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

h is an ami tra.ry n\Jlber.


l f each of the coordinate positions represented in c1 16-bit c:arpu~r were
l ess than 32767 , then h "-ould be n-ade o:JUa1 to 1 and the CXX)rtti.nate positions
represented directly . I(, hcJ..rever, one of the Eucledean or ordinary CXX)rdi.nates
is larger than 32767, say , )( ::: 60000 , then the poNer or haxogunuous cxxmlinat:es
bea::tres apparent. In this case '''e can let h = 1/2, and the CXX)rdinatcs of the
point are then def ined as ( 30000 , l/2y , l/2z 1 1/2) , all acceptabl a nUtbers for
a 16-bit CXIIlpllter . Ho..-evet"1 sooe resolution is lost sinro x .. 60000 and x =
59999 are both represented by the sama hooogeneous CXX)rdinate. In fact resolu-
tion is l ost in all the ooordinat2s evan i f only one of them exceeds the 11\lX.i.-
nun expressable mmbor of a particular <Xluputer.

1~ PRESEw.!~ f>REv iOUSLY PREPARED PICTURES

~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

Figure 1-1 ~ di.Jrensional Figure 1-2 ional


windo.o~ing (clipping) . frustun of vision w.indo.ol.

rcost general case oonversion to display exx>rdi.natcs within a specified t:h.me-


din'cnsional viewport~ a linear rrapping frau a si>Hu.d ed [rustun of
vision (wi.ndo.") to a six-sided vieNpOrt .
An additional requ.Ue1ent for II'OSt pictures is the presentation of alpha-
nlm'Cric or character data . There are in general two rroth::x3s of generating
characters - software and hard"are. If dlaracters am qenc.rated .1.n software
using lines , they are treated in the smre manner as any other picture elCI'I\"'nt.
In fnct this is rocessa.xy if they are to be clipped and then transforncd along
with other picture e l aronts . Ha.leve.r, many graphic devices hava sare k.ind of
ha.rd,..rare character generator . '-ben har:d.>are character generators are used , the
actual characters are generated just prior to beirxj drawn. ~ Wltil this point
they are treated as only character oodes . Hara,•are character generation is less
flexible sinoe i t does not allow for clipping or infinite transfonration, e . q .,
only li.Jru.ted rotations an:l sizes are generally possible, but it yields signifi-
cant efficiencies.
\\hen a ha.z:d..rare character generator is used, the !'rogr& which drives the
qrapuc device nust first specify size , orientatioo, and the position ,mcz-c
the character or text strlll9 is to begin. 'nle character c.oOOs specifying these
c:ha.rnct.&istics ;u-e then OOdod to the display file. {k.lon being p~sscd th<.:
character generator intexpreb the text string , looks up in ~ the neces-
sary .Lines to c:lra\..• the c:haractcr, and draws the characters on the displ ay de-
vice.

1-5 lrCTERACTWG HrrH THE PICTURE

Inte.racti.ng with t.l)c picture requires sare type of interactive device to


CXllr.Uni.cate with the progra., while it is running. In effect this inte~

tix: program so that rc-1 or d.l.fferent infol:'T19tion can be provided. N\.ITCrous


devices have been used to accotplish this task . The sirrnJ.est is , of course ,
the al[:haru.vreric keyb:lard such as is foun:! on the tel etype . flore sq::hlsticated
devices incll.JOO ll.ght pe.n.G, jat sticl-.s , track balls , a rrouse, ftlnction swi tchc:s ,
control dials, and ana.lo-1 tablets . We shall exanu.nc each of these devices
I.:. ric fly .
A sjpple alpham..tmric keyboard as sham in Fig . l-3 can be a useful int:er-
actiw device. Preci.sc al(ilabetic, ru.meri..cal, or ex>ntrol inforrration can be
easily ~lied to the proyram. lbleVer, it is not capable of high rates of
interaction, e><pccially if the user is rot a cp:xl typist.
Perhaps the best kncMn interactive device l.S the lic;l\t pen. 'lhc light pen
a:>ntai.ns a light-scn:ntivc rh;>toelectric oell and associated ci.tcuitry . \>,'hen
I-OSitioned over a l.i.nc sc:qm:nL or other ll.ghted area of a CRr and activated,
the posl. tion of t:re pen is sensed ard an inte~t is sent to the conputcr . A
Gdl.eMatic of a typical light pen is sham in Fig. l-4 . Figure 1-5 sharJs a licjlt
pen in usc for renu p1.c:::k.ing.
The JCI'f stick, rrousc, cllld track ball all operate on the SCITe principle.
By ITOIIirq a ex>ntrol, ~ional positiooal information is cx:rmunicatcd to
the catputer. 1\l..l thesr' deVl.oes are analog in nature. In particular, ro~t
of the a:>ntrol dlan<;Jcs tho setting of a sensitive potentiareter. The result.i.ng
siCJOials are convortccl fran analog (voltages) to digital signals using an analog
to dig.1tal (A/D) oonverter. These digital signD.ls arc then interpreted by the
cn·puter as positiot"..a.l infoo:ation . A joy stick is stnm in Fig . 1-6. Jat
sti&s, rouses, t.rad: balls, azrl similar devices are useful for particular
appll c:at.:lons. IJ&C..'VC.r, they sOOuld not be used to provide very pr ecise posi tioo-
al information.
Control dials a.c; sho.m 111 Fig. 1-7 are essentially sensitive rotating poten-
ti(');Cters clnd <lSSOCi..ltl'd circuitry such that the position of the dial can be
sc.::nsed using anal.oq to cliqlt.dl <X:lnvcrsion t.echrtiqoos . 'l1ley are particular ly
useful !'or activating rota im, t.ranslnt.ion, or 7.0:11'' fentures of ha.rc:Ware and
soft..tarc syst:.e~Tc.
~hiiiiCI
hullnn

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

Figure 1-3 Al{:tlanll!l'eric Figure 1-4 Schc:rnatic


keyboard. of a light pen.

Figure 1-5 Light pen in use for menu picking.


Figure 1-6 Joy stick. Figure 1-7 COntrol dja]s.

Function switches, sJu.m in Fig . 1-8, are either toggle or push-button


switches wtn>e fOSit.ion can be detennined by the ~cs program. Li~ts

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

,....•. ·-· '' '


.........·~'
'l)erating principle.

1-£ 1l:SCR I PT I(XII OF Sot"C TypICAL


'' ••
•••••••• '
•••'. •••. ' •• tAAPI·fl CS l£v1 CES

•• • • • 'ttlere are a large nll!bcr of differ-


ent types of grCifhics devices available,
far too many to describe them all hru:e.
'Therefore only a limited m..rrber of de-
vices representative of those available
Figure 1- 8 E\Jncti.oo s.dtale:S . will be c.cnsidered. In particular,
three different t}?eS of CRT grapucs
devices - storage t\be, refresh, and raster scan; a pen and ink plotter; and
a dot oot.ri.x plotter - will be described . .Additi.ona1 devices and rore detail-
ed descriptions are provided in Ref. 1-1.
'llle three types of CRI' (cathode ~ tube) devices are direct vie,., storage
tl.be displays, refresh displays, and raster scan displays . '1\le direct vi&l
storage tube display, also CAlled a bistable storage tube cll.st>lay, can be
oonsidered as similar to an oscillosoope \17ith a very long persistence phospl'¥:>r.
A storage tube display is shown in Fig. 1-9 . A line or character will remain
visible (up to an rour) until erased by the generation of a specific electrical
signaL 'llle erasing prooess mquires about 1/2 serond . Storage t\be displays
have several advantages and disadvantages. Sam of the advantages are: the
display is flicker free, resolution of the display is gocd (typically 1024 x
1024 acklre.ssable raster points in an approx.irnate 8 x 8 inch square), and oost
is lao~. FUrther, it is relatively easy arrl fast to obtain an acceptable hard
CXJPY of lhe picture , and conceptually they are sarewhat eas1.er to program and
rrore suited to tilre-shnring applicatialS than refresh or raster scan displays.
'ttle principill dis-'ldvantagc is that the screen cannot be selectively c.rascd;
i.e., in order to dlange atrf el..E!rent of a picture the entire picture rrust be
redrawn . Because of this the display of dynamic ITOtions is not possible. In

f'ig-..:.re l-9 Analog tablet.

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

- - - high-quality hard ~ o f qrat:hical out-

-- put. O::crpared to CRT


they are qw. tc sl~ .
grapucs deVl.ces
COnsequently t.'"eey
are not generally used for .rea.l- tiJre

. 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.

Figure 1- u Drum plotter.



,
Pll pe 1
drne I one r Rcill
upp iJCiltor
e lee t rode .._ ....

-- OJ

,
I Pa Jl e r
$Uppl)i

Fi'JUCe 1-13 Direc:t..i..ats Figum 1-14 Conceptl:.a1


for incre<e.'ltal plotters. description of electrostatic
dot rntrlx printer/plotter.

and typical output.

1-7 CLASS l FICATIOI~ ()- f1wt.i i CS l£vlCES

'lhcre u.rc a n\.UTbcr of rrethods of cl assifying couputcr graphics devims.


Each rrethoJ yields sate insight into the sa1etirres confusi.ng array of possible
~via.:.s. ~It'"! will dic;cuss several different t~Ethods .

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 .
-

Figure 1-15 E.l.ectrostatic dot trat:.rix


printer/plotter and typical ootput.

I ~

,p J.
- •
~
rill
~~iii:'!
I
~

..:

Ill'!
:;;;,

1.11
:00

Figure 1-16 Storage tube CRT gra(i\i cs device


am typi cal output.
Figure 1-17 ~ CRI' graphics device
and typical ootput.
=--"'\~
;:..a,;
~r ·
~r---
t c: ..
-·----
~~-::

- ....

-
---:
. -• --------
-
....
~--
- --w
~ -.
---
••
... :. ..__...,.._
- - ~-- -

·-• -· - ...__
. c;,.r-
4
• ~
- -
__ --
• --.- =-=-.:-:
~JI::: .... <IIt • ••
·-
-·-· --
-·-- ~- --- --
--... -·
......_...._........._
--~--..,.._.

:"' , i:¥ =-s.


.:w-..--
,____- c::.c-
:--- - .t;·
,...
- --· --
. - __--..... _. -
...
_.,_
: ~

- ....,..
a---......,...
...,_._,_
- - -~­ ~ -'\.- ;-_:.:
_
_....__,.,.
.......
~
C"'".._..... .... .,_
--~-

- --- . ·n:--.s••:r
- ... .... . .
::----...,._ - -:e.!:.

-·...., .---
.-... =~
.

-- -- ~.:a- · ''::"~-":""~.-L'-
·: •• I "· -·-.:::s--- ..,.. ___
..........
- --
..Cl.::. ---.5 •

c.::~ · , z~:- - - --.. • •

--- --·- :.-.; • - _ . --- ___



,.,..._,.,.. ..- ~
!WI---·.:. ----=. - ,.....::
- '
~--
~ _._ ..;"' ,_ .. t - ":.~
....,_~

--- .. -- .--- ---· ----- .


~-
_.,__ ~~~--

----
- 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

Figure 1-19 High-speed printer


and typical graphic output .
'

•••••••••••••••••••••••••••••••••••••••••••
•• •
• •
•• • ••••••••• •
• ••• • ••• •
•• ••• ••• •
•• •
• •
••
• ••
•• ••
• • •
•• • •
• •• ••
•• •• • •
• • • ••
• • •


• 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

1-1 Newman, ''~· t-1.. , am Sproull, R. , Princi pl es o£ Interactive O:ltputer


Graphics , r-ldinm..-Hill Book Catpany 1 New 'tori<, 1973.
1-2 Bezier, P . E., "E:xarple of an Existing Systerrs in the t-bt.Or Industry:
'1he Uri.sur! Systan" P:roc. lby . Soc. (I.orxbn) , \Ql A321, pp. 207-218 ,
1971.
CHAPTER 2

POINTS AND LINES

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.

'2-2 ltP~scrrrATJ CX~ OF Ponrrs

!\ point can be represented in two dirrensions by its coordinates. These


bJO valu:s can be spoc.ified as the el.en:!nts of a o~tn.~, b.oo-c:ol~..~~m nllltri.x
(x y). In tJ'\rnP dirrensions a one by three rclt.rix [x y z) lS used . Alternate-
ly, c1. point can ~ x~resented by a two-row, onc-cohrn matrix [¥ J in bNC

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

\o.hlch is a position vector relative to a local ooordlnate systGn, may be


stored in a ttluputer as a matrix of ru.mbers . 'Ire position of these points can
be controlled by manipulating the rrotri.x \"trich defines the points. Lines can
be dr.r..-n beo.oeen the points using afP:roprlate cxxtputer ha.rd../aro or software to
generate lines , curves , or pictures as output.

2-3 TRANSFf:»4ATICl'lS f\.'40 1'\.\TRICES

'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

qJerator is the foundation of the ll'athernatical transforrrations useful in cx:m-


puter gra!itics.

2-4 TRANSFO~'ATI~ (J= PoiNTS

COnsider the results of the matrix nultlplicat.i.on of a nutrix {x y) con-


taining the ooordinates of a point P and a qeneral 2 x 2 transforttation matrix:
(x y] [: :] os [(ax + cy) (bx + dy}) = [x* y*1 (2-l)

'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.

Consider the case where a =d =1 arrl c = b = 0 . 'lhe t.ransformltion Nt.rix


then reduces to the identity matri.x and
(x y) = l~ ~] "' [x y] = [x • y* ) (2-2)

and oo change in the ooordi.nates of the point I' occurs .


tJext consider d : 1 , b =c = O, i.e.,
26 t-fi\l'HEW\.TIO\L EIDIM'S FOR CQ-!'Ul'ER GRAPHICS

(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 .

r-o,., consider b • c =- o, i.e., •

(x y] f~ ~J = (ax dy] = [X* y*] (2-4)

'lllis yields o stret:dting in both the x- and y-ooordinates , as s ho.m in Fig.


2-lb . If a ;. d, then the stret.chinqs are rot equal. If a = d > 1, then a pure
en.Uw~rent o r scal.i.nc:] of the c:oordinates of P occurs .. If 0 < a = d < 1, then
a m tprcssion o f the ooordi.nates of P will occur.
If a ar¥.\/or d are negative, then reflections occur. To see this, consider
b - c - 0, d .. 1 and a s -1. 'Lhen

(x y] [-~ ~] = (-x Y1 = [x* y*] (2-5)

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)

and lhe x-ooordi.nate of the point P is unchanged, while y* deperds linearly on


the origuvll coordinates. This effect is c11 led shear and is stnm in F1g . 2-le.
Similarly \o.iten a -. d = 1, b = o, the transformation prodtJCCS shear proportional
to the y-c:xxu:d.t.nate , as sho.rn in Fig. 2-lf . Thus , we sec that the off-diagonal
tcnns produoo a shearing effect on the ooordinates of the point P.
Bofore m •pletirq our discussion or the transfoll'Mtion of points, consider
the effect Of the qcreral 2 X 2 transformation qiven by Eq . (2-1) when af{>lied
lD the oriqin, i.e.,
(x y) = [(ax+ cy) (bx + dy)] = (x* y*) (2-1)

or for the o rigin,


[: :J
= [0
OJ
[: :]
[0 0 ) = [X* y*}

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

) ·.) ,.} p• >·~


•r = [~ ~] I
I

T ~ [-~ ~]
,, ,.
I
I
,.
[~ ~]
I T=
• -. I

I'
- -- I'

• ' ,. \ , A• I. L
'·~.
~ c

\. \ ) . ~ ~ ) .
)
".
,,,.T= [~ ~] .
(\'•\
T= r-10 -1OJ n
.-
I'
,
·" ,.
!- •
h~ T
[~ ~]
)
r

,,
, ,, .... \ ,. h\
',. • "' ".
,
~ "'
f
••
I'

Figure 2-1 Transfonnation of points .

2-5 TRANSFORI'V\TIOO OF STRAIGKT LINES

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)

'Ihus, the rcs\.O.ltinq el.e"ents in A• a..-e x* = 3 ani y* = 1. Similarly 1 B* is a


f'l&l [X>int specified by x* ... 11 and y• • 7. f'bre mtpaccl.y the line AB rror:t be
rcprcse."'tcd by the 2 x 2 ~TUtrix L = (~ ~· l·atrix nul.tipllcation t.~cn yields

LT ""fo 1] '"1 2] = r3 1] .. L* (2- 10)


l2 3 l3 1 u1 1
"''here the mtp:ments of L* represent the transfoll""Ed position 'v'ect:ors A" and
B*. The transfot:r:\ltion of A to A* and B to B* i s sho.m• in Fig . 2-2. 'Ihe ini-
tial axes are x,y and the transfonred axes axe x*, y *. 'Ihis shearing effect
has increased the length of the line am changed its or ientat ion .

2-6 MIIYOINT TAA~SF00"1f\TION

Figure 2-2 sho..'s that the 2 x 2 transfOllMtion rratrix tral'.sforms the


straight line y = X + 1, beO.-een points A and B, .into another straight l.ine
}' a {3/4) X - 5/4, bet.-.-een A* and B* . In £act a 2 X 2 natrix transfOJl!'S atrj
straight line i."lto a secord straight line. Points on the seo:m;i l..lne have a
one to one correstx>l"lder::oo with points en the first line. \'ie have al..ready s.l\a..'n
this t.o be trua for the c!'ld p-rints of the line. To further ccnfinn this we
t.~

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

{X)ints sir.ult:aneously gives

[:~ ~~1 r: r:~: :~


(2-11)

Hence, the transfomed end {X)ints are


:J =

A* = (axl + en bxl + dyl) = (xl• Y1*l


B* • {ax2 + c.y2 bx2 + dy2) = <x2* Y2 * )
'Ire cidpoint of the initial line AS is

] (2-U)

'Ihe t.rar.sfo rr:'dticn o f this midpoint is

axl + ax2 + c.yl + c.y2 (2-13)


] [: :] = 2
bx1 + bx2 + ay1 + <TJ2
• 2
l<>INI'S lWD LINI:S 29

'lhl..s transfomation places the rnidpo111t of AS on the midpoint ot i\*B11 since


the rniqx>~.nt of A*B* is giwn by
ax1 + cyl + ax2 ~ cy2 axl + ax2 + en+ cy2 (2-14)
x• = 2 =----..,.,-----
2
bxl + dyl t- bx2 + dy2 bx1 + bx2 + dyl + dy2
r - ----...----
2 ------=----...;;...
2
For the spec1.al case sho.m in Fi9 . 2-2, the uli~t of line 1\B is H1 =
[1 2] . '1hls transforms to
[1 2]
G~ J : [7 4)
(2-15)

\,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.

2-7 PARAU.£L LiNES

a 2 x 2 rratrix is used to transfonn a pair of parallel lines, t.~


\•lhen

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)

Transfo.cning AB usi.ng a general 2 x 2 t.ransfonnation yields t.he end points


of A*B11 :

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)

'the slope of A*D* is then


(bx2 + dy2 ) - (bx1 + dy 1) b(x2 - x1) + d(y2 - Yl)
m.. = ........---..,..---,--.;.;_-~ :::0 _...,..---:---:-----:-
· ··~ (ax2 + cy2) - (axl + cy1) aCx2 - xl) + c(y2 - Yl)
or
Y2- Yl
b+d x2 - ><t b + dnl
m - ~ (2-18)
2-a+c Y2- Yl a+ on
1
)(2 - )(1
12 •8

I(I

T== [ll -32] 8

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 .

Since the slope~ is indc~t of x1 , x 2 , y 1 , and y , and since "1• a, b , c,


2
and d are the sarm for EF and AS, it follo.,'S that ~ for both E•F* and A*B* are
equ.al.. 'll\us, parallel lines remain parallel after t.ransfonration . This ~
that parallelogra:rs t.ransfonn into other parallclogtans as a result of operation
by a 2 x 2 t...ransfonnctt..wn matrix. 'Ihese siltpl e results begin to sho.o.' the po..-er
of using r.atri.x rrul.tiplication to produce g:rlltiric:al effects.

2-8 INTERSECTING LINES

'1\-.lo dashed 111tersect.ing lines AS and EF are s.ha.m in Fig . 2-3. 'Ihe ~int

of intersection is at x 4/5 and y = 1/S. We no" rrult.iply the rratric:es oon-


t.al.ning the end points of the two lines AS and EF by the transfonnation matrix

[: ~] . '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 [~ ~] •

'lhe trans foetal, new vertices are qiven by



• •

(}'

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

C£f' is transforrrod by {~ ~] which yields

a distortion chr to the unequal sc.osle


factors .
It is n::w clear how plane surfaces,
defined by ~oes joined by straight
lines, can be mmipulated in a variety
of ways . By performing a matrix opera-
~ } .~
I•
tion on the position vectors which define 1\ t- • • I•

~
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)

order of the transfoxrnations is inport-


ant when performing cntbined q:Jeratior.s .
'

- ,
{

-
- -
">; "8
,_
\
--
••
\

,.
-' ~
- h
\

Figure 2-5 L'niform and


In order to illustrate the effect
nonuniform scaling
or distortion.
of ronc:amult.at.lve mat:rix nult.lplication,
consider the operations of rotation and reflection on the verti~ of a triangle
(x y] . If a 90° rotation is follo.,'ed ~· reflection about x- o, these two
consecutive t:ransforr.ations cfive
[x y] [ 0 1] "'
-1 0
[-y x)

and then

(-y X) [-~ ~] •
(- x y)

en the other hard, if refl ection is follor..ted by rotation, a different result


given by

(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.

2-13 TRANS FO~\ATIOO OF A ~IT SooAAE

O::nsidcr a square-<Jrld ~l:k consisting of unit squares in the xy-plane.


'lt~ four position vectors o f a unit square with one CX>J.'Tl& at the origin of the
coordi rote system arc
0 0, o rigin of the coordinates - A
1 0 unit point on the x-ax:is - B
l 1 outer oorner - c
0 1 unit point on the y-ax:is - D
'Ihis unit squru:e is shom in Fig. 2-6a. Application of a general 2 x 2 matrix
transformation [: :J to the unit squaxe yields

~ ~ 1[: :J- ~ ~
(2-21)
:: :::
: ~ ~J la: c b : d:

~e results First ootice fran


o f this transfonnation are sl'la.m in Fig. 2-6b.
Eq. (2- 21) that the origin is not affected by the transformation, i.e., A • A*
= (0 OJ. fUrther, ootioe that the coordinates of B* are a;JUil.l to the first
row in the genera l transformation matrix, and the coordinates of D* are t:q1..li!l
to the scoond row in the general transfo.rmation matrix. 'nlus , onoe the coor-
dinates of B* and D* (the transfomed unit points fl 01 and [0 1) respectively)
are J<no.m, the gereral transfornation natrix is determined. Since the sides
of the unit square are o riginally parallel and sinoe we have previous l y shotm
that parallel l ioos transfoDn into parallel lines, the transfor.med figure is
a parall elogram.
The effect of the t..enrs , a , b, c, and d in the 2 x 2 rrotrix can be identi-
fied Sep<mltely . '1he t:.ez:ns b and c cause a shea.rin:J (cf Sec. 2-4) of the initial
~ in they- and x-directions respectively, as can be seen in Fig. 2-6.
,IP terms a asd d act as scal e f actors as noted earlier . Thus, the general
2 x 2 rotrix produces a ooub ination of shearing and sca.lintJ.
It is a l so possibl e to easily det:errrU.nc the area o f the parallelogram
J\*ti• C*O• shown in F'i.g . 2-6 . 'Ibe area within the parallelogram can be calculated
POINI'S PND L.INES 35

..
l •

I
tJ' u
~-
- -x
I

a Before b After

Figure 2-6 General t.rar.sfomatian of unit square.

as follc:MS :
~ • (a t- c) (b + d) -j{ab) - i(cb) -¥(b + b + d) - ~(c + a + c)
which yiel ds
(2-22)

It can be shown that the area of any t.ransfoJJTed parallelogram~ is a function


of the transformatioo natrix det:e.J:rninant aro is related to the area of the
initial square ~ by the sinple relationship

(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)

'!his is a useful technique for de~ the areas of arl:atrary shapes.

2-14 AAB ITRARV 2 X 2 l'bTATI~ r•'ATRJX

'lhe general 2 x 2 rrat.rix which results in pure rotation of a figure about


36 ~~ICAL £IEJ.fm'S FnR CCl.rorER GAAPHICS

the origm can be obtained by consider-


ing the rotation o f the unit square about
the Origl.n . 'lhis is sl'loNn in Fig. 2-7
for positive rotation in tl'.e c:ounter:clock-
wise direction . Figure 2-7 stXJWS that
p:>int B, [1 01 , is transfomed to the
po-1.1\t B*, with x* = (l)c:osa andy* =
))
{l)sme and that p:>int o, [0 ll, is
transfonred to D*, with x• = -(l)sin6
and y* = (l)cose . Recalhng our previous
cbservatjoo that for an amitraxy 2 X 2
transfol:I'Mtion rratrix the cxordinates of
B* nust equal the first ro-o• in the trans-
fot:mation matrix and the coordinates of
..
_..,. ;
D* form the second roN, the general 2 x 2
rotation rratrix is
I c:os9 sinA] (2-25)
- • - _.._______...0....__ ~B X )...
[:-sin p cos 6
0 I
For the special case of 90°, this reduces

Figure 2-7 lbtat.J.on to the result t!Sed earlier in Sec. 2- 9,


of unit square. i.e.,

[_~ ~]
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.

2-15 Two-DJtelSI<lW... TRANSLATIOOS AND ~EOUS CooRDI NATES .

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

Figure 2-8 Geatetric representation of


hoiT'Ogeneous c::x:ord.ir.ates •

vector, or in general the representation of an n-a:a,pJnent vector by an n + l


cx:arp:>nent vector, is called J:orogeneouc oool'dinat<? representation. In harogen-
oous a:xn:'Cti.nate representation the transfonration of n-diJrensional vectors is
pcrfonred in (n + l) diJrensiooal. space, and the transfot1ted n-dirrensior.al results
are cbta.ined by projection back into the particular n-dirrens.l..OnAl. spaoe of in-
terest . 'lhus, m 0..0 dirren.sions the position vector !x y) is represented by
the three-cx:nTpOnent vector (hx hy h]. '1he extra ccttpJnent in the vector acts
like an additional c::x:ordinate . '111e ordi.nacy or "physl.cal" cx:x:>rdi.nates are re-
lated to the hcrrogeneoos ooordinates by

X • ~ and y = ~ (2- 28)

'Ihere is no unique haroge.ne::>us c::x:otdinate representation of a point in


tw::>-dilrensl.Onal spaoe . For ex.anple, the lnrogeneous c::x:ordinates (12 8 4],
[6 4 2], and (3 2 1] all represent the ordinary point [3 2] . For ease
of calculation we dloose [x y 1) to represent a rontransfonred powt in bolO
dirensional houoycneous OXJrdinates . 'then the transtormation*
r~ y*J - rx yJ

*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

in regular coordinates is given by


(X Y Hl = [x y 1] b 0

in hatogeneous coordinateS. carxying out the above two t.ra.n::>fotmaLions sllOoiS


that X = x*, Y = y«, and H .,. l. 'lhat is, since the addi banal conrdi.nate II is
unity, the transfonrod hatogeneous coordinates are the sasro as the transforrred
ordinary coordinates. In general, H 1- 1, and the transferr-ed ortli.nary coordi-
nates are d>t.ainOO by noxnallzin<} the transfomed hatogeneous coordinatr$, e.g.,

x* .. ~ and y* - ~ (2-29)

In a gearet.rical sense, all transfor:mations of x andy fall within the plane


H=l after normalization of the transfonred hatogeneous coordinat.cs.
'n\c advantage of i.nt.rcrlucir¥j honogeneous coordinates occurs in Ute qene.ral
3 x 3 trans formation rMtr.ix
a b p
c d q
m n s
where space is new available to include other traJ"I.sfoxnations such as translation.
n-.e scaling and shearing effects of the IMtri.x terns a, b, c , and d have bc-€0
sho.m previously.
To sb:w the effect of the t:him colunn in the 3 x 3 transformatioo matrix,
consider the follOioling operation:
[X Y H} = [x y 11 1 0 p = Lx y (px + qy + 1)) (2-34)

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

Letting p • q • l.O and USl.f¥1 [X>ints A, [1 3) and B, (4 1} sho.m in Fig. 2-9


gives
.) '
4

>"

2-

( . ,
-
(
-'-7'~o·- . - II I

. ..
' A

Figure 2-9 Transfoma+ion in harogeneoos coordinates .

for the transfoil'I'Ution and projection of A to C* , and


4 2 1
:x* •l+- 4+l =J and y*=6
for the transfomation and projection of B to D* . '!be harogeneals coordinates
for C* and D* sN:Ml in Fig . 2- 9 are (1/5 3/ 5 l) aJ".d [2/3 1/6 1) respectively .
'Jlle effece of rottralid.ng is to project the th.ree-di.Jrensional line rn back onto
a two-cllirensional line C*D* in the plane H = 1.0. As shown in Fig . 2-9 , the
center of projection is the origin .
'Ihe C}eneral 3 x 3 t:ransforrration matri.'< far O.'()-(llirensiona.l honogeneous
mordinates Cdl\ be subdivided into four parts:
ra b 1 p
I
C d 1 q
-m ----
n ' s 1

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

Here , X = x, Y :: y , and H = s . '1his gives


X
~--
9

'lhe effective transformation is [x y 1] • (x/s y/s l}, a unifo tm scaling of


the p:liSition vector. If s < 1, then an enla..r:gen:mt occurs, and J.f s > 1, a re-
ductioo in scale occurs.

2-16 Po iNTS AT INFINllY

The use of harogeneous (X)Qrd.inates gives a oonvenient and efficient ..,ay


of rrapping a set of (X)ints fl:un one coordinate system into a oorresponding set
in an alternate exx>rdinat:e system. usually the infinite ranqe o f one ooordinate
system will rrap into a finite range within the second coordinate system. 1\l.so,
lines which are parallel in one system will usually not be parallel in the ot:l1cr .
Hoo.oever, geatetrical prcperties such as p:>ints of intersection can be evaluated
in either (X)Qrdinate system as s.ho.m bela¥" .
'Ihe O..Q lines given by
x+y •1
2:x+3y=O
have a p:>int of intersection at x .. 3/5, y .,. 2/5 . '!his solution can be cbtain-
ed in terms of the horToge.neous ooordi.nates. By rewriting the equations as
x + y - 1 • 0; 2x - 3y = 0 it is possible to represent the bolo equations by the
matrix equation

[x y 1) 1 2 ; [0 0)
1 -3
l-1 0
Ho..oever, for a matrix to have an inverse it must be square . '!1)e follc:Ming rep-
resentation of the sane set of equations can be used to rreet this rcquirenent;
(X y 1) r 1 2 0 e [0 0 1] (2-31)
1 -3 0
l-1 0 1
The inverse of this square matrix M is

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

1/100 400 300 4 3


[4 3 0) in hCiroqeneous ooordinates. It follows that the position vector


(1 0 OJ represents a point at infinity on the x*-axis and [0 1 0) represents
a point at infinity on the y-axis. In this rranner horrogeneous ooordi..nAtes
give a convenient representation of points at infinity in addition to the cap-
ability for ~ali zed transformations .

2-17 T\'K>-DweNstONAL fbTATION ABolJT AA ARBITRARY Axts


Previously <Ne have considered rotations as ~ about the origin .
Han:>geneous cx::ordinates provide a JreChanism for aCCX)Itplish.ing rot:ations about
points other than the origin. In general a rotation about an amitrary point
can be acc:atplished l:7j first translating the center of rotation the origin, to
performing the required rotation, and then translating the result back to the
original center of rotation. 'ltlus, rotation of the position vector (x y 1)
about the point m, n through an arbitrary angle can be ao::ntplished l:7j
(x y 1] 1
0
0 0 rc:ose
-sine
sine
cos a
01 r1 0
1
0 • (X 'i H) (2-34)

~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 \
\
\ .,.,. ~


\ .. I I

>"\ }'
OOSil sim 0
. \
-smn coso 0 \
0 0 ] \
\ ... ... ..>..

,..J
\
... •

'

Figure 2-10 ROtation .


CHAPTER 3
THREE DIMENSIONAL
TRANSFORl\fATIONS
AND PROJECTIONS

3-1 INTROOXT I00

The ability to represent or display a t:hree-d.ir'Cnsional object is fundalren-


t:a::l to the understanding of the shape of that ooject . Fu.rt:herlrore, the ability
tO rotate, translate, and project views of that object is also, 1.n mmy cases,
f~W to the underst.an1.i.r¥J of its shape. nus .1s easily c:lErnlstrated by
picking up a relat.h.-ely c:ancJlex unfamll.iar object. Imrediately one rotates it,
oolds it at ann• s length, stands back fran .it, etc ., in order to obtain an under-
starding of its sh8pe. To oo this with a mcputer we rrust extend our previous
t:wo-d..ironsia-.al analyses to three dim.msions . Based on our previous experience
we imrali.atcly introduce N::rrogeneous exx>rd.i.nates. Hence a point in ~
diJrens1onal space (x y z) is represented by a four-dimensional pos1.tion vector
lx y z 1) or IX Y z H). Again the transfonration f:n::n N::rrogcneoos coordinates
to ordinary coordinates is given 17.1
[X Y Z H) • (x y z l)T

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

'llle 3 x 3 ootrix produces a linear transfomation* in the tonn of scaling, shear-


ing, arrl rotation. The 1 x 3 row matrix produces translation, and the 3 x 1
oolunn matrix prcxluces perspective transformation. ThL final single e 1mcnt pro-
duces overall scaling. 'Ihc total transfonmtion obtained by op&Bt..i.ng on a posi-
tion vector with the 4 x 4 matrix arrl normali2ir¥3 the transfomed vector i.s
called a bilinear transfomation. nus gives a cutbinatioo of slwari71!,, weal
scaliff(l, l'Otal.i.on, rej'lection, translation, per'BiX"Ct.iVl, and WnY111 cwatitlfl.

3-2 Tffi.EE-D WENS IONAL ScALI t-.6

The d.i.agooal terms o f the general 4 x 4 transfonrauon produce local ard


overall scaling . Consider
(x y z 1] a 0 0 0 = [ax ey j z 1] : [x* y* 2* 1] (3-3)
0 e 0 0
0 0 j 0
0 0 0 1
wch sln-ls the local scaling effect. Figure 3-la shows a parallelepiped r e-
scaled as a unit. cube. Overall scaling is obtained by using the fourth diagonal
elerent, i.e.,
(x y 2 11 1 0 0 0 = [x y z s]
0 1 0 0
0 0 1 0
0 0 0 sj
= (x* y"* z* 11 • (~ l.! 11
s s s

A linear trcmsformation is ale \<AU.ch transfonns an initial linear carhi.nation


-
of vectors into the sane l.inoar canbinatioo of transforrrud vectors.
1. • 0 ll I fi 0 0 0 •
•· o1a
• c.lOl o;oe 0 l DI
t• S l I 0 0 l 0 011 ~ r
' 2001 •OOC1 I 0 0 I I
f9 20:1 1 o1 1 r
: ) 0 l llClC
1' ,1 I l ). 1 I 1 I I

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, •

,.

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

3-3 T~E-DIMENSI<JW. Sl£AAJNG

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.

3-4 T~EE-DI~I<JW. RoTATIONS

In the previous sections we saw that a 3 x 3 cx:up:lC'lent matrix produced a


CXlibinatioo o f Si2ling and shear. lt:lwever, i f the deteminant (cf Appen:lix B)
of tbe 3 x 3 oc::mpcnent matrix is +1, then it produces a pure rotation about
the origin. Before considering the general case of ional rotation
about an arbitrary axis, we examine several special cases.
In a rotation about thex-ax.is, the x-d.irrensians oo not cl'la.NJe. 'lbls, the
transformation matrix will have zeros in the first row and first co1l.llm, except
for unity oo the main diagonal. The other tenn9 are determined by considering
the rotation of a unit cube in the same m:mner as discussed in Sec. 2-13. 'lhis
leads to the t:ransfontatioo matrix for a rotatioo of angle e about the x-axis
given by
T= 1 0 0 0 (3-6)

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.

3-5 REfLECTIOO IN Tt«E DWENSIOOS

Sc:m:! orientatioo.s o ( a three diJren.s.i.oo.al object require reflections. In


three ctitrensions the sizrplest reflectia\S occur through a plane. For a rigid-
) . ~ ..

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

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*

· ensiooa.l ref1ectioo through the xy-plane.


Figure 3-4 'Ihl::ee-d.i.rr

body re.f1ectioo the determinant of the reflectioo transformatioo will be -1.0.


In a reflectioo through the xy-plane, only the z~.rdi.nate values of the
cbject ' s positioo vectors will be cl>.anqed. In fact they will be reversed in
sign. Thus, the transfonratioo ratrix for a reflectioo through the xy-plane is
T = 1 0 0 0 (3-11)
0 1 0 0
0 0 -1 0
0 0 0 0
54 l'~CAL ~ FOR a:t-tPlTI'ER GRAPHICS

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.

3-6 TRANSLATIOO IN TJ-REE DWENSICJIJS

Three-dimensional translation is obtained by writing


[X Y Z H) • [x y z 1] r1 0 0 0 (3-14)
0 1 0 0
0 0 1 0
t mn 1
t'lhen expanded this yields
' [X Y z H) = I (x + t) (y + m) (z + n) 11 (3- 15)
• It follo,.s that
x"' • ~
H
• x+ ~ (3- 16)

y* = 'i = Y+m
H
z"' - !H = z + n
An a1gorithn for translations in three dimonsions appears in l\ppe1¥ii.x c.

3-7 T~-REE-D U-1ENSIOML RoTATIOOS ABOOT ~ AABITRARY Ax iS

The rrcthod of O.t>-dirnensional plane rotation D'to.lt an arbitrary axis was


discussed m sec. 2-7. The generalization of that probl em is rotation about any
axis in t.hr~sional space. Again , the procedure is to translate tte ob-
ject and the desired axis of rotatioo so that the rotation is made about an axis
passing l.hrouqh the origin of the ooordinate system. The rrethcxl invol ves a
th~im:!ns1onal translat1oo, a rotatioo a'to.lt the origin, and a translation
bdck to ~ init.LAl positioo. 1f the axis about "'hlch rotation is desi.rEd
passes throu.g h the }X>int A • It m n 1] , then the form of the transformat.ioo
rratrix is
(X Y Z H) = (x y z 1] 1 0 0 0 r1o o o (3-17)
0 1 0 0 0 1 0 0
R
0 0 1 0 0 0 1 0
-t -11\ -n 1 t mn 1
where the eleSJents in the 4x4 rotation matrix R are in geroral given by

2
n1 + (1 - '1 2l008 D n1 ~ (l - oosO) • n 3sJ..ne ~n 3 (1 - 008) - "2~1n 0 (3-18)

(R) Q n1 ~(1 - cos9) - n sJ.r,(, n-/ + (1-


3
n/)~ ~n3 (1- C060) + n 1 sintJ 0

n1 ~(l - 0066) + "2s.J..nk n n (1- cosO) - "ls.inO n 1


2 3
2
~ (1 - n
3
2
)0C1Sll o

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.

3-8 Ei.&Etfl'S FOO n£ taERAL RoTATIOO f"AlRn<*

We begin by considering Fig . J-5, whid1 sho,.;s an arbitrary axis of rotation


(Q'l) transl ated so that it passes through the origin. We then rotate a }X>int oo
tl1e translated cbject (5\d\ as }X>int P) about the axis by an angle u. This will
JTOve the }X>int fran P to P* . In Fig . 3-5, PQ = P*Q, and both of these lines arc
perpendicular to oo. P•s
cx::nst..ruct.ed to be parpendic:ular to PQ. To deter-
J.S

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,

*1hl.s scctioo rmy be Oll'li.tt.ed withoutloss of mntinuity.


a..--d y are 1der.t;.fied 1.n Fig. 3-5 . ':he d.irection cosines are tOO t..ltree ~ts

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

':1le t:.it vector is


-
tr.e.'l given by
n .. "11 "2J.... + nl~
...,..

-
-
!.."'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

P. = Q+ <P - Q) cose + sP*


'l1le nagn i tude of SP111 is equal to

SP* - loP,sine >= IP - olsine


'nle ch.rection of s'P• is · to the plane F'Ctl and is therefore
parallel to the vector ~ x P. 'Jbe unit vector m this direction is

•u= nxP
.. .. -
...nxP.•
... ..
1n x PI IP i sin~
- -
SP• -
n• x P•
p Str.~
-.
p - Q Sl.n J

rut P)sW = loP! zo IP - • aro thus

~ ~ 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 •

p• a {P·n)n(l - cose) + Peose + (n X P)sine


As r~, this ~tion gives the transfor ned pomt 1.n terms of the iru.tial
point, the angle of rotatioo , a."ld the d.i..rectioo o f the axis o f rotation. we ro.~
:.trite this result m rot.n.x form.
l!smg the Ntrl.X ex-press~oo give."\ earlier for the dot pro:3uct (P· n ) ard for
... .
the cross product (n
x P), the equat.iC!'l for p• beo::m...>S

~ · • (x y z) n
1 !~1 ~ n3J (l - COS7) • (x y z ~ t lx y zl 0 n 3 -n 2 Sln (3- 23)
n -r. 0 n
2 3 1
. r.l l "2 -'1 0
~ em ~ writte."'l in a."'l equi\'81ent form usi.'\9 hatt:a;ie.neous coordil'...ates :
2
P '"' (X )' ~ l) r n1 r1 n 2 nl':l 0 Cl - COS• J • r 1 0 0 0 C08 + " " ~ -n 2 0 SUl ()- 24)
2
r:l:-"2 ~ n2"3 0 0 10 0 -n3 0
2
t n1 "J "2"3 n3 0 0 0 1 0

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

It 1s seen th.::lt to pro:lt.X:'C .a general rotat.lcra by use of F.q. (3-17) , the (x y z )


O'.:lOrdinates of t.'ll2 JX)int P, t!le directioo oosiJ'les of t.lx! u.xis of rotatioo
ln 1 ~ n l, and the angle of rotat:a dbout the ax1s are neOOod to defl.ne (RJ.
As a spcc1hc exa:rple consider rotat.J.oc al:ntt t.~ z-<lX.ls. '~hen n = 0, ~ = O,
1
an::l n • 1.0. For this spt..>cial c1se t.~ rotaticra r .:ttrix R b..~
3

THREE-OIMNSIQW.. "l'AANSFC>Rt-17\TIOOS AND PI'D.': 'cr'l'IQS 59

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.

3-9 AFF1NE PMJ PeRsPECT 1VE GEa-t: 1RY

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.

3-10 AxoMMT'RIC PRoJECTIOOS

An axonanetric projectioo is produced by an affi!le transforrration which has


a zero value for its determinant. 'lhere are several different types of a>a::lOCI'OOt-
ric projections which find applicatioo l.l'\ descriptiw gearotry o.nd engineering
draftl.ng. I"Mt:.herratically form an axonaootric projection, the 4 x 4 transfo.rm-
To
atioo matrix is used to pxcdu::e an affine transforrratioo on a set of p:>ints .
.. 'n1e p:>mts are then projected onto a plane frun a center of projection at infin-
ity. 'l1le canton axonarotric projecticns are classified in Table 3-l.

'nsble 3-1
Ax.onc::r.etric Proj ecti<XlS

Pro)ec:tl.on

Trilrotric The trans£orrratioo matrix causes pure


rotatioo. 'Ihus, the coordl.nate axes
remrln orthogonal ~'hen projected
Oiztetric Two of the three axes are equally
foreshortened when projected
Isaretric All three axes are equally foreshort-
ened when projected

J\Xl:lnc::lrotric projectioos ~ shown in Fig. 3- 2 and 3-3. An axonaret.ric


projection fran tlu:ee-c:l.inenional space onto a plane z • n can be obta.i ned by
the followll"'9 operatioo:
(X Y Z H) = {x y z 1) 1 0 0 01 "" (x y n 1) (3-25)
0 1 0 0
0 0 0 OJ
0 0 n 1
'Ihcn,
[X* y* z• 1) a (X y n 1)
Notio:! that. this transfoD1'1<'1tiOO ~ts a translatiOn in the z~on
by the amJU'lt n CJ1vP..n by the transfomatioo
l

'l'HRai-OINENSlOW. TRANSFOffofATIOOS AND PR:mX:TIOOS 61

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·

B" D"t -- - --e i " J"

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 .

(X Y Z H] = [x y z 1} coso sm¢sin6 -si.n9cose oo] (3-26)


0 cos9 sine

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~

'Ibe maqn1.tudc of the transfoi'T"Cd ~s lD'lit vectOr is T'OII

cos &= cose


'lb create a dilretric projectioo, the I!B<plibx:le of the b.Q transforrmd unit
vectors is shortened by an equal mount. El:]uating thL magnitude of the x- and
y-axi.s wctors yields
oos2¢ + sin ~sin e
2 2
: cos2e
2
Usi.n.J the identities cos ¢ =1 - sin2~ 2
and cos & = l - sm2 e, it follo..'S that
. 2,. sin2e
SJ.I\ " = . 2 (3-27)
1 - sm e
\-lhen the value of sine is crosen, and ~ is calculated by the use o[ D:J. (3-27),
the matrix in F.q. {3-26) produces a d.imetric projection.
now consider a specific e.xanple far a di.rretric projectioo. Qle rrotln:l
\lie
of choosing sine is to shorten the z-axis by a fixed mrount. Consider the unit.
vector on the z-axis, [0 0 1 1) . 'Ibis transforms to
[X Y z H} = (sincj. -cos~sine cos¢cose 1)

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~

For sin6 = /i73, sin2~ 2


• 1/2, and cos ¢. .. l/2, this angle is
1
Q = tan- (-;) = 30°

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

Pro)ec+..l.O'l Oeser iptioo

cavalier '1\.Q axes appear perpendlcu.lar and are not


foresrort.enerl; the third axis is inclined
with respect to the horizontal and is not
fore.sOOrtened

A special case of the cavalier projectioo


in which the third axis i s foreshortened
by a factor of 1/2

AI: algo.nthn for sirrple projections is given in .AppeD::lix c.


A trirretric projectioo can be abtai1led by using the three-dim.:msional
rotation alg:>ritlrs presented previously followed by the sinpl e projectioo
c.. lllg:>rithm given al:x>ve .
An alg:>ritl'ITI which inplerrents the specific diJrotric and isaretric transf or-
TI'ittion rratrioes discussed above [i.e. , Eq. (3- 26) with P • 20 . 70481P ,
: = 22.20765° and ~ • 35.26439, ~ = ~so respectively} and assuming projection
on the z • 0 plane is give.'\ in Appendix c.

3-ll PERsPECTIVE TRANs~rta-ts

As previously nentioned, nonzero elements in the first three ro.~S of the


last co1um o f the 4 x 4 transformatioo rratrix yield a perspective transforma-
tion. A perspective projection is obtained by ooncatenatioo of a perspective
transformat.l.on foll~-ed by a pro)ectial onto sare two-dirren.sic:nal "vie.r.ri.n9"
plane. A perspective projectioo onto the z = 0 plane is given by tho transf o r-
rration
(X Y z H] = [x y z 1] 1 0 0 0 = (x y 0 (rz + 1)) (3-29)
0 1 0 0
0 0 0 r
0 0 0 1
'Ibe ordinary transfol'li'Od coordinates arc t.l)en

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

'F' y Figure 3-8 Perspective projectial


2 (3-31) of a point.
z .. 1
k
'Ibese are tho transform.."<! cxxmiinates produced by the rrat.rix operation with
r • l/k. This cperatJ.a'l produoes a perspective projectl.al on tl'lC' z .. 0 plane
fran a center of projoctial located at z =-k. In a perspective transfotmatial
the transfonrod space is rot Euclidean, since orthoqalaliLy of lhc a>-.cs is not
preserved. !l.ft'\en k approaches J.nfinity, the ~tric Lransforrralion discussed
above is cbt:ained .
Equations (3-30) and (3-31) sho.ol that when z = 0, then x• = x, andy* --' y.
rx.e to this iclentJ. ty transforn'at.ion, p:>ints in the viewing pl ane z "' 0 are not
changed by a perspective projection . 'Ihis is ooly true, rc.•~vcr. when the horro-
gencous ooord.inatc H is unity after the transfol:malicn has been a,wlied to a
p:>int [x y z l j . Since aff.inc transfo:rmal.ians retain a value of nnity for II,
a perspective transfornatial 11'\lY be preceded by an arbitrary sequcncc of affine
transfoi"'T''ltions. Thus , to obtain perspective views fran an arbit.rary view point,
affine t.ransformst.i.als are first. used to establish a ooordi.natc system with the
z- aJU.S al<nJ the desired line of sl.ght; then the pcrspccbve transforrrutioo i.s
applied and a projectiw transformation is used to project the total set of
p:>wt.s alto the viewing plane z • 0 of the current coordlllAte syst.ern. In prac-
tice , it is often l'lCO'Ss.cny to apply further affine transfornutl.ons to scale
and positton the proJected new (~f . 3-3).
Above we have considered projectioo onto tl¥3 2 • 0 plane . fb..-eve.r 1 this
ray not a!.wars be desiiable . Q1e reason is that projectioo onto the 2 • 0 plane
loses the 2~rchnated infanration which can be useful in controll.ing the
bnghtness o f displayed points oo a plane (Pef. J-4 ). To include the 2-coordinate
infoOM.tion the perspective transfomation
(X Y z H) E {x y z 1) 1 0 0 0 Q lx y z (rz + 1)]
0 1 0 0
0 0 1 r
00 0 1

rx * Y* 2 * 1) -
-
{ X y Z
rz+lrz+lrz+l 1] (3- 33)

rrey be used and the full · ional results obta.ined.


Here we note that the origin of the coordinate system ro 0 0 1] ls again
unch.ancJed. Notice that the point At infinity a'\ the Z-axi.s l ro 0 1 0] 1 '('0;1

uansfoms to the noninfinite p-.>int [X Y z R] = [0 0 1 r) w.ith the ordinary


o:x:m:U.nates [x* y* z* lJ • [0 0 lfr l], i.e . , a finite point m the z*-axis .
nus rreans that the entire positive half of the dcrrain co ~ z ~ '"') is projected
within a finite danain (0 ~ z• ~ 1/ r ) .
Further, lines which were originally
parallel to the z-axi.s will rv::J;~ app>ar to pass throught the point [0 0 l/r 11 .
This point is frequently cal l ed the
%I a
vanishing point of the perspective
transfomation. \\hen the results o f
the transformaticn are projected onto
l n11ial
,.. It n c:
a plane, a perspective projection as
rre."''tiooed arove is obtained . Assuni.ng
that the z = 0 plane is the projectioo
plane, the center of projectioo is
A located on the sarre axis as the vanish-

ing p:>int at an equal distance on the
opposite side of the zero plane; i.e .,
i f the vanishing point is located at
z • l/r oo the z-axi.s, the center of
projection is located at z :: - 1/r oo
the z-axis. 'lhi.s is s.~n m Fig.
3-9.

~
Similarly the perspective trans-
·t , fooration
Cen 1cr t )f
p• QJC:CI•on

Figure 3-9 P.roJectiat of a line


parallel to the z-axis.
~I'IOOS 1\ND POOJfel'IQIS 69

(X Y Z H) z (x y z 11 10 0 0 - [x y z (qy + l)J (3-34)


O l Oq
0 0 1 0
0 0 .0 l
with ordinary coord.in.ates
(x• y• z* 11 = [qy+1qy+lqy+l
x Y z 11 (3-35)

will result in a vanish.i.ng point located oo the y-axis at [0 l/q o 11,


perspective transfonnatioo
rx Y Z H) = [x y z 1] 1 0 0p (3-36)
0 1 0 0
0 0 1 0
0 0 0 1

= (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

[x* y* z* 11 "" [px + ~+ 1 px + ~+1 px + ~ + 11 (3-39)

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. ~

c 0 1 1 1 0 0 1 0 0 0 0 0 -o. s 0.5 0 1.1 C" -0.455 0.455 0 1 c•


D 0 1 0 1 -o.5 4>.5 0 l 0001 -0. 5 0. 5 0 1.1 D" -o.4S5 0.455 0 1 c-
E 1 0 0 1 o.s -o.s 0 1.1 E* 0.455 -0.455 0 1 E"'
F 1 0 1 1 o.5 -o.s 0 1.1 f"' 0.455 -0.455 0 1~
G 1 1 1 1 0. 5 0.5 0 1.2 c• 0.417 0. 417 0 1 G-
I 1 1 0 l 0.5 0. 5 0 1.2 r• 0.417 0.417 0 1 r•

Fiqure 3-ll 'IWo-p:>.int pe.rspectivcs.


proJc<:Ud onto the z • 0 pl.ane. In Fig. 3- ll.a, t !\e vanishing p::>ints aro at the
x-a.x.is at x - 10 aro on the y- axis at y • 10. If ""-e first center the z- axis
with r~ to the front face as s.~n in Fig. 3-l lb, a suitable t\olo-point
p:::rspective is still rot obtair.ed. 'tt'.is is du: to the fac t that the obJect
sh::lu.ld fl.rst be rotated aboot the y- ax.l.S in order to attai n an esthetically
pl&'!SJ..."lg t:w:>-pol.Tit per~ve . '!his is discussed later .
I!: three te.rrS in the 4 x 1 coh..-:n fl"atriY. are nonzero, then a t:hree-pomt
or obL.que ~...ive is obtained . The throe-point pe.rspective transfo rmation
(X y z 11 = (x yz 11r1 0 0 p, ~ [x y z (px + qy + rz + 1) (3-40)
0 1 0 q
0 ol rJ •
~0 0 0 1~
w~th o:rd.ina.r:'J a:x>rdinates

(x• y • z- 1) • [px + qyx+ rz + l px + qy + rz + 1 px + qyz+ rz + 1 1) (3-41)


results L"l t.i-.ree vanishing pomts : one at the x-axis at (1/p 0 0 1 ), one on
the y-axis at [0 1/q 0 1), and one at the z- axis at (O 0 1/r 1). A three-point
perspec"'_ive vie-N of a unit cube is sl'~•n l.TI Fl.g . 3-12 . 'Ihe r esults are proJected
onto the z = 0 plane . In Fig . 3-12 the throe vanishing points are located on
the x-axis at x = 10, on the y-axis a t y • 10 , and on the z-a.x.is at z "' - 10.
Po5itioo PosJ.t:.1 on ~tm'll ized PoSJ.-
Vectors vectors ot t.ia'l Vector s o f
of Ori9- Trans forma- Trnnsfocrcd Transf oLHed
inal C\.lbo uon :-auix Cl.lbe Cl:be
A 0: 0 0 1 1 0 0 0.1 - 0 0 0 1 A• "' 0 0 0 1 A•
9 0 0 1 1 0 l 00.1 o o o 0. 9 a• 0 0 0 1 8"
c 0 1 !. 1 0 0 0 -0.1 o 1 o 1 c• 0 l 0 1 c-
D 0 1 0 1 0 0 0 1 o 1 o 1.1 o• 0 0.91 0 1 o•
£ 1 0 0 1 l 0 0 1. 1 E• 0.91 0 0 l ~

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•

) . )" Tc. \ Pion)·•nn


Dr-----.' c ·~----G" a1 >-10
o··- --c-I "'-." -- -
,, " T u VP2 on ~-.u.•~
,., "'
Tn \ Pl on , •• ," .H 11. IC'
lll I • ·IU
A .- --+--~-­
E ~

u,. .,
l
I

Figure 3-12 Three-point perspcctJ.ves .

3-12 TEOtH<US ~ f£NERATING PERsPeCTIVE VIEWS

h1len a perspective viLv of an cbject is created, the horizontal reference


line is norrrally at eye level, as shown in Fig. 3-13. Vanishing p:>ints arc then
p:>ints oo the horizon line (eye level) at which parallel lines converge. Figure
3-14a shows heM the vanishing p:>ints are forned. In genenU. , different sets o f
parallel lines will have different vanishing points. This l.S illustrated w
Fig . 3- 14b. Planes of an ooject which are tilted in relation to the ground
plane have vanishing points which can fall above or below the horizon eye level.
'ltlese are often called trace points and are sluwn in Fig. 3-14c .
\\hen viewing a CRl' display the positi.oo of the viCWJX>int or eye is normdly
fixed . 'Ihus , rather than rroving the viewpoint to ootain an acceptable perspec-
tive view, it is comon to ITW'Iipulate the position ard orientation of the OO)ect
displayed on the CRT. This will normally require ooe or rrare rotatials and
translatioo.s of the object.
As we have seen, i f the viewing point is on a line normli to the center of
a wti.t cube face, then a single-point perspective "looks rl<Jht." In this view
all reoed.i.ng ~!.anes con'll'er9e to one vanishing point oo the horizontal eye-level
line, and all perpendiculars are drawn as true vertl.cdls. 'n1e front and back
cube faces are parallel to the picture plan and do not converge.

Papel

VP
- - - - - - - - - -Hor11on- -
1- yc lc\C I
-

St.liHIO po1nl

Figure 3-13 Perspective t.ransfoll!Ution to paper.


H r r
-
\P
-
\P

-- -

- •

(
,.

\p - -~

<::-::>
-- - -
~

-
' --- - -- -- ~

:cr •;;In.o..:s ::ltlra:lel



L.-.es .

-
- --
- - ------
-- -- --
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

For e- 60° 1 m :- 12, n : 1, an0 k = 1 , this matrix Of transfomcd, horrogcncous


ooordl.nates is
ro -2 o2
0.86 -2 0 2 . 5
0 . 86 -1 0 2.5
0 -1 0 2
I
o.s -2 o 1.14
1. 36 - 2 0 1. 64
l.36 -1 0 1.64
l
0 . 5 -1 0 1.14
!ben, since

[X"' •'*
I
1] - H !B
[! ll

the! proJected pcn.nts x•, y• are given by


0 -1.0
0. 344 -0.8 •

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

oose o - sine -sine


k
,.. 0 1 0 0

sine 0 oose cose


k
0 m n !!+1
k

Vfl l VP1

_.-~I
....-- // I
_, /" " I I
-'/ I
/(
I
I e .. 60°
I m • -2
I
I
n • 1
k. 1

Figure 3- 15 Perspective transfonnatioo .


different axes. For exanpl e , one might rotate 6 degrees about they-axis and
then ~ degrees about the x-axis before applying the perspect i ve transfooretim .
A cooplete set of transfo:anatia'\5 on a unit cube to obtain a three-point per-
spective is then

1 000 .,..., o-....c 0 I c 0 0 1 0 0 0 • <X>J'? ....~ .. w -1


~-·
..,..
-
0
0 1 00
00 1 0 ~
0

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 ~._..-

- • rrnr ..,... • ( l&1rl' - """'0 II w 0


..
I • ~Ulll • C.lrl'i • f!!:!'"l

3-13 PoiNTS AT INFINITY

To sho,..t rrore clearly \~t has happened to points at infinity, consider


the following exanple.

'Ihree po1nts are given by 11 0 0 OJ , (0 1 0 OJ , and [0 0 1 0]. These


wct:ors represent points at infinity on the x-, y- , and z- axes respectively.
!New, performing the boo-tx>int pe.rspective transformation, given by,
'"1 o o o· ·o.s o o -o. s6· g ·o.s o o -o.86
0 1 0 0 0 1 0 0 0 1 0 0
0 0 1 o. 0.86 0 0 0.5 0.86 0 0 0. 5
I
0 -2 0 2 .
Thus, the point at x =co transfoil'RS to x* • 0.5/-0.86 • -0 . 58 andy* • 0 .
This is the vanishing point VPl in Fig. 3- 15. 'lbe point at y .. oo transforms
to y* • oo, ari1 the point z •"" transfoxms to x* • 0 . 86/0 . 5 • 1.7 andy* ... 0.
This is the vanishing point VP2 in Fig. 3-15 . '1he result is that points at
infinity in me coordinate system have been t.ransfox:nel to finite FOints in a
second system by use of harogeneous ooon:hnates .

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.

3-14 RECONSTRU:T I(J.j OF T~-DIMENSIOOAL INFORI'IATIOO

'l11e reoonstructioo of a thrce-dinlmsional ooject or positioo in sp:x:e is


a ca11:al problem. It occurs c:ontirn.ously in utilizmg rrechanical drawings which
are orthographic projections. The rrethod of reconstructing a thl::ee-diltC'ISional
object or positioo frau o.o or nore views (orthographic projectioos) given on a
n'!Ciw\ical drS'Ning is well kno;.m. !Jo..-ever, the technique of reconstructing a
three-d:inl:msional position vector fran two perspective projectioos, for exanple,
,...
tw:> photographs is not as well koown. Of course if the trethod l..5 va 1 id for
perspective projcctioos, then it is also valid for the sin'pler orthographic
projectioos, and in fact for all the projections srentioned above. FUrther, as
~ will shc7,.. belON, i f certain other Womab..oo ~s available , then no direct
kno,..lcdge is required about the transfor:JMtion .
'Recall that the general perspective transfomation can be represented as
a gr>Jlet"al 4 x 4 nutrix. Thus
(x y z l)T ' e (X Y Z H) (3-42)
~re

T' = T' u T'tz T ' 13 T'14

T'21 T' 22 T'23 T'24

T' 31 T' 32 T' 33 T' 34

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)

T2l T22 0 T24


T31 T32 0 T34
T41 T42 O T44
It is useful to write the transformatioo, say,
[x y z 1) Til TU 0 T ::: (X 'i 0 1] (.3-44)
14
T21 T22 O T24
TJl T32 O T34

T41 T42 O T44

= [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)

(Tl2 - Tl4y*) x + (T22 - T24y")y + (T32 - T34y*)z + (T42 - T44y*) • 0 (3-47b)


As suggested by sutherland (Ref . 3-9) this pair of equatioos can be considered
in three d.ifferent ways . First assure T and x , y, z are knc7.-m . 'lhcn t..hero are
b.Q cquatims in the t:w:> unJ<no..ms x* and y*. 'lllus, they may be used to solve
directly for the ooordinates of the perspective projectioo. This is the approach
taken in all the previous discussions in this chapter .
Alternately T, x*, y* can be as.suted J<na..m. In this case \ole have two
equatioos in the three unJmown space cxx:>ntinates x, y, z. '!he system of equa-
ticns cannot be solved . fioNcvcr, i f b.u perspective proJecticns say t:w:> photo-
graphics are available , then F.q . (3-47) may be wn.tten for both proJectims.
ru.s y1clds
~~1 - ~4x*l)x + (T~ - ~4x«1)y + (~1 - ~4x*1)z + (~1 - ~4x*l) = 0
(-rfl - ~4y.1)x + (T~ - ~4~y + (~2 - ~l4y*1)~ + (~2 - rr!4y*l) = 0

1-?11 - ~4x*2)x + ~~1 - ~4X*2)y + (~1 - or;4x*2}z + (~1 - ~4x«2) = 0

(~2 - ~4y*2)X + (~22 - 'S~.,2)y + (T;2 - ~4y*2)Z + <-r!2 - ~4y*2) a 0

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

[A] "" ~ll - rri4X*l ~1 - T~4x«l T~l - ~4x*1

~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 )

(B] T = l~4x« 1 - ~l ~4y*l - ~2 ~4x« 2 - ~l ~4Y*2 - ~2]


Equatloo (3-48) represents four equations :in t.00 three unknown space o:x>.rdinates
x, y, z. The problen is over speci.fied and thus can be solved cnly in sane mean
or best fit sense.* '1hls is an extrerre1y pcJWerful technique for obta.ini.ng
threc-diJrcnsional positional data.

E:x..arrp1e 3-2: 'lliREE-DIMENSICNAL

Asslll'C that the rreasured position of a point in one perspective projec-


tioo is (0.3763 -0 . 8258 0 1] and in a second perspective projection is
[0.6548 0 0.2886 1]. The first perspective proJectioo transform1tloo is knc:7.m
to be the result of a 30° rotatioo about the y-ax.is follo.--ed by a 60° rotation

*l\ rean squares tit can be a:ltPJt.ed by solving the eqootioo


(A)T[A} (X) ~ (A)T(B)
~re (f\) T (A) is square and of the co.r:rect d.irrensian for (B) . In particular
I>!J=[(AJT[AJJ-l[AJT[s]. Note that i f no solutioo result.s, then the iJrposed
conditl.oos •'lre redl.l"ldant and no uni.que solutloo which qives a "least" error
concli tion f"..xJ.Sts.
arout the x-axis plus a translatioo of 2 units in the negative y-diJ:ectioo.
'Ihe point of projection is at z .,. 1, and the result is projected onto the z • o
plane.
'l1le second perspective projectioo is the result of a 30° rotat.ioo about
the x- and y-axes . The point of projection is at y ... 1, and the result ~
projected onto the y =- 0 plane. ~ and il are t!'l.ls

~ = o.s o o -0. 867 and ~ ~ o.867 o -o.s o


0 1 0 0 0.25 0 0. 433 0.867
0. 867 0 0 0.5 0.433 0 0.75 -0.5
0 -2 0 2 0 0 0 1
The A-flBtrix is then
[A] • 0. 826252 0 0.67885
-0 . 715969 1 0.4129
0. 867 -0.317712 0.7604
-0 . 5 0. 182784 -0 . 8943
and
[B)T e (0 . 7526 0. 3484 0.6548 0.2886)
'
solution yieldc: X ... [0 . 5 0. 5 0. 5] , i.e. , the center of a unit cube.

An al gorithm which utilizes this technique is given in Apperrlix C.


As a third way of CXX'lsidenng Eq . (3-47) \~ rote that if the location of
several points which awear in the perspective projcctioo are J<.no,.,n in object
space and in the perspective projection, then it is possilile to determine the
transfonnation elerrents, i.e. , the T .• ' s. 'Illese transfoD'I'atioo elerrents can
~J
subsequenUy be tt<ied to determine the location of ~ points using the
technique descritEd alxlve. To soe this ~ again examine Eq. (3-46), which nay
be rewritten as
Tllx + T2ly + T3lz + T41 - Tl4xx- - T24yx~ - T34zx* - T44x* = 0 (3-49a)

T12x + T2~ + T32 2 + T42 - Tl4xy* - T24yy* - T34~ + T44Y* • O (3-49b)

Asslll\ing that x• and y* as well as x, y, z are kno.-'1"1, the Eqs . (3-49a,b)


represent bolo equations in the 12 unknown transfornetioo elmcnts Tij. Apply-
ing these equations to six noncoplanar kruwn locat..ions in d:>Ject space and in
the pers?£tive projectial yields a system of U equations ~ U \11"\l<:Jn.m.s.
'1hese equations can be solved for the T .. •s. Thus we have determined the
~J
transfo.x:natian. Notice that in this case ro prior Jan..r1edqe of the transfor-
rration is required. I f , for ex.arcple, the pers?£tioe projections are photo-
gra{tl.s, neilher the locatioo nor the orientation of the carrera is required.
In matrix form the system of U equatioos can be written as
x1 0 -x1xl * yl 0 -yl~-- zl 0 -zlxl* 1 0 Xl * Tu • 0 (3- 50)
1 y •
0 xl -x1Y1* 0 yl -ylyl* 0 21 -zly1* 0
1 Tl2

~ 0 -x2~* y2 0 -y2X2* z2 0 -z2"2* l 0 X2• Tl4 I


0 x2 -x~ • 0 y2 -y~2· 0 z2 -zi'2* 0 1 y2 • T21
2
x3 0 -xyc3* y3 0 -y3X3* z3 0 -z 3x3• l 0 X3* T22
0 x3 - xy 3* 0 y3 -y3y3* 0 z 3 -zl'3• 0 1 y 3 * T24
)(4 0 -x4x4• y4 0 -y4x4* z4 0 -z4x4,. 1 0 X4* T31
0 )(4 - x4Y4• 0 y4 -y4Y/ 0 z4 -z4y/ 0 1 y 4 * T32

)(~ 0 -x5x5* Ys 0 -ys~· zs 0 -z5x5* 1 o ·x5• T34


0 xs -><sYs" 0 Ys -ysys* 0 zs - zsYs" 0 1 y * T41
5
)(6 0 -x6x6• y6 0 -y6x6* z6 0 -z6x6* 1 0 )(6 T42
0 x6 -x6y6* 0 y6 -y6y6* 0 26 -z6y6• 0 1 y6 T44
where the subscnpts correspc:nd to points WJ.th f<na.m locatioos. n:tuatioos
(3-50) can be written in nore c:x:.ttpact form as
(A I ] [T] :: 0

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.

Exanple 3-3: EI»ari'S fOR REXXhS'I'ROCTIQl

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

An algorithn which utilizes this technique is qiven in ~ C.


3-15 STEREOGRAPHIC ~CTJOO

Q1ce an object has bePn transfoxrred to a desired positioo, many techniques


can be used to actually display the abject. Tec::hniques such as shading, color-
ing , etc. , are frcquP_ntly device-Oependent and are .beyald the scope of this
book. Others, such as hicklen-l..ine reaoval and cliArlng can be acmtplished in
either software or ha.rdnare. Arother useful display technique is the use of
stereo pairs to create the illusi.oo of depth. Often stereogxaphic projection
can be used for this purpose rather than hidden-line rerroval. . Graphical output
of cnqineering struct:ures such as bridges and towers lend therreel ves nicely to
ste.r:eographic projcctloo . Also, the representation of three-dirrensi.onal
arra.nqerents such as piping systens, a.rchitect:ural designs, rredical >t:-ray
studies , the chcrni.cal structure of organic nolecules, and solid crystal oonfig-
uratio,s can be irrproved by the use of st:aJ::eographic projection .
Jn a stereoytafhic projectioo, a separate perspective view JTUSt be created
for each eye. Then a stereo viewer such as sho..ln in Fig. 3-16 can be used to
' view the apparent single thr · object. If desiied, a stereo~

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

Figure 3-16 stereo~ - Figure 3-17 stereograpuc perspectives.


-1
5. 0 Cll, the stereo angle is c • tan (5/50) = 5 . 71° . For a ste.roo vie-acr ~
let d be the scaled scparatioo distance betwetm tr.e eyes (cf Fig. 3-17). If
~ viewer has a focal length of k units, then the value of d .1s fixed by tl~
requ.i.reJtent tan-l (d/k) = 5 . 7l0 • 'lhus, d = k/10 i s required to 11'\;'lintam the
correct stereo angle c . To obtain this scaled eye-separation distance fr<r.1 a
single view o f the obj ect, a -+d/2 = +k/20 horizontal translatioo is ~rforrred
before creating the left-eye perpsective view and a -<1/2 = - k/20 oorizontal
transl.atioo is perfarrrcd baforo creating the right-eye perspective vie....
Before generating a stereogra{tlic projectioo it LS oonvenient to center
the object with respect to the z-ax:LS and then rotate i t about tile y- axis in
preparat.lon for a tw:>-point perspective, or about y and x in preparation for a
three- point perspective . One final pl;'E!Ca.utioo is advisable . ~tatioo rmy cause
sate of the points to be behind the p:>int of observatioo, z c k. 'lllcse over
tbe shoulder points cause a distortioo of perspective views. To prevent this a
final transl ation in the negative z-cl.irectia1 can be rradc to ensure that all
p:>ints on the object lie on o r behind the x*y*-plane, e . g ., -z* !._ 0. 'Ibese
preliminary operations result in re.~ positioo vectors \vhi.ch descr ibe the t.rans-
forned initial object.
To create a stereo pah, the rr.at.rix contai.n.ing the new posi tion vectors
l.S t.ransfonred by use o f the two matrices
Left eye Right eye
1 0 0 0 1 0 0 0
0 l 0 0 0 1 0 0
0 0 0 0 -~
k k
20 0 0 1 -20 0 0 0

'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

Figure 3-18 Intermediate Stereo Position.


'Ihc last ~rat.ia'l is to sep.-Lrate the two pcrspcctivc vie..rs by the p:rqer
di~ aloog the x-axis in order to place each view directly in front of the
proper e:;ye. As stnm m F~g. 3-18 , (X*)R l.S the average val~ between the
largest and S'T\l.Jlest value of x*R and (x")L is the averag-: value be~ the
largest ard smallest value of x*r.· t'e let. D = (X'*)L- (X*)R. The value of D
mJSt be calc.llatcd by searching the no:rr.ulizcd ~-val~s of each perspective

VJ.C:.l.

A final hori?.ontal transl.atioo in the x-directioo of L .. D + (E - 0)/2


for. t.">)c nght-eyc view and - L for the left-eye view places the stereo pair in
prqx>r positioo. 'Ille value of E is the actual eye separatioo distance for the
hll'\an observer, "~u,·c'.i i~ 1!6 :wale c f thr output device . for cxanple, i f
the final points for the right-eye view fall bet:..-een 2 !. ><P, < 4, arxl the final
pomt.s for the left-eye view fall ootwcen -4 ~ xt_ ~ -2 , then one might c:h;:x)se
to plot these two views on a standard sheet of paper, using a 10-unit scale
bet;...-een -s x* $.. 5. Then, the actual 5 an distanoe bet\.~ hunan eyes
l"n'lSurcd relativo to this scale o;..uuld be about E = 2 . 5. Q'le or two iterations
r.ay be useful to determine the best value of E to use.
An algor1tbn to generate a stereo pair for an ob)C'Ct wtu.ch has been p:l!Si-
tiooed and rotatG1 to form the desired view and parspective is given in
Afp>-Niix C. I t uses the left and right ste:reo rratri.x pair presented above to

Vigure 3-19 Sinple stereo vi<.......


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

3- 1 lti:lerts, L. G. , "IJarogeneous Matrix Representation and t-'. arup.Uation of


N-D.iroonsi onal COnstructs, " r:o:::urertt t1S 1405 , Lincoln L1.boratory, M.I.T. ,
carrin"idge, l1a.Ssachusetts, May 1965.
3-2 Ahuja, o. V. , and Coons, s. A., ..Gecrtetry for COnst.ruct.ion and Display,"
I.Et-1 Syst. J ., vol. 7 , nos . 3 and 4, pp . 188-205, 1968.
3- 3 \-bodsf otd , P . A. , "'lbe Design and lnplerentation of the GIN:> 3D Gra{iri.cs
Soft:<Hclre Packllge, .. Soft:ware-Pract. Exper., vol. 1, 1971.
3-4 \bxlsford , P. A., "GIN)-{)eSign and Inplesrentation , " CM Group Doc. 27,
U1L, carrin"idgc University, 1969 .
88 ~11\TICAL EIJ.l.!EM'S FtlR COMPl1I'ER GRAPHICS

3-5 Cocns , S.A., ''Transfor.nation and 1-'atrices," unpublished notes , Univers~ty


of :-~clugan Short Course in CbrTpuler Aided Design , 1971.
J-6 Forrest, A. R. , "co-ordinates, Transfor:TI'Olt.l.Ons, and ViSUil.lizatioo ~

niques," CAD Group n:x:. 23, Catnbn.dge t'nivcrsity, June 1969.


3-7 forrest , A. R., "c,c,.pumtional Gc~t.ry," Proc: . roy. Sex:. (London) , vel .
A321, pp. 187-195, 1971.
3-8 Kubert , q., SZl\00, J. , an:i Giulieri , S. , "The Persp:!Ctiva Representaticn
of F\lnctions of '1\.u variables," J . Assoc. c::atplt. t-\!ch., \1'01. 15, 2, pp.
193-204, April 1968.
3-9 S.!the.rland, I . E., "'lllree D.irrensional Data Inpul by Tablet," Proc. I EEE,
vol. 62, 2, pp. 453-461, April 1974.

CHAPTER 4
PLANE CURVES

4-1 INmOIXJCTI ()'~


Today a multitude of t....">Chniques are available for ltli1lllla11 y drawl.OCJ and
designing curves. 'Ihe instrunent userl can be chosen fran ~ wide vanety of
pencils, pens , brushes, knives, etc. A m1pass, stra~ght edge, French curve,
ships curves , splinBB , tmplates, cm:l nany other rrechanical devices , as 'h'el.l
as r.odels , col or dta.rt.s , and perspective grids , rnay be used to assist in the
oonst:.rucLion of a c:urve. A great many different techniques and tools for cuxve
generation and display will also be needed \</hen using oatpUter graphics. sare
of the ideas that have proven useful for generating plana, o.o-<11mensional
curves ill'e discussed in this chapter .
The previous b.o chapters have treated the transfo.rrt\ation of points. A
curve may be presented by a rollection of points, provided they are closely
spaced as the niC3i us of cw:vature decreases. Hc::lwe\ler , there are several
reasons why a mat:rematical representation of a curve has an advantaqe over its
representation by a grid of points . SOrre of these are

1. A !Mthatatical represen~ticn is precise, and the properties of the


curve such as slope and radius of curvature can be eas.Lly calculated .
2. A rra~tlcal representation can be mt,w=t.ly stored 1.n a cooplter.
3. ~s o! an object represented mathematically in a muputer can
be easily ptcduoed.
4. \\hen C'lli"w"eS are analytically defined over the region of interest , oo
1.nterpllation schsre l..S needed to cxrpJte in~te p::>i.nts.
5. 'nle use of p::>l!'lt.s to represent curves has proven difficult \ooile."l it is
desirable to o::ntiru*"llY alter t:he shape of the curves to reet certa.L.n des1.gn
cr.1.ter.ta. A rmthrn-atical representation of the curves has prove."\ t:llCh r.ore
cse.ful !or t.his PU-"1X>S8·

we ro.~ consider various techniques for math£!!\atically repre~ti.ng tiNO-di.rre.n-


sio.na!. curves.


4-2 tb~PAAAVETRIC URvES

Either a p..lranetric or a nonpararretric foon can be used to represent a


CU..""\;'e mat:hm.atically . A oonpararretric expressJ.on can be explicit or inplicit
in form. For a plane curve, the explicit, nonparamettic expression takes the
form
y • f (x) (4-l)
Il' this fonn there is only one y-value for each x-value. For t:lus reaso:'l the
explicit fotl':' cannot represent closed or CJ.l.tiple-valucrl curves . 'lhis limi-
tat.la'l can be overCXXll!' by usin<; an inplicit eJ<preSsion of the fonn
f (x,y) = o {4-2)
Hc7..Jever, a p::>i."\t on an in'plicit curve se;:p.eat rrust be calculated by fl.nd.ing the

.-..
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

0 values of the four coefficients.


A difficulty arises \,'hen using axis-dependent nonparanetric curves i f the
end rx>int of a curve has a verti.cal slope relative to the chosen ooordinate
system. 'lhi.s infinite slope cannot be used as a ni.JI'et'ica.l bourdary conditi on.
• It is necessary to change the coordinate system or approx.iJnate an infinite slope
with a l..arqe positive or negative value.FUrther, when points on an axis-
dependent nonparanetric curve are calculated with equal i.ncrem::nts .in x, the
positioo of the rx:>ints will not be distrib.rt:ed evenly alCI'lg the length of the
curve . This can affect the quality and accuracy of the gra{irlcal outplt.. '1hese
difficulties lead to an interest in para!'llrtri.c curves for <XIiputer gra~ .

q_3 PAAA"ETR I c WMS

In paranetric form each cxxmlinate of a point oo a curve is represented


as a flDiCtion of one or nore paraneters. For a curve of one pararreter, the
p.:>Sition vector for a p:>int on a curve is fixed by all! val ue of the pare.rceter .
If the parameter is t and the curve is t:INo-diJTcnsialal, one writes
X= f(t)
(4-8)
y .. g(t)

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

representing closed curves and curves


with multiple values at a given value of
an independent variable . 'nlc ~t \

vector at a point on a para~"retric curve Y-~


l.S given by ( ) L - -_ __ _ _.
P' (t) = rx• y' 1 ::r [f' (t) g' (t) 1 (4-10) o \ 10
~ the ' denotes differentiatial with LOt---._ 0
I
respect: to the parar~eter . 'lbe slope of I I X = COS;J
the curve, dy/d.x, is written as \ I I
I I / y = sw.J

~-b!n the tenn f' (t ) =0


(4-11)

in El:). (4- 11) , 0


: ~/
I I I"' // / """
';.
--
./
_..-- --
0 10
the s l ope dy/dx is infinite. Since an 10 t--...._ h

infinite slope occurs~ one c:atp:>nent


of the tangent vector is equal to zero,
)
it ci:>es not introchx::e cx:mp.ttational
difficultics.
Since a point on a para:netric curve o ...._...__
0 "' c I0
is speci fiEd t:Jy a single value of the
parmreter, the parametric fornl is axis- Figure 4-1 Circle r.::prese.ntatia'\5
independent. 'lhe curve length is fixed by the range of the pararreter. It is
often convenient to noonalizc the parameter so that the curve falls par~t.r:ic
between 0 ~ t ~ 1.0. Due to its axis-independent nature, a parametric curve is
easily transforned into a curve of the sarre shape but wi. th various orientatioos.
'!his is aooatpli.shed by using the tratrix multiplication techniques discussed in
the previous chapters to perform rotatioo, translatioo, sca1ing, and perspective
projection.
A ooopa.rison of the parametric and nonparametric form of a circu.l.a.r arc is
sllOn'n in Fig. 4-1. '1'hls figure was used by W:lodsford (Ref. 4- 4) to sln4 that
a choice of pararretric functions can be used to inprove the distritution of
catpJted points on a curve and thus give a better gra,;hlcal repr-esentation. The
gtadrant of the circle shown in Fig. 4-la is represented by the non~tnc
fouu y = h - x2. Equal increments of x were used to obtain the FOints on the
arc. '1his form is inconvenient to catpJte because a square root algorit:bn is
necessary. It also produces fOQr results since the arc lengths are unequal.
Figure 4-lb is obtained fran the hr1sic parametric form given by
P (t) • [oose sine] (4-U)
'lhis produces good output since the arc l engths are equal, but the calculatial
is inefficient because trigJa'I'Ctric functioos require several operations to
<XIItpute. Figure 4-lc is an alternate paranetric representation gi'V'Cn by
2
2t
rd l
(l - t )
+ t
2) (1 + t
2

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:

y = A: - x2 "' {0. 75 = 0. 866


For the para.rrotric representaboo it is first nece~ to solve for the p!U"a-
rteter t in terms of x and then use this value to obtain y . Specifically for
the parazretdc representation of Eq. (4-12) we have
x • cose
y =sine
Thus,
e = cos-lx = ros- 1(0. 5) = 60°
y = sin(60°) = 0.866
Alternately, far Eq. (4-13)
2
1- t
X - .;;.........-""
- 1 + t2
y - 2t
2
1 + t
Solvin9 the first of these equat.ions for t yields

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.

4-4 tbPARAiflRIC REPREsENTATIOO a: Coorc SEcn oos


COruc sections fonn useful planar curves for rrany applicatialS. ~'Je ro-;
S\J'!'r"drize sonc useful relationships frau analytic gcarotry. Figure 4-2 ill-
ustrates hc:Jw the intersection of a plane and right circular oone defines the
various conic sections, i.e., the CliCle, paralxlla, ellipse and hyp!'rtx>la.
The general definitial of a cadc section can be given as:
..

PLANE OJRJES 95

,
/

d
( 11 de

Figure 4-2 Cooic Sections

A conic section is a curve described by a p;:>int which rrovcs


such that its distance fran a fixed p;:>int (cal led the focus)
divided by its distance fran a fixed line (cal 1 ed the directrix)
~ a constant £ (called the eccentricity) .

All the c:ooic sections can be described by the general i.rrpl.icit sec:::oro-
degree curve

ax2 + bxy + C'i + dx + ey + f : 0


'rtle cross product term bxy in this equatjoo oootrols the orientation of the
resulting CCIIUC with respect to sorre reference axis system. If the reference
axis system is selected such that one of the a.~ is an axis of symretcy of the
curve, then b • 0 . Since we can always rotate the curve such that. the axis of
S}ITI"'retcy is one of the axes of the reference systan, we need ooly consirler the
equation

a •x •2 + c •y • 2 + d ' x ' + e ' y ' + f ' = 0 (4-15)

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

(cf Ref. 4-5) • Narrely, th~ c:urve is

2
a parabola if b - 4ac =0
..
c an el11p5e or a circle if b 2 - 4ac < 0

a hyperbola 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

k = 2f ' - d'2 e 'JO


2e' r

Equatioo (4-19) represents a paratola "-OOse axis of syrrtl'ntry is y ' . If


PIA'IE ClJRVES 97

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

oenter at (h,k) is then


2
(x' - h) > 6
2 .. (l (4-20)
(l

-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

c ... lcl + r?- > 1


(l


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 ~

defined, coordinates CX>Ul.d be chosen which produoed rea.scnably satooth c:urves ,


even through the point distri b.Jtion was not tnifonn. The shape of ships and
airplanes were adequately defined in this manner. One advantage of this ~
was the relative ease in ca.lculat.inq the intersectioo of boO curves, each defined
by nonpt\I'atretric, algebrAic cquatioos.

COOsider the ooterminaticn of a circle through three paints given by


[1 1) , [2 2] , and [3 2] respectively (see also Sec. 4-11). 'lb generate a
• circle through these points , let a ' = c ' = 1 and write 6::). (4-15) as

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.

Exarrple 4-2: CIK"ULAR 1\fC WI'1li FIXED AAD.ItS

Let the o.o end points be [1 11 an1 [3 2) as before. In addition we re-


quire a radius of r = 5. Fran Eq. (4-15) we obtain the three equations whidl
result ftom these three cocilitions:
2 + d+e+f=O
l3+3d+2e+f=O

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.

E:xanple 4-3: CIR:lJI1\R Me l..zt'IH A FDCFD 1u~ NG£

:If an init1al slope of +1 is required at (1 1) and a final slope of zero


is necessary, then the final point oo the circular arc cannot be .11'll~lendelltly
spew..fied. For this case, we require
at: X • 1, Y • 1

at x; 1, ~~ "" 1
dx y. 1

at x = 3, ~; 0 •

'lhese ~ ocnditicns lead to


2+d+e+f=O
4 +d+e:::O
6 +d . 0
\olhich has the solutioo d = -6, e = 2, f = 2. The equation for the circular
arc is thus

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.

Exanple 4-4: CI10.1l.M .Ale WI'ni GIVEN END SUlPE

Given the end points [1 1] and (3 2) with dy/dx • 0 at x ,.. 3 yields


2+d+e+f•O
13 + 3d + 2e + f "" 0
6+d:::r0
'1hen d • -6 , e • 1, and f • 3, with h • 3 , k ~ l/2, and r -- 5/2. 'lhis so-
luticn prcx:h:es a slope of 4/3 at the initial {Xlint. 'Ibis may be t.maeeeptable
and an iterative so1ution nay be requi.rea to find a final {Xlint ~ch allONS
an acceptable initial slope. An alternate approadl is to require the user to
specify the radius wch will pnxluce acceptable slopes at the two end points
and to proceed as in Exanple 4-2.
PIAN£ 0JRVES 101

'lbese ~les illustrate the problems encountered when trying to provide


a catJlUter software (or haJ:d\..'are) interface between ~ usPr and the graphlccll
output. 'Dle creatioo of the desired curve may be straightforward, or 1.t rray
require iterative techniques, depending oo the known or de!Sired charact.eristicn
of the curve. Even 1Nhen the required equation for the Kno..m, calcula-
C\.1IV{? ,l.S

tions which produce \tlell-distributed (X>ints aloog the C\l.t'W my be expensive in


terms of Further, ~ nooparrureLric curves are created, care
<XJlllUter t.itl'e.
nust be taken to find the real roots rather than iJMqiJl.'1ry ooes, and i.ndcpandent
variable step sizes between consecutive data points may require <::ha.niJes based
upcc1 the local curvature and ooordinate system.
c:Dlsider again the problem of pa.ssinq a circular are through three pomts.
If the points are far renoved fJ:Cil\ the origin of the coordinate systEm, l<m]e
values of the coefficients can occur. To avoid this, translate the origin or
the original coordinate system to the first point and define a new ooordi.nate
syst:en x'y' as shoNn in Fig. 4-3. The coordinates of the three points, relative
to this transfOl:'lred system, are then
p = (0 0]
0
((Xi- Xo) (yl- Yo))= (xl Yil
[(x2- xO) (y2- Yo)) • lxi Yil
Since x
0• Yo = 0 due to the location of the transfonred coordinate system,
f' = 0. 'lhe other t-..-o equations, obtained by evaluating the general equatioo
at P and P , are
1 2
x•12 + y1•2 + d'~l + e ' y 1' • 0

Xi2 + Yi2 + d'Xi + e'yi =0


SOlving for d ' and e ' yields
2 2 2 2
d' Y2 (Xj_ + Yi ) - Yi (Xi + Yi )
; <~i xiy~) -
2 2 2 2
Xi(~ + Yi ) - x]_ <Xi + Yi )
e' ;
lxiY1 - Yix2)
It foll.ONS that the center of the circular arc, relative to the x'y ' -coordi-
nate system, is
2 2 2 2
Yi<~ + yl' ) - Yi(x' + Yi)
x' _ d' l
c-- :za' - 2 <XiY2 - '91)
'lbe center ooord.inates relative to the
origir.a.l coordinate system are silrply
xc = x'c + x..u
>I Yc .. yc' +Yo

\<.'hen f.Oints of intersection, offsets


for cutter tools , enclosed areas or
wltr"eS , or other such geatet.ric infor-
mation is needed, the required calcula-
tions nay be si.nplifl.ed by expressmg the
equatioos in explicit

form. The explicit
• form of the circular arc is given as
either y • f(x) or x • g(y) . In t:erms

of the ooefficicnts of the general second-
order p:llyrouial equation, the first foon
• is

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.

4-6 PARNURIC REPRESEtiTATIGI OF WHC SECTI<l4S


PIA'IE OJRVES 103

A pararretric rcpresentaticn of conic sections is of interest bx:ause it


prodUces axis-independent curves. '111ese can have udvantages over nonparanetric
curves for soue applications. ~vcr, neither type of curve repr:esentat.ion is
a panacea, since both have advantaqes and disadvantages and both find uc.cful
applications in CXX'!t'Uter graphics.
'lhe conic sections can be s.inply represented in param:!tric form.
origin-centered circle can be paranetrically repxesentcd as
X = ro:>SB (4-22)
y : : : rs.ine (4-23)
where r is the radius of the circle and e is the parcuroter. In sec. t1-3 ~
remarked that although equal incrementS of 6 \Qlld produce gcxxl output a\ a
display device , the calculation was inefficient because the trigonaretric func-
tions rrust be repeatEdly calculatod. Followin<] Ref. 4-6 we shall show below
that a nore efficient algorithn is possible.

4-7 PARAt-1ETRIC RePRESENTATIGJ OF A CJRCI E

'!be circ:L! can be efficiently represented pararretrically by eliminating


the neoessity for calculating the triganretric functions at each step. 'Ihis
can be accouplished by using the double-angle fornul.as:
cos(9 + d 9) = cos9cosd9 - sin9sind9
sin(e + d9) = cosesinde + cosd9sin9
Noting that the circle will be cxxtpletely swept out for a range of 0 fran 0 to
2n and assuning that a fixed numer of p:>ints will be used , then dO will be a
constant. TOO cartesian coordinates of any point on an origin-centered circle
are then given by
Xn+l = rcos(O + d6) (4-24)

yn+l = rsin(9 + d9) (t1-25)

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)

yn+l = ><nsinde + yncosde c4-2n

I f the circle is l ocated at h, k r elative to the origin of the coordinate system,


then we have
><n+l - h + (~ - h)cosde - (y0 - k)slrlde (4-28)

yn+l = k + (xn - h)sindB + (yn - k)cosd9 (4-29)

A BIISIC subroutine incorporating this algorithn is given in Appendix c.


since dO is constant, the values sinde and cosd8 rx:ec1 to be calculated only
once. nus ptoduces an efficient algorithm. 'lhe results of using this algorith:n
are stn.n in FUJ. 4-5. Notice the equal spacing of the points.

4-8 PAEWEIRIC f?EPRESENTATIOO OF N-4 ElLIPSE

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

Fiqure 4-4 Crude nonparametric Figure 4-5 Equal-angle representation


representation of a circle of a high-t>ccentric.1.ty ellipse
PIA'lE aJRilES 105

\
I

/
/

Figure 4-6 Equal- angle representat.ioo of a hiCJh-ecccntricity ellipse


periJreter length near the ends , "''here the curvature is l.arqe, and larger pe.ri-
rreter incresrents along the side, where the curvature is smll.l .
To ove.rcx.xre the problEmS of (Xlint distri.butioo, consider the pararretric
representation of an origin-centered ellipse of san.ilrajor axis a and semiminor
axis b . 'Ihen
X = acos6 (4-30)
y = bsin6 (4-31)
"''here e is again the paraneter. Varying e beboleen 0 and 2n 5\oo'OOps out the entire
ellipse. A specified fixed number of p:>ints can be used to represent the ellipse
by t:aJd.ng fixed incrcrrents in the parameter e, say, increments of 2n/ (n - 1) ,
where n is the nl.llt:Jer of p:>ints .
£xamininq the derivatives
dx - -asin6d6 (4-32)
dy =bcosed6 (4-33)
shc7.ols that the desired perimeter i.J1crenents are aut:aratica l ly ootained. ~

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-

I' angle formulas (Pef. 4-6) . Here the ell i(&


;. is a5S\.IIred to be inclined at an angle i
to the horizcntal , as sJ1o..m in Fig. 4-7.
Hence
x' .. xoosi - ysini (4-34)
x'
y' = xsini + yoosi (4-35)
• or
0 •• x ' "" aoos6cosi - bsin9sini (4-36)
._I y ' = aoos8sini + bsin6oosi (4- 37)
Introdu::ing the coordinAtes of the
'• center of the ell ipse yields

X'
n+l
a X
c
+ X 1 00Si -
n
y'sini
n
(4- 38)
Figure 4-7 Ellipse y'n+l = yc + x'sini + yn' cosi (4-39)
n
For the recursial fOD'I'lllas, note that the ellipse algoritlTn in Appendix C uses
a SOI'I'ew'hat different technique than used previously in the circle alqorithm.
In th:Ls case a teri(X>rary variable T1 i s used in the inner loop.
Snith (~f. 4-6) has sb:1h'Jl that this alqorithm can be made still nore effi-
I
cient such that ally four additi.a\s and four nultiplications are required within
the inner loop. Snith has also sb:7h'Jl that this technique yields the inscriOOd
polygc:n with max.irrun area. 'nlus, the additions and nul.tiplicaticns give an
efficient representation of the el] ipse , such as the CX81Tple shown in Fig. 4-8 .

4-9 PAR#ETRJc REPResooAnON OF A PARABCX.A

Consider an origin-centered parabola opening to the right, .i. e. , with the


axis of S}'n1'retry the positive x-axis, as shown in Fig. 4-9. In rectangular
cxxn:dinates such a ~l.a is repl:'escnted in l"aaparaJretric fonn by

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

Figure 4-8 Pa.rwetric representation of an ellipse


"''here 0 ~ e ~ r/2 . Alth::)l.¥Jh this provides an Nlequate representatias of a parab-
ola, Smith (Ref. 4-6) points out that it does not yield a figure with ma.xlrruml
inscribed area and thus is not the rrost efficient rcpresentatioo. An alternate
parametric representation which does yield ma.'Cirrun inscribed area is

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~

Figure 4-9 Para):x)la


~ant can be obtained by reflection al::out the x-ax1s (cf Sec. 2- 10) . An
appropriate alcprithm to obtain the required points in the first qu!ldrant is
given 1n Appendix c . In the algorithm a fixerl ntri:ler of points is specified
• and a constant i.ncreme.nt in e is used. Parabolas with displaced centers or at
other orientations ca.'"l be obtained using rotation and translation.
For en+l = an+ d e , Eqs. (4-43) and {4-47) beoare


I
~ 1 ~ aen2 + 2a9nd~ + a(de)
2

yn+l ~ 2a9n + 2adS


o,..hl.ch ~ray be written as

~1 = ~ + y0 da + a(d9)
2 (4-47)

Yn+l .. Yn + 2ad9 (4-48)


..
F.lgure 4-10 s~'S a."\ ~le of a parmx>la generated using these recursion
relationships.
For s~ifl.c purposes other pa.r21r00t.ric representat.Wns can be rore useful .
1his generally depe.."lds on the info:rmation specified by t.~ user. For ex.a:rple , i f
a parabolic arc is to oo drawn bet~ t:"..o points, and oontrol of the end slopes
is necessary, then the folla..t1.ng form .lS suggested:

X (t) = (0'"Y. - -2R'): + P X) t


2
+ 2 (RX - PX ) t + PX

-
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

Figure 4-10 Parabola generated by the PARAOOIA alc;priilin

4-10 PAIWIEl RIC RePRESENTATI~ a= A HYPERBOLA


As was the case for the parabola, we asst.~te that we want to generate a
hypertx>la which is origin-centered, with the axis of symretcy being the positive
x-axis. 'Ihe rectangular nonpararretric CXX>rdinate representation of this hyperbola
(
is l
2 2 I

;. - ~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

hypet'OOla. smith (Ref. 4-6) points out 1\


I '
that with this pa.rametric representation I \
the inscribed p:>lygon is not of rrax.inun I \
area . Ha..oever, it is of nearly rnax:inun I ' \
I \
area, and t:r.e dcuble-angle fonrulas can 1 \
be used to yield an efficient algorithn. 'I
I
'\ \
To see this recall that \
1 I ',
sec<&+ de) = cos (e + dO) I \
- 1 II ' ~
- cos660Sde - si.neSillde
and
I
tan(e + de) ~ tane + tande
1 - tanetanae
'1hls we may write

'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

'l'he algonthm HYPERBl 1.n Appendix C uses tl'w:!se rclatiooships.


A"l alternate para11etric representation of a hyperbola which yields the
polyqt:Xl .,.."1 th max.i.nun inscribed area is •
X = acosh6 • (4-53)
y = bsinh& (4-54)
6
'Ibe h~~rtx>lic functions are defined as coshe .. (e + e -e)/2 and sinh& =
(o 6 - c - fl)/2. l\s e varies !:tun 0 to co the hyperbola is traced out. 'll1e double-
angle fonnulas for CDsh and sinh are
CDsh(& + de> = oosheooshde + sinhesinhde
sinh{6 + d6) = sinh6coshd6 + cosh6sirurle


' 'nlese allow wrib.ng tqs. (4-53) and (4-54) as
~
1 = a(cosh6coshd6 + sinh'-sinhd6)

YOTl = b(sinh- coshd& + c:osh~sinhd& )

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

cosh-lx = log(l + x) - log(x - 1)


2
An exanple of a hyperbola using this technique is shC7...n in Fig. 4-12.

4-11 Af>Rocen.RE Foo niE UsE OF Coote SEcrtCR;

In Sec . 4-5 the nonpararretric representation of a circle through t:hrc!e


points was cx:nsidered. An essentially brute force awroach was adopted. uere
we cx:nsider the sane problem; i.e., detexmine the location of ~ center and the
radi.us of a circle "hlch will pass through three specifl.c point.s. However, here
"e divorce the problem of drawing the appropriate circle fran deteiJI\i.ning ~t

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

,,

Figure 4-12 Paranetric representation of a hyperl::ola



'
-
..
-


\

~

. l
I'
I

l
0
0
-
' \.

Fl.gure 4-13 Circular arc f'iqure 4-14 Circular arc


throogh three powts (gecr-etry) through three points (pararretxic)
solution rore oorwenient, Lett:in:J
x ' = x- m and y' • y - n
\>tlcre m ar¥1 n are t.~ translatjon factors (cf Sec . 2- 27) , we have m: ,_, n,.. y .
1
Equation (4- 58) may then be written in the x ' y ' -cxxmiinate systan as
2
(x' -h ' ) + (y ' -k ' ) 2 • r2 (4-59)

h ' • h - m and k' = k - n


Dl.rect sub6tJ.tutl.on of the o:ordinates of P , P , P in the x'y ' -ax>rdinate
1 2 3
systen yields

h ' + k' 2 - r 2 a 0 for p


1

'lbcse oguations represent til.ree equat.ioos in the three ~ h 1 , k 1 , an:l r


an:1 thus may h.:! solved . ~, the systan of equations 1.s non.l.inear ard ~

quires an iterauve solutioo, l.lhl.ch is undesirable . Notice, ~, that becaus


the origin is at the first point, the fi.rst e:}Uat.ion can always be S\.btracted
fran the sec::ond and thl.rd equaUoos such that the nonl..inear t:etms are el.u:u..n.'lted.
"Ire resulting equ3t.ions are
PlANE CURVES 113

2x 'h ' + 2y!k'


1 1
= x! 2
~
+ y! 2
~
~ - 2,3 (4-60)

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)

kno.m, a standard origin-oent:ered algorithn, either para~rutric or na1paranutn.c,


can be used to generate the points which describe the circular arc fran P to P
1 3
through P •
2

Exarrplcs 4- 5: CIK:UI.AR 1\0C PR:CE:I:XJRE

consider the three points given by P (3, 2) , P ( 4, 4) , and P (0, 6) • Trans-


1 2 3
lating to P yields Pi (0,0), P2(1,2), and Pj(-3,4) . F.quations (4-60) are then
1
2h' + 4k ' = 5
-6h I + 8k I !!0. 25
Solutioo yields k' = 2, h' = -3/2, and r"" 5/2 . Translation to the center
yields P1* (3/2 , - 2) , P2*(5/2,0), and P *(-3/2,2) . Thus, Eqs. (4-61) give
3

01 tan-1 (-2/(3/2)) ~ tan-1 (-4/3) - -53.13°

82 = tan- 1 (2/(-3/2)) = tan- 1 (-4/3) = 126. 87°


'Ihis provides the angular input for the arc drawing S\lbroutine.

A parzuretric form is crosen to inprove the point distribution along the


arc. Figure 4-14 shows the resulting pax-arootric rcprescntiltion. 'llle algorithn
used to generate this ~ is called 3PCI..RAR:: and is given in Appendix C. The
pararootric circular arc subroutine was discussed in Sec. 4-7.

4-12 CJ RCULAR AAc I tfrERPa.AT I 00

The snoothness or fcumcss of a curve is generally a quahtative judgrrent


based oo t..t\at is pleasing to the huron eye. Nevertheless, it 1.S possible to
select a quantitative treaSUre of sztmthr1ess and qenerate curves according to
this critenon. One such criteri.al used successfully by 1-\ehl.ll!! (Jef . 4-8) is
to minimize the inteqral aloog the arc length o£ the square of the cw:vature.
Curvature can be expressed as
y"
K""
(4-62)
.,here the pr~ indicate dif£erentiatioo with respect to x . Thus , the p.rcblem
is to rnini.'1lizc I, 'Where I is given by

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:

When a picce..rise curve is drawn ~'hich mi.nirn:i,zcs the integral


al.crq the arc length of the square of the cu.r:vat.ure, then the
curve segrrents lie in a direction aloog ...nich the cw:vature varies
linearly bet\o.een the end points of each se<Jrent..

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.,_,

F1.guro 4-15 CUrvature profiles


PlANE aJRVES 115

the acblill direction of the lmear curvature variatioo is chfficult to dct.ermi.nc.


It requires the solutioo to elliptic integrals whose wtegratioo cx:nstants are
dependent in a catplicated '"'W'f oo the specified boundary conditions. t-~un
suggested that an approximatioo to the piecewise linear curvature be rro.dc by
replacin<] the linear variattoo with a series of disocxltinoous steps, each with
constant curvature, as indicated in F~g . 4-lSb. 'll1e curvature profile is then
piecewise cx:nstant over the curve length. Since a ccnstant curvature descrires
a circular arc, the piecewise curve u; represented by a series of ci.rcular arcs
with various centers and radii of curvature. 1\ large nt.111ber of steps, i.e.,
circular arcs, will produce a closer fit to the ideal. curvature. The required
nunber of circular arcs depends upon the separation distanoe between the dat..a
};X)ints, the dlange in curvature over the curve segrrent, and the required ~
of the graphical output. Detai 1s of this technique for generating snooth curves
by circular arc interpolat-ion are given in the cited reference. The output. of
the itcraoon process gives the value of racHus and center };X)int for each cir-
cular arc, as well as the specified x-values where the curvature c:hangcs. '1hen
I
sd:>routines for generating parametric c.ircular arcs can be used to produce the
actual pieoewise curve.

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,

Berlin , OCt . 1971.


4-5 'l'hc:rnas, G. B., Sr., calculus and Analytical Gearet:J:Y,, J'ldll.son~ley
Publ.i..shing Carpany, carbridqe, t-1ass., 1954.
4-6 Snith, L. B., "Drawir¥} ellipses, hyperbolas or parabolas w1.th a fixed
n\J't'bcr of };X)Ults and nwc.iJtun .in.scribed area, " COJipUt. J . , vol. 14, p . 81, 1!
4-7 COhen , D. , "Linear Difference CUrves," in lldvanoed Cu!uputer Graprics ,
Plen\1'1\ Press, New York, 1971.
4-8 l-fchl\1'1\, E., "CUrve and SUrface Fitting based on Variational Criteriae for
Snoothness," Central lnstl.b.Jte for Industrial ResearCh (CIIR), Oslo, Nor!o.'ll}'
Dec. 1969.
THIS BOOK BELONGS TO

IKE HAYDEN

CHAPTER 5

SPACE CURVES


'

5-1 Itfi"RROLCT ION

ll\::lst objects encountered in the real world are t:.h...~ia\al in nature.


l~ver, nost drawul<J t:.ec:hmques are two-disneruucnal , the results bemg produc:ed
I~
on a plane surface such as a drawing board. '11lis frequently results in the
represent.at.loo of three~ialal objects by I'J:!allS of t:wo-diJrensiona.l Vl.L'".TS

or sectional d.nwings. 'l1le use of a digital conputcr to ge.-,erate curves ndds


a new d.ireru.ioo to drawing techniques . ional spaoo C'l..lrVeS can be
defined, gC!I'lC'!raLL..od , stored, rrenipulat:.ee , and plXldt.red as output. Sp;!CC cur\11"5
can be displayed oo a tw.'t>-d~ooal plane by use of ~tnc and perspec-
tive projectioriS, as d1.scnssed in Chapter 3, or three-<lurensional rrodels can
t::Y! prodooed directly by using a nu:rerically oont.rollf'O cutting tool. The
present chapter extends the previous discussions for CUIVO dcscriptioo to three-
d imens.J.ona 1 space curves.

5-2 R£PI ESENTATICU OF SPACE (aVES

As was the cage for plane curves, sp.~ ~ rray oo reprosc.>nted either
mnparaztw:·trically or pararretrically. '11l.ree-ditramsional spaoo c:urves expressed

'• SPJ\CE ~ 117

in nonparaJtt:t.ric form a.re g.1.ven explicitly by a set of cquotions of the form


x=x (5~)

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

det 2!. ll.


i4X oy
1 0

~~
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:

x = >. (acos {co + ~) - bcos3 {0 + i> ) ( 5-8)

y = IJ (asin (6 + i-> + bsin3 {6 + if) I


z • csin(2E) •

" • 1 + dsl.n(2fl ) - 1 + d(!)


c
.c . v =1 - dsin(2e ) =1 - d(!)
c

.. 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

5-3 CusiC SPLINES

The mat:hcrratical spline derives fran its {ilys~cal counterpart - ~ l ofts-


rran's spline. spline is a l.a1g narro.~ strip of "'COd or plastic used
A physical
by a loft..sman to fair in curves beO."een specified data powts. ~ s plines are
shaped by lead weights called "d\.Cks." By varying the ni.ITber and pos ium o £
the lead "-eights the spline can be rMde to pass t.hrou.;;h the sp.."<Cified data
points si.Ch that the result.ing curve appears srooth or "fair."
If the physical spline is considered to be a thin elastic bcilrn, then
Eulers equati01 (cf Ref. 5-l) y.lelds
EI
M(X) = R(x}

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

y" (x) = loti';>


Assuning that Ule d\.Cks act as sinpl e SliftQrts, them M(x) is a linear function
beb¥een the supports . Letting M(x) = A + ax and integrating the above equation
twice shows that the physical spline is descriOOd by cubic polyncmials between
supports.
In general the mathenatical spline is a piecewise polyro1ual of degree K
with continuity of derivatives of order K - 1 at the camon )Ol.nts between
~ts . Thus, the cubic spline has second-order continuity at the joints.
Piecewise splines of lo..r degree polynanials are usually rrore useful for forming
a curve through a series of points. The use of lo..r~e<Jree polyranials reduces
the ca•putatJ ona 1 requirements and reduces mm-erj cal instabl.l i ties that arise
with higher order curves. 'D1esc instabilities can cause an undesirable wiggle
when several pomts nust. be jowed in a CXJflTIDO curve. fb..lever, si.ncc l<:M-<legree
polync:rnials cannot span an arb~tracy series of points, adj aoent polynomial seg-
Jl'el)ts are nooded . Based on these consideraticns and the unalogy with the Fhz'si-
cal spline, a camon technique is to use a series of cubic splines with each
sec:rent spanru.ng on1y boo points . Further, the cubic spline is advantageous
since it is the l~t degree space curve which allo..rs a ~int of infl ection and
has lhc dbility to tl<dst through space.
111e equation for a single pararretric cubic spline seqrrent, 1.n terms of a
paraneter t , ~ qiven by
4 . 1
P(t) = L
. 1
a.e-
l.
; (5-10)
l.=
\."here P(t) = {x(t) y(t) z(t) J. P(t) can be considered the p:>Sitioo vector of
any p:lint oo the spll.ne. It has tllree carp::n:mts x ( t) z ( t) \oohlch
, y ( t) , ard
rruy be o::nsidercd ~ cart..esian O::Xll:di.nates of the posit.icn vector . The coeffi-
cients B are det:.errni.ned by specifying four boundary oonclitl.ons for the spline
l.
se<J'l'IC."lt .
In expar.ded fonn Eq. (5-10) may be wr1.tten as

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

~. To s.irlplify t.h.e calculations , we can assign ~ = 0.


The required boundary corrlitions for each cubic segrre.nt o::nsist of the b.'O
end points and the tangent vector at each end point. For the single seqrrent
beb.'OOn P and P , these conditions are given by
1 2
P(O) = Pl (5-U)

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

3(P - P ) 2P' P'


2 1 1 2 (5-17 )
B3 = 2 - t2 - ~
~
and
SPI\CE OJRVES U l

(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

t:fi + 2(t3 + ~)Pi + ¥3 = ~3t3 [ t~(P3 - P2) + ~ (P2 - Pl)] (5-24)

...,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]

'!he expansion of Fq . (5-26) gives r. - 2 equatioos in n unknown tangent


voctors . \-lhen the t\oJO and tangent vector s Pi and P~ are specified, then the
systan of equations is dete.rminant . Thus, to generate a curve tt:e position
vectors P , 1 ~ i ~ n, al on; with Pi and P~, are specified. Then Elq. (5- 26)
1
is 11SE!d to calculate lhe i nt..enrediate tangent vectors Pi, Pj, . . . , P~-1'
Tlus calculation is rrost conveniently aco::c1plisr.ed by natrix inversion
(cf sec. 5- 5) . 'l1le tangent vectors are then used to calculate the B. coeffl.-
.1
cients g.tven by the 9f!f1eral ized focn of Eqs . (5-13), (5-14), (5-17), and (5-18) ,
for each curve segrrent, e .g . ,
(5-27)

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 .

5-4 ~IZED PARA."£TERS

In spite of the approxunate sr.oothness of the resulting curve, normali7.ed


paraJreter ranges for al 1 cub1c se<JI11'!1lts of a spline cw:ve can be used when
defining a C\.IL"W , \'hm this approach is u'?ed, 0 ~ t s. 1 for all spans and
Eq. (S-26) ca.n ba .roarran<p:l in the form
(5-31)

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

(5-27) and (5-30) , can be expressed in z:utrix form QS

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.

5-5 13ruJlARY CcfiDJTJrJ~S

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)

• • •

• • •

• • • •

M(N- 1, N- 1) ~(N- 1, N) P ' (l< , N) B(l<,N- 1)


A squ<s.re (t-S)""11'oaLr:LX LS I1C<X!5SlUY to ootain a unique solution for Lhe un-
known tangent vectors. The required square mat.nx M can be created by spcci fy-
ing boundary c:xnlitions lit each end of the total piecewise cubic curve as
sho.m be}.o..o. In this r..ase Eq. (5-33) may be \oi'I"itten as
(M] (P. I - (B} {5-15)
~~:: t-1 J..S tOO required square rratrix. 'Iben the internal tangent vectors
,
P~ >
(Pi , . . . , 1 are given by
[P' ) = [l1)-l[B] (5-36)
~ [M]-l is the inverse of [M) . cnce the P '-values are known, B.-values for
l..
each segnent arc calculated using Eqs. (5-27) and (5-30).
Vany chc)l.m5 exist for specJ..fyinq the end boundary CCI"lditions for a plcce-
wise cubic curve . Several differo.'"lt choices may be desirable i f ally a few
data points are kno.rm or 1..£ P"~Ysical cn'lStra.ints require accurate ooot.rol of
the curve shape at the ends . 'l1le rrost direct solutioo is ootained by specify-
ing the two end tangent vectors P' and P ' of the total picccoiliso spline. '11tis
1 n
boundary condition is called tile clarrp?d end corrlibon .in Ref . 5-2, and the
encastered spline in Pef . S-3. 1he CC111'lete matrix equatioo for tro cubic
spline curve is then given i:Yy
(5-37)
1 P ' (K,l) - BU<,l)

M(2, 1) ~:(2 , 2) p• (l(,2) BIK,1l

M(3, 2) M(3 , 3) • P'(J<,)) B(l<, 31

• • • •

• • • •

• • • •

M(N - 1, r: - 11 11(N- 1, Nl P' (}(,N - ll B(K,r; - 1)

1 P ' (K,N) B(l<,N)


126 t-11\'lli:o~TIChL Eina."l'S FOR ~ GRAPHICS

'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

2P ' + 4P ' = ~(P - P ) (5-39)


n-1 n t
0
n n-1

' 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

P " (0) • P" (t ) (5-4 1 )


1 n n
1..c., the s lope .:tnd curvature at the beginning and end of tJle curve are eqtkll.
Recallmq Eqs. (5-16) ard (5-28) to (5-JO) the condition expressed by
Eq. (~40) yields
3 (P - P ) 2P' P' ] 2(P - P ) P' P'
P'- P ' • 2 n n-1 _ n-1 _ -E. t +3 n-1 n + n-1 + ..12 t cs- 42)
1 r -1 t2 t0 ln n t t2 t2 n
n n n
SinUlarly the condition expressed by Eq. (5-41) y1clds

lfl '1 - p I ) _ 11''1 _ r•2 • ~ J r)(l' - I'n-1 I __


2P'n-1 _ I''] fl ll'n-1 - -"-
P ) • -Pi~
P' I'']
~ ~
r
7
t :1
1
l7 t2
n
t
n
tn
n
tn
• {
tl
n
t
n
1
t"
-n
(5-43)
SPACE CURVES 127

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\

Recalling that Pi • P~ and rearranging the terms yields

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)

t-i(2 , 1) t-1(2,2} M(2, 3) • P ' (K, 2) 8(1<,2)


t-1(3, 2) f.1(3, 3} • P' (K,3) B(K,))
• • • •

• • •

• • •

t-t(N - l,N - 1) P ' (K, N - 1) B(K, N - 1)


t-bnnal Gaussian e.l.imi.nation or otro.r matrix inversion rreth:xis can be used to
invert the nontridiagonal matrix in El';{. (5-46).
f'.btice that ~ P ' and B rratrioes are r'OII (n - 1) x 1 rratrioes as required
for matrix nultiplication in Eq. (5-46).
The anticylic spline is similar to the cyclic spline, except that
P • (0) = - P ' (t )
1 n n
and
P " (0) = -P., (t )
1 n n
Following that sarrc prooedure used to derive El:J. (5-45) yields
t t t 1
2(1 + t;>Pi + Pit;-- Pn-l = 3(P2 - P1 )~-+ l(Pn-l - Pn)t;; (5-47)

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

tiXlc but opposite in directicn (cf Fig. 5-2b) .


The cubic spl1ne end conditions considered above are S\.IIITI\arlzed m
Table 5-l.

'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

di>1 dt ~ "' -dl'tdt ~


M(l,1 )
M(l,2 )
.. 2 c1 • t / t >
- tr!tz
2
s cK,l l • 3 <P 2 - P
t-)(P 1 - p ) (1/ t. )
n ~( l,!i-1 ) ; -1 n- n n
r-1 t:...~,
and
2
2 d ii
d 2v/ dt ~- ::2 BIK,~) : undctinod
t-o dt t~
n
k•l K•r.-l

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 .
'

SPliCE aJRVES 129

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.

E:xarrple 5-1: alBIC SPLINES

Assune that the three (X)Siticn vectors P (0 OJ, P (1 2) , and P (3 2) are


1 2 3
u• J<na..m . We wish to detez:mine a cubic spline fit through these (X)ints usinq re-
laxed end o:::nditicns . We base trrax on the chord lenqths of each span.

' To begin we first calculate the chord distances t

~ • ;(~ - ,_,2 + (y2 - yl)2 = 1(1)2


2

+ {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

P(0. 745)"" (0 O) + 0.745[0.3013 1.1305) + (0.745) 2 [0 0] + (0.745) 3 [0.0293 -o.0472]


= {0. 2366 0.8227)
arrl similarly
P(1.4907) = (0.5462 1 . 5289]
For the second span, Ekjs. (5-27) and (5-30) yield
11. • p2 • (1 2)
82 = P'2 = [0.7394 0.4224}
3(P2 - P2 )
2P ' P'
83. 4 - 2 - ~a (0.19535 -0. 31685)
2
2(P2 - P3 ) P' P'
84- 8 + ~ + .2.; [-0.03253 0. 05283]
4 4
~ choosing t/t3 • 1/3, 2/3 yields t • 2/3 , 4/3, and Eq. (5-11) gives

P(2/3) = [1.573 2. 1579]


P(4/3) = [2.256 2. 125)
'n1c re.sulLs are plotted in Fig. 5-3.
It should be noted that it l.S not
necessary to mvcrt the rratrix to obtain the internal derivatives . E>quatioos
(5-24) 1 (5-38) I and (5-39) can be easily solved by sl:bstitutioo to yield the
~~ resw~. I
An algont:hrl for gene.rat.lJ"-9 cubic spl.L"te fl.ts for n kno..n data p:>i.nt.s l.S

c;1ven L" AWC."ldix c.


It is possl.ble to nai<e vari.o\!s ~· fl.caticns to the" a!:x:M! r ec"v-.ique "'t-.!.ch
may offer ~t for certa.1.n appll.cation.s. For e:<c:w""Ple, in Ref. s-s,
l·ann..lng describes an a.lgon.thlu in which the shape of t:he ~........e l.S CXXltrolle3
b'J varytng the tangent vector ragnitudes at the data points (!<rots/ thra.lgh
wtuch the curve passes . nus technique has found applicatial .1.n carp.rt:.cr-aided
footweM eesic;n.
Arother rethod for ir"provinq curve sn:x>thness for m<plic.l t cubic splines
was rcp:>rted l:tj.• Detlt'a"\ (Pef. 5- 6) . P-is technique requires an interactive
nt:reral Sl"...arch and the use of Gaussian quadrature mtcgration . Details are
descnbcd m the c.1t.ed reference. 'lhe t:ni.q-E feat ure of this n:thod l.S d-.at the
end c::ondltions are autaMtically selected based ~..{a' a rJ..nimiz.auon c:n.tencn.
It hAs been ased 1.n the autmobile industry.
A t.echn.:..que ''sed to Sl:ccth out undesirable oscillations ~o.hlch scr.et.b~s

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

W' .... :'CJ

• - 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

alonq the curve, and the lhin1 dd 1va-


tivc is only pieoewisc constant. Dis-
CXlCitinuities in third derivatives can
thus induce \JI"looanted inflection points
at certain locations a.l.on<J the curve.
Consl.der a {tlysical spline supported
by docks at certain points. If the
thin, flexible beam has small oscilla-
tions 1 one way to retove them ...ould be •
------- I']
to apply tension to the ends of the beam ., - •
to SttOOth Out the spline. A Jrathemati-
cal spline under tension is an appro.xi-
mation to this procedure. 'I'heory and
applications for this technique are dis-
cussed in Refs. 5-7 and 5-8 .
1
,•
5-6 PAFWn.IC PllNDit-.G L J. J
I J
'n'le technique for paralx>lic blend-
Figure 5-3 Results of cubic spline
ing presented here "'as first suggested fit for Exanple 5-l.
by A. W. Ovel::hauser (Ref . 5-9). 'Ibe interpolatioo scheue CXlCISiders four mnsec-
utive points sinultaneously. A srrooth curve between the 0.0 interior points is
generated by blend.i.ng two overlawing parabolic segnents . The first parabolic
segnett is defined by the first three points, and the last three points of the
set of four define the second ~lie segnent.
consi der four oonsecuti-w points in space specified by the {X)Sitial vectors
P , P , P , and P • '1\o,Q overlapping parabolas P(r) and Q(s) between these
3 4 5 6
points are sho.m in Fiq . 5-4. Each parabola qces through three points and each
is defined relative to its own local coordinate system. The parabola P (r)
th.rolxjh P 1 P 1 and P is CjO\I'Im'led by the follc:Ming equatioo, relative to the
3 4 5
ur-ooordina~ system
u = P(r) = or(d - r) (5-48)
INhere as shown in F.ig. 5-4 r is rreasured alonq the crord length P P and u is
3 5
neasured perpendlcul.ar to r in the plane defined by P31 P 1 and P • The chord
4 5
length between P and P is d. A parabola can be oorpletely specified by two
3 5
end p;:>ints P , P51 and a th.i.rd p;:>.int P on the curve. 'Ibe value of the CXJnStant
3 4
a is chosen such that the parabola P (r) passes t.h.rough P .
4
In a similar rranner I the parabola O(s) is defined so as to pass thrO\.Xjh
the p;:>ints p 41 p 51 and p 6 • The equatia'\ is
v = Q(s) = 6s (e - s) (5-49)
Here s 1s rroasured along the crord length P P , v is perpendicular to s in the
4 6
plaoo defined by P , P , and P , and 8 is d'osen such that the parabola passes
4 5 6
throU'Jh P5 • 'Ihe crord length between P 4 and P 6 is e .
'Ihe par.urctcr t is now chosen as the distance measured alonq the chord
length bct:l.-.;en P and P • A curve CCt>, which is a blend of the blo overlapping
4 5
po.ralxllas, is c::onstructed bet:l.'een P ~ P by use of an interpolalioo schete.
4 5
1he blending curve C(t) is defined as

C(t) = [1- (f-)JP(r) + lf-JO(s) (5-50)


0 0

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

' sho..n in Fig . 5-5 is helpful.


bct'w'Oen P and P •
In Fig. 5-Sa , P J is perpendicula.r to the cOOrd
4
Thus, the ur-plane can be defined by the ve;:tor cht prodoct
I 3 5
(P (5-51)
4 - J) • (P
5 - P 3) • 0
If J is lo:::ated in the ur-plane at r = m,
then in the xyzwo:x>rdinate system
J = P3 + x(P
5
- P )
3
(5-52)

and E>;J. (5-51) may be written


(P - (P + x CP - P ))} • (P -P ) ""0(5-53)
4 3 5 3 5 3

)
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)

Once the points are specified, the procedure is to calculate .x using


Eq . (5- 54) and then a using Eq . (5-57). For a given value of t, r is given •
by Eqs. (5-58) arrl (5-59) . Finally , points on the curve, P(r) , are calcu.l.ated
using Eq. (5-56). This procedure is then repeated for the Q(s) parabola.
To continue generating a curve through aaH tional points, a blend.ing curve
C. (t. ) is foz:rned between each adj acent pair of points. 'lbis creates a contin-
~ l.
uous curve which is also oontinu:rus in first derivative at the internal data
points. 'lhese first derivatives can be easily detetmined i f Eq. (5- 50) is
rewritten as
C(t) = P(t) + (~)(Q(t)- P(t)) (5-62)
0

+ (- 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

) • equals the slope of the parabola Plr) at


P • Likewise, at P on the blending
4 5
cur.<e, t =
t ar¥i P
0
Q. 'lhus , =
p_
(~t) • (~)
r
at: p Ot p
I 5 5
a r r(t l 'Ibe equatioo for the blerrling curve
I
C ( t) is cubic ..men expressed m terms of
'
the haslC car-...esian coord.lnate system.
For t:his reason it can prodUce a p:>int
~
• of .Ulflectioo within an interval. H:Jw-
\l
~s ~ Ohl
ever, the blending cubic which defines
!4 ::.;1 - c..._ the curve between p:>ints P and P does
J - - - f>6 4 5
not pass through P 3 and P6 . 'Ihis behavior
I
makes parabolic blending a different m-
b f> ~c r) terpolatioo ~ than one INhich passes
,
1 a C"Jbic through four p:>i."lts on a curve.
FJ ;u.re 5- 5 Ge:m:!tric relatu:nships According to Ove!i'.auser (P.ef. 5-9) , this
r ft.) and s ( t ) . characteristl.c guarantees that spurious
wiqqles are not l.nt.roduoed ~g the curve defini.tioo.
Parabolic blc.:.'ldi..nq can be used o.>'lly for _nternal segrrents of a curve .
te a swgle parabola, defined through the fliSt
The t:1o.r.> end segr;ents rust each
an:i last throe data p:>l.nts respectively Cc f sec. 4- 9). 'Ihe di.st.anoe between
these p:>.iJlts can te smaller than that for other sec;rents in order to c:are.f ully
specify the shape of the curve at its end points . Also, closely spaced p:>ints
can te uSE(} in reqion.s of high cur<~ature.

'1he technique of parabolic blendi.nq offers a different approach to curve


defi.nitioo a.'Xl generation. In the cubic spline tech.l·U.que discussed previously,
it was necessary to define the catplete set of points and two e.'ld tangent
vectors before the ~ ...as ~ted. In parabolic interp:>l.ation, ooly three
polnts are needed to start a curve . These defl.ne the initial parabolic se;rrem:
t.etween points P and P passing through P • A fourth point can then be acXied
1 3 2
and the cubic blerdi.nc; seg:tent beb.-een p:>ints P and P detexmined as shoom
2 3
above. Su::oessive points may be added, one by one, and these determine the
cx:nunuous C"Jbic blendJ.nq cu..~ segmmts t.~t make up tr.e interior part of
tlv> cun~e. If the shape is rot mnect, the last {:011\t or p:>mts can be
delct.OO and a re11 s.h""'f.C defined by usL""~g alte.rnate points.
When an artist, stylist, or designer sketches, he or she uses short, over-
.lappir.g strokes to produce the cootou:r desired . This is not unlike tile tech-
SP~ Ct..'RVES 137

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.

Exanple 5- 2: PAAAOOl.IC Bu:NDn~

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

r = xd + taos~ ~ 0.3846113 + 8t 2 1.3867 + 0. 9923t


/SID
fbr t/t = 1/3, t = 0. 745 , which yields r - 2.U6. Equatioo (5-56) then
0
yields
P(r) : PJ + ~(PS- p 3 ) + nr(d- r) [(P4 - P3) - x(P5 - P3)1
P(2 .126) = PJ + 0. 5896(P - P3) + 1.0223 ( (P4 - P3) - 0. 3846(PS- P3 )
5
• root + o.ss96(3 21 + l . o223lll 11 - o.J846£J 211
= [O 0) + (1 . 7688 1 . 1792) + 1.0223[-0.1538 0. 2308)
P(2.126) • (1.612 1 . 154]t/t = 1/3
0

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

Q(s) =P4 + e(P


s
6 - P4 ) + Bs(e- s)((P5 - P )- x(P - P4)J
4 6
• P + 0 . 205(P - P ) + 0 . 6887((PS - P4 ) - 0.6154(P6 - P4 )]
4 6 4
-= r1. 121 1. 2511 1t/t =l/J
0

and for t/t


0
• 2/3 , t,... 1.4907 and s = 1.479, Eq. (5-61) yields

Q(l.479) = (2.3882 1.584J i t/t •2/3


0

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

for t/t0 • 1/3,


ceo. 745) = ~P(2 .126) + j.oco.7392)
= [1. 648 1. 361]
and for t/t
0
= 2/3,
C(l.4907) = j-P(2 . 8659) + ~0(1. 479)
= [2 . 352 1.6398)
'Ihe results are stn.m plotted in Fig. 5-6.

An algorithm which will inpl.erent tre parabolic blendi.ng technique


dt:-scnbed above is given in Appendix c.
SP~ ct1RVES 139

5-7 Be:ziER Cl.Rves

The previously discussed r.ethods


for ional-curve generation
have been oonstrained to pass through
all t.l'lo specified data points; i.e. , 3

they are curve fitting ted\ni qucs. 1n


many cases excellent results arc achieved }
with these rreti¥xis. '1be:re arc, however,
certain ~ks which render these 2
nethods ineffective for interactive "ab
initio" curve design. '!his is due to
the fact that control of the curves~

by nurerical specification of both direc-


tion and rragni.tude of tange.nl derivatives
does not provide the intuitive "feel"
required for curve design; i.e. , there
..J
is not always an obvious relatioo be- l
Results of parabolic
tween the nlDI'tlers and the curve shape. blend.i.ng for Exanple
In addition, the cubic curve fitting S-2.
technique specifies a curve o f unique order, which d::les not vary fran spline
to spline. In order to increase flexibility, nore points lTLISt be input, creat-
ing norc spl ines which are all sti 11 of cli>ic order.
An alternate method o f curve description has been described by Bezier
(Refs. 5-10, 5-ll , and 5-U) which all~'S the user a nuch cp:-eater feel for
the relation between input and output. 'lhis enables him to use the pxogcaan
as an artist , stylist or desi9J1&, varying curve shape and order by the use of
easily controlled input pnrarreters until the output rmtchcs the desired shap?.
A Bczior curve is associated with the "vertices" of a polygon which unique-
ly define the curve shape . cnly the first and last vertices of the polygon
actually lie an the curve; however , the other vertioes define the derivatives,
order, and shape of the curve. 'lbus, the curve is defined by an open polygon,
as sho.m in Fig . 5-7. Since the curve shape will tend to follo.~ the polyga1
shape, changing the vertices of this pol}'9011 gives the user a III..ICh greater
intuitive feel.i.ng for input/output relationships. All that is necessary to
increase the order of any curve segnent is to specify another interior vertex.
This qreaUy increases flexibility and owr:co1es many of the difficulties of
the cubic fli>line fitting and parabolic blending techniques . FUrtherrrore, local
control is easy with Bezier curves. Any change in the -..ertic:es of a span will
only effect the curve within that span . ~ne rest of the o.lr'W will retain
P.
- ---
•r.0
,.

Figure 5- 7 N:xtenclature for Bezier C'lll:'VeS .

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

to have a Bernstein basis. 'lhe basis fuoct.ion is given by

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)

FOr ex.ar.plc, for a cubic ,

-- 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

For this c;.,se n = 3. Assune equal in-


crerents :m the pa.ra:retcr
segrrent, sa:,.·, t-= o, l/3,
t for the
2/3, 1. Then
P,
--
using Eqs. (5-64) and (5-65) yields
3! 2
JJ,l(t) .. 11(2) I t (1 - t ) = Jt(l - t 2)
and
31 2
J3, 2(t) • 2! (1!) t (1 - t) = Jt2 (1 - t)
"u '
'111e results are tabulated in Table 5-2.
P,
USing Table S-2 dl1d Eq. (5-66) /
/fP,.
1 8 4 2 l / I
P(J) ,. 27PO + 91?1 + 91?2 + 27P3 /
I
P;;- ~ ')A I
'nlus, to create a cubic curve seq- ""~.../I
nent, it is only necessary to specify the ......... J
PI
the four p:>l;,:JOO vertices and then cal-
culate JX>ints along the curve for Figure 5-8 Bezier p:>lygons for
cubics.
0 ~ t ~ l.O using F.qs. (5-64) and (5-80)

Table 5-2
Results for Bezier Curve

n=J

1 J n,i
0 l/3 2/3 1

0 1 8/27 1/21 0 JJ,O • 1


1 0 4/9 2/9 0 2
J3,1- Jt(l - tl
2 0 2/9 4/9 0 J3,2 = Jt2(1 - t)

3 0 l/27 8/27 1 J3,3 .. 1

as shc1...n arove. lt is not necessary to explicitly ccnsider parametnc deriva-


tives . A user can quickl)• learn to predict the shape of a curve which will be
generated by a certain p:>1}1901'\al shape. Various Bezier cubic curve seqzrents
arc stn.m in Fig. 5-8 .
Although tt 1s not necessary to calSider curve derivatives in generating
142 l~C\L EIDIENI'S FOR C<:M='ln'ER GRAPHICS

i.rrlividua.l Bezier curves, rraintaininq continuity of slope and curvature "tlen


JOiru.ng bolO eezio.r curves requires consirleratioo of these derivatives. The
rth derivative at the st:.artJ.ng point is given by
I It •
pr(O) .. n. L: (-l)r-l.(:)P
(n - r) •1 i=O
.
1. 1.
(5-70)

and at the end point by


r
n!
- (o - r) I L:
i=O
(5-71)

'Ihus, the first derivatives at the end powts are


P'(O) = n(Pl- P ) . (5-72)
0

(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.

, Similarly the secC>l¥3 derivatives are


P"(O) = n(n- 1) (P - 2P + P )
0 1 2
I (5-74)
I
P"(l) = n(n- l ){P - 2P
n n-1 + Pn- 2
)

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)

01 - 0o = ~) CPn - Pn-1> (5-75)

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

Figure S-9 First-order cxmt.inuity in ~ier cubic segrents.


Thus
0 1 + p2 - 2P3
'!hat is, P is the midpoint of P o . Note that continuity of slope c:nly requires
3 2 1
that P lie on P o1 sare..nere bet\.-een P and 0 •
3 2 2 1
For the sane P and Q curves above, seoond derivative continuity is given
by
m(m - 1) co0 - 201 + o2 > = n(n - 1) (P _ 2 - 2P _ + P ) (5-76)
0 0 1 0
As a practical matter it may be necessary to increase the order of the
curve, i.e., .it.crease the nl.llber of p:>lygon vertices to rraintain higher order
derivative continuity. This is frequenUy eas1.er than splitting the overall
curve into smaller setiJieJ'lts ard m:rintaining lower orders, say C\Dic, within the
~t . nus flexibility of increasing the order of curve ~ts to get bet-
ter control of the curve shape is one of the major advantages of the Bezier
rrethod .


Exanple 5-3 : BEZIER aJRVE

Assume that P0 (1 1], P (2 3), P2 (4 3) , and P3 (3 11 are the position vec-


1
tors of a Bezier p:>lygon .
R£lcall Eqs . (5-64) to (5-66)
n
P(t) .. L P.J . (t)
i=O ~ n , ~
n i
where J 0 , 1. (t) = (.)t (1- t)
n-i
and
.n n!
\ 1) • . , (n _ i)! • Here n • 3, since we
1 1 1.
have 4 vertices . Hence
n 6
(i) = i! (3 - i)!
and
0 3
J ,
3 0
ct> = (l)t ct - t> = (1- t> 3
2
J3 , l(t) = 3t(l - t)
2
J3,2(t) - Jt (1- t)
Thus
P(t) • POJ3,0 + PlJ3,1 + P2J3,2 + P3J3,3
table of J
A
n, 1 for various valoo.s of t
is given bela..~ .

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 ~ ~

figure 5-10 Results for Dezier curve


segrrent for Exanple 5-3. Finally
P(O) = P0 = (1 1}
P(O. lS) : 0. 614P + 0.325P + 0.0574P + 0. 0034P • (1.5 1.765]
0 1 2 3
P(0.35) =0.275P0 + 0.444P + 0.239P2 + 0. 043P3 = (2 . 248 2. 367]
1
P(0.5) • 0. 125P + 0. 37SP + 0. 37SP2 + 0. 12SP • (2 .75 2. 5)
0 1 3
P(0.65) : 0.043PO + 0. 239P + 0.444P2 + 0. 275P = (3 . 122 2. 36)
1 3
P(0. 85) = 0.0034P + 0. 514Pl + 0.325P2 + 0. 614P = [3 . 248 1. 75]
0 3
P(l) ; P3 =
(3 1]
'Incse p:>ints are plotted aloog with the defining p:>lygon in Fig. 5-10.

An algoritr.n which nay be used to calculate Bezier curve segments given


t:re p::>sition vectors of the po1ygcn vertices is given in .Appendix c .

5-8 8-SPLit~ CLRVES

From a m2.tl'.ematical point of view, a C\lnE wtu.ch is qenerated by us:ing t:.M


ver+ioes of a defining p:~lyyat is dependent on sare interpolation o r approxima-
tion schcfrc to establish tre relutionship bcO..'eCJ'l the curve arrl the p:>1ygon .
This schal~ 1.S providod by the croice of a basis or ~ight..ing functioo. As
SPK.'E CURVES 145

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

where the P . are t:re n + 1 defining polyqon vertices.


1.
FOr the ith oornalizcd B-spline basis curve or order k, the w.ighting func-
tioos N. k (t) are defined by the recursion fornulas
1,
1 i f x. !:. t _ x.+l
N {t) = 1 1
1,1 J0 0

othexwise

• (t- xi)Ni,k-l(t) +(xi~- t)N~+l,k-l(t)


N . k(t) (5-78)
1' xi+k-1 - xi xi+k - xi+l
'lb:l values of x . are elerrents of a krDt vector which is cliscussed belo..r. 'lhe
l.
pa~ter t var1.es fran 0 to t
along the curve P(t) .
rrax .
An additional variable rrust be uc:ed for a-spline curves to aocount for
the i.nherent added flexiliility. 'lhis 1s achieved by use of a knot vector. A
krDt vector is s.i.nply a series of real integers xi, slrll that x ~ xi+l for all
1
xi. Examples of knot vectors are (0 1 2 3 4) and [O 0 0 1 1 2 3 3 3] . The
values of xi are considered to be pararretric knots . 'lhey can be used to indi-
cate the range of the paraneter t used to generate a a-spline curve with

' O -< t -< t max .


Recall that the pa.ratTeter range for a Bezier curve was arbitranly chosen
to be 0 .i t ~ 1 for a Bezier curve of any order. '~ f'OI deviate fran this con-
vention and use a knot vector to specify the paraneter variation for the cut""'.l'e.

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

For a th.i.xd-ordcr curve defined by fiw vertices, ~ value of t •


nwc
4 - 3 + 2 3. The conplete knot vector, using rrultiplicity of 3 at each end,
is then given by (O 0 0 1 2 3 3 3). A second-order curve for tro sarrc defining
p:llygon has a knot vector (0 0 1 2 3 4 4), a."td a fourU.-ordec curve has
(0 0 0 0 1 2 2 2 2} . If seven polygon vertices are used a thircl-ord,.J" curve lS

desired, then the koot vector .is (0 0 0 1 2 3 4 5 5 51•


As a final cxanplc, consider a polygon of four djstincl vcr.t..locs. 'lhe knot
vector for a seoond-ordcr curve is [0 0 l 2 3 3}. Nc:M, if the 0.0 center ver-
tices are rMde to coincide so that a rrultiple kn:lt occurs between the two end
krx>ts , the knot vector for the sec:ood-order curve is I 0 0 1 1 2 2] •
If suoothness is based on continuity of higher order derivatives, the
order of the curve determines how "srtooth" the curve is. For exanp1e, a fourth
order curve is continoous in first and second derivative, as well as p:>sitlon,
along the entire curve.
The 8-spl.i..ne curve is matherrat.ically defined as a polyromiAl spline func-
tion of order k (degree k - 1} since it satisfies the folla.r.ing t:\..o oondiucns:

The function P (t) is a p:>lyncmial of degree k - 1 on eACh interval


(xi~ t ~ xi+l }.
P(t) and its derivatiws of order 1, 2, . • . , k - 2 are all continuous
over the entire curve.

'lhus, a fourth order a-spline curve is a piece.ri.sC! cubic spline.


Due to the flexibility of B-spl.i.ne curves, different types of control
"handles" can be used to change the shape of a curve . COntrol can be achieved
by changing the integer order k for 2 ~ k !:.. n + 1 , by usa of repeating vertices,
or by changing tOO nurber and/or p:>sition of nc:nrepeat.i.ng vertices in the defin-
ing polygoo. These effects are illustrated in the follo.dng six figures.
Figure 5-11 sho.Ys three &-spline curves of different order, each de..fined
by the sarre four polyc;pl vertices given by 0 0 • The second-o.rder curve
3 9
6 3
9 6
creates three straight lines bet\.Jeen the four vertices, the fourth-order curve
corresponds to the Be'.der curve for the p:>lygat set, al'X1 the t:hi.Id-order curve
produces a looser curve bet-..-een the two end points. Notice that all three
curves have the sane end slopes, determined by the slope of the first al'X1 last
spans of the defining polygon . As the order of a curve increases, the resulting
sha?> lod<s less like the defining p:>lygou shape. '!bus, ioc.reasing the order
tightens the curve.
! t r---~--------------------~--------~------------~

• •

' ' I" •

'• •
• • • 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

Figure 5-13 Multiple knot B-spline curves.


150 wmaP.TICAL El c:.V.ENTS FOR cn!PL"l'ER GRAPHICS

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

Fiqure 5-14 Local c::allrol of B-spline c~ .


SP/tCE CURVES 151

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.

Ex.anple 5-4: &-SPLINE CURVE

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 - O)Nl l (t) (x - t}N , (t)


3 2 1
N , (t) c +
1 2 X:z-~ x3 - X:z
(t - l)N2 ,l (t) (x - t)N (t)
4 3 1
N2 , 2(t) c: +
x3 - x1 x4 - x3

(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

t 0 0.5 1.0 1.5 2 2.5 J


N
l. , )

N0,2 1 0. 5 0 0 0 0 0

Nl,2 0 0.5 1 0.5 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) = +

I '' N4, 2(t) = 1- 1


4
l- 0
(t - l)N ,l (t)
+
(1 - t)N , ( t )
5 1
1- 1

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

(0 . 5)1(0.5) + 0.5(~ . 25) : 0.375

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

5- 1 Rigdon, A., Chlsen, E., Stiles, w. and Weese, J ., t-t!chanics of Natcrials,


2d editioo, John Wiley & Sons, Inc., New York, 1967.
5-2 South, N.E. , and Kelly, J.P. , "An.llytic SUrface l'ethods," Ford Z.lotor
Catpany N/C Dewloprcnt. ll'rit, Prodl.d: Engineering Office, DeoerTber 1965.
5- 3 Nut.boume, A. W., "A Cubic Spline Package Part. 2 - 'nle Mathematics,"
Cc:xrput . Aided Des., vol. 5, no. l, January 1973.
5-4 Adams, J . Alan , "A Ccnparison of l-:ethods for CUbic Spline CUrve Fitting,"
Carput . Aided Des., wl. 6 , pp. 1-9, 1974.
5-S t-~, J . R., "Co!puter-M.ded Footwear Design: A rrct:.hOO of c::a1stnlcting
srrooth curves , " SJ\TW\ (Sb:le & Allied Trades Research Association - SATRA
House, lb:::k.ingham ~d , Kettering Northants, England) Research Re{X>rt
R.R. 251 , December 1972.
5-6 Denman, H. H., "Stooth CUbic Spline Interpolation FUnctions," Industrial
Mathematics, J . Ind. Math. soc., vol. 21, Part 2, Rl· 55-75, 1971.
5-1 Cline, A. K. , "Curve Fitting Using Splines U1der Tension," ll.trro.s . Tech.,
no. 3, pp. 60-65 , 1973.
5-8 Sclr..oeikert, D. c., "AA int.eq:olaticn Ctlr\A:! usinq a spline in tension,"
J . Math. Phys. , vol . ~5, pp. 312-317, 1966.
5-9 OVerhauser, A. w. , "Analytic Definition of Curves and SUrfaces by Parabolic
Blending," Technical Re{X>rt No. SL68-40, Ford f-btor Cl::ltpany Scaentihc
IJ'OOratoty 1 1'1ay 8 , 1968.
5-10 Bezier, P. £., l:.;P10i des t-'dcirines a~ Nurerique, twasson et Cie,
Paris, 1970. Transl.dt.ed by FOrrest , D. R. and Pankhurst, A. F. as Bezier,
P.F., ~iml. Control .r-utherratics and Flpplicatials , John \'Iiley & Scns,
.JlC • 1 London t 1972 •
S-11 ~zier, P.£., •e:xanpte of an Existing Systan in the t-btor Industry: The
Ul · surf Syst.£!'1\," Proc. Roy. soc. (I.ondon), vol. A321 , pp. 207- 218, 1971.
S-12 Forru;t, A. R. , "Inte.rpolaticn and Approx:irraticn by Bezier Polyncmials, "
CNJ C".roup Doc. No. 45, l!-U.., catrbridge university, Q:tobcr 1970.
5-13 SChoc.nbcrg, r. J ., "Contributions to the Pl:cblm\ of Approximaticn of
Ek)w.dist.ant Data by Analync F\lnctions, " Q. Appl. l-lath. , vol. 4, 1946,
pp. 45--99; 112-141.

5-14 Cox, M. G., '"lbe Nurerical Evaluation of B-Splines , " Nathicnal Physical
Iatx:lratory D!l..~ 4, August 1971.
5-15 de Boor, Carl, "()1 Calculat.i.ng ,.'ith B-Splines," J . Approx. 'lheory, vol. 6 ,
pp. So-62 , 1972.
5- 16 Rl.esenfeld, R. F. •aerstein- Bezier l'ietrods for t.~ COrputer-A.ided Design
of Free-Form C\l.n-es and SurfNYS . Ph.D. 'llll!sis, Syracuse tkriversity,
\ l-arch 1973.
CHAPTER 6
SURFACE DESCRIPTION
AND GENERATION

Surfaces and surface representatim play a cntical role in rost design


and manufacturing prcx:csses. 'lb! design and manufacture of aut..ard:liles , air-
craft, s':ups, nachlne parts, glass..rcue, and clothing are obvious exant>les. ~
b:cldi.tiO'\al way of r<..-prescntir.g a surface is to use multiple orthogonal projec-
tions . lb.-ever, l"'&ly couplex surfaces cannot be effic1.ently represented Ul this
rm.nner. <n,e devcloprent of L-rt:eractive cxx1puter-aided design techniques along
with that of ni.JiCI'ically controlled ooch.ine tools has lead to ~ developtent
of rrore effective rmlh:rls of surface representatim. Here we arc not oonoe.rned
with catpUter representatim of JUSt the pictorllll aspects of a surface, but
rather the rrathmt.ltical description of shape fran which either drawings or nt~Ter­

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

6-2 SMRJCAL SuRFACES

SCire properties of curves which are useful in surface defiru.tion can be


derronstrated by considering a surface of Jcno.m analytical description. To this
end cons1der a spheriall surface . Specific curves on t:he surface are defined by
planes wilich 1.ntersect the ~e . As an exanple consider the intersectioo of
a unit sprore and the plane defined by the surface z .. ~l
• a . 'Ihl.s is
1
sho.-m in f'ig. 6-la. The resulting curve lS a parallel of latitu:3e. 'Ihe equa-
t.ioo for the parallel of latibrle is oot..ained by solving the two surface equ.a-
ticns silrultaneously. The ncnpa.rairetric equation for a unit sphere is

~ + y 2 + z2 • 1.0 (6-1)
Thus,

zw defines Ule intersectioo.


In Fig. 6-lb, the plane at r : e0 which intersects the sphere is defined
by
)
' or
cx - by=O (6- 2)
1 1

-.
'\
• \
•I • •I ..a I
/ --
,~ I )
~I I
I
I

/ I
I
I
I

, "'
, ~"

• b

l'•nallcl ol latuudc \l truloiln 111 lc'n~11ul1c

Figure 6-1 Int.ersectioos of a plane and sphere .


'!he resulting intcrsectioo of the plane and tOO sphere yields a para l lel o f
longitude . Solving F.qs . (6-1) am (6-2) sinultaneously yiel ds the equatioo for

the resulting curve, l.. e. ,
b
2
il<_!>
cl
+ 1] + i :: 1.0

1\ spherical surface patch can be foxued by four planes int.ersectl.l'¥} the


~. as shc:1wn in Pig . 6-2. 'Ihis creates bolo parallels of latitude and two
parallels of longitude for the patch bolrdaries. 'llle vector equatioo f or the
result:.l.ng surface patch 5(9 , ~) is
• -+ •
s = (cosesin$)e
2
+ (oos~ >e
3 (6-3)

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 ~.

1\ pararretric representation of the un.it spherical surface is


X • cos6~ (6-4)
y = sil16si.nQ
z = cos¢'
Notice that two pardlmters 1 and ¢ are required for the pararretric representa-
tioo of a surface. The patch shc:1wn in
Fig. 6-2 is defi..ood betw'een 0 ~ 9 ~ 'Jl/ 2
am ~;4 ~ v ~ 11/2 . Fran Fig. 6-2 tNe
see that the surface paten is defined
by the four boundary curves AB, oc, CD,
and Dr\. FOr the spherical patch these
1
are cil:cular arcs. Further analysis of
Fig. 6-2 shows that the shape of a b::lun-
dary curve can be descrHvxl by specify-
lJ
ing the tangent vectors at the end of
each curve, i.e., the eight tan<]ent
vectors at the end of each of the corner . ()

p:>ints A, B, C, and D. For a


analytical surface these end tangent
vectors can be obtained by d.if ferenti-
~

y
/D

ating the equatim describing the t II 2


surface. For the spheri cal surface
shown in Fig. 6-2 these are
Figure 6-2 Spherical surface
as . ..
as : -(SJ.n'ISi,n<f ) el + (COS6sin¢)e2
-+
(6-5) patch.
$as .. (cosecos¢)~ .. + . • - {siM)e•
(sl.n°oos¢)e
2 3
(6-6)

'Ihe rragn:i.t:u.'ie of each of these tangent vectors is unity . At comer A, (1 = O,


~ = Tr/2, and


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

•~l//2)2 + {1//2)2 e 1.0


'Ib! l.angent vtctors at all four comers are shown in Fiq. 6- 2 and are given in
Table 6-1.

Table 6-1
Tangent Vectors for the Spherical
surface of Fiq. 6-2

Point as;ae as;ae CIS/CI¢ Iasr~l


A
... 1
....
1
e2 -e3
1 .... 1 1... 1 ..
B -e
li 2
- -e --e
12 1 12 3
1
12
1+ 1 .. 1 •
c -- ;
12
-12l -e- -e
12 2 ~ 3
1
.... +
0 -el 1 -e3 1

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)

'Ib! magnitu::ic of the twist vector is

c:os2Poos2~ .. COSQ
Note at oomer A,
Ia2s;aea¢.- o
a2s
aea~
- .C2eoos2¢ +

and at cm::ner c, a 2 sh"CI~ = -<1N2>~1 • '!he twist


(6-8)

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

Point il/a~ <as;ae> I /lB(ClS/ ~>I

0 0

B 1/12 e 2-· 1/l'i

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 .

6-3 PLANE ~FACES

Sate of tr.e techniques for surface reprPSentatiCI'l are rrost oon\A:!f\iently


described by considering a plane surface . In thls sectiCI'l we restrict ourselves
to a four-sided plane surface. l1'le four sides def.i.nin<] the surface are four
pa.rarretric curves or lines which o:>nnect: the four corners

and form the shape o f
the boundan.es.
As sha..m by El:] . (6-4) in the previous section, it is possible to express
points wtuch fall on a surface in terms of ~ parcllOOters. Let these ~
pa.ra!l'eters be u and w. The expression for the plane surface is then
w x = f(u ,w) (6- 15)

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..~

plane into the desired surface in the xy-plane .


The derivatives of the point functions x and y as defined by Fqs . (6-15)
are
oXd + ~ XA..
dx • auu ~

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

Consider the surface in the xy-plane defin<xl by two paranetric cqwtials


given by
x=Ju+w
y - 2u + 3w + \.5oo'

Wl.th bomdaries specified by


u =0 0 ~ w ~ 1.0
u = 1 0 .!. w ~ 1.0
w = 0 0 -< u < 1.0 -
'.Ihls surface is shoom in Fig . 6-4a.
w = 1 0 < u < 1.0
- -
'lbe equatioos for tm boundaries can be
obtained by substuting the appropriate u and w values. 'lhey are
u=O ya3x
u = 1 y = 4x-10
w • 0 y,.. <t>x
w=l y=x+2
'l11e derivati\1\:.:t which appear in the F.q . (6-17) are a~au = 3, ~~aw Co. 1,
ay;au • 2 + w, and 1y/f!w = 3 + u. Front these partial denvatives the slopes
of the boundaries can be found. It fol.lc::Ms that
~ • ";)au • 2 + w
dx ~ au 3
along w • oonstant, and

al0119 u = constant. These s lopes can be verified in Fig. 6-4a .


I f desired, additional pararretric l.inBs may be a<Xbl to help represent
the surface patch. For exanple, when u • 1/2 the equatiat for this parametric
line is y • (14x - 17)/4. hben w • 1/2, the pararretric line is y •
(l Ox + 13)/U. These 0.0 surface paranetric lines are shcJ..m as dashed lines
in Fig . 6-4a .

Similar calculations can be made for an expressiat for a planar surfc'!IC'e


written as
u = f(x,y ) (6-18)
w= g(x,y)
Figure 6-4b sh:lws the surfc'!IC'e defl.ned by
2
u -L
X
w:-
,2-
y
'!he l::loormries are 9iven by
u- 1
- -
1 <w < 4
u- 4 <w-
1 - < 4
I
w=1 1 -< u -< 4
w- 4 l.i.u.i.. 4
". ( '
C]-----+---------·-----+---
'Ibe equations for each boundazy curve are
indicated in Fi9 . 6-4b . Many other types
of curves, su:h as o:::nic sections , C\bic
splines, Bezier polynanials , o r B-spl.ine

curves can be used to de fine the boundar-
ies of surfaces.

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

Figure 6-4 Plane surfaces.


functioo
P(u,w) = (x(u,w) y(u,w) z(u,w)J
A curve on this surface m!IY be represented by fixing either u or w, e .g. 1
P('\ ,w) represents a curve along u = ' \ • constant, and P(u,wi) represents a
curve along w a w1 m cono;tant. A curve an the surface P(u,w) rray also be
represented by specifying sare relationship betl<.leen the ~ pararrctcrs, e.g .,
f (ulw) • 0. 'I11is relationship might define the intersection of a plane witl,
a surface patch, for exarrple.
A poinL on the surface rre.y be represented by specifying values of roth
pararretcrs, i.e. , P ('\ 1 wi) , or by specifying ~ independent relat.i.cnshi.ps
beO.'eell the pararetcrs1 say, f(u,w) = 0 and g(u,w) - 0. Note that the latter
representation does not necessarily define a single fixed point.
We will consider that a surface patch can be built up ftorn knoNn data:
i.e. , we oonsider a surface to be constructive. With this in mind we adq>t
the fol..lowi.ng convention:

P is the vector obtained fran kr'lcMl or input design data.


0 is the vtX:tor defining the surface coost.ructed from the input data P .

'Ihus , P and 0 coincide ooly at the specified data points.

6-5 BILINEAR SuRFACES


One of the sinplest surfaces is the bilinear surface. Coosider that the
four corner points of the surface are given in the u ,w-plane by P(O,O), P(O,l),
P(l,O), and P(l , l), the corners of the unit square. tte wish to construct a
bivariate functioo or bilinear surface Q(u,\.,t) where (u,wc(0,1)) allows us to
linearly-interpolate any p:>int on the surface . 'Ihis yiel ds
Q(u,w) = P(O,O)(l-u)(l-w) + P(O,l) {1 - u)w+ P(l,O)u{l-w) + P(l,l)u,.; (6-19)
or
Q(u ,w) =( (1 - u) u J rP(O , O) P(O,l)] [1 - wl
LP(l , O) P{l,1) w J
,..hlch is sha.m in Fig. 6-5 . Here it is easy to venfy t:hllt
Q(O,O) : P{O,O,, etc.
Also, a (Xlinl in the center of the sur~ace (u = w = 0.5) is sirply
(P(O,O) + P(O,l) + PCl,Ol + P(l,l))
QCO . 5, 0. 5) 4
tn general, a bilinear surface and t-'le (Xlsi tion vectors of t!-.e ccmer points
of the surface are three dJ..""eJ'\Siona.l. 'Ihis is perl'>.aps easier to sec i f "-"e write
Ec;. (6- 19) in a rrore o:xtpaet IT'dtrix forr: . In particular ,
Q(x(u,w), y (u,w), z(u,w)) = L~

where IJ is a (XlSiuoo vector on ~ interpolated surface , P iS tile ll\3tri.x of


• ) •

PI(! II - - -- - --,l"illl

Ql -~~01.11

PtU 1Sll:!5t

Pl0.01

p ( I 01 u •
QtfJ.O)
l •
Qr flJ -•
• • a., •• • •
.. .. ,_ . •
- . .. • ""L ' .., • • •

Figure 6-Sa Planar bilinear surface.


positiOO \.'eetOrS o: the comer points, a"ld U • r (1 - U) (! - t:.)W U(l - W) u..-) .
An exan-plc using t:-..o-dilrensional posit.J.on vectors is shown in Fig . 6- Sa.
J..n exanple of a th.-ee-dilrensional bilinenr surface 1s sha.m in Fig . 6-Sb . In
Fig. 6- Sb tr.e as~ three-dir'er.siooal position vectors were four of the el.CJht
corners of a unit cube.
/In algorithm ,..;uch will create a bilinear surface patch is given m Appen-
dix c.

5-6 loFTED 00 R1u.o SuRFACES

Lofted cr ruled surfaces are freq..lently associated with the aircraft or


shipbu..l.d....r.9 ..n::lw;tries. To obtain a lofted or ruled surface, asS\m'E! that bo.o
bor.Jndary c-.JI:VeS asscx:utted with the opf()Site s;dtts of t.~ unit square 11\ the
u ,w-pl..ane arc knc;r..n, say, P(u,O) and P(u,l). 'lllesc li\3Y be defined using a."l}' of
t-lm t.E<:h.ruques discussed .i.r. Chapter S. A ruled or :ofted surf~ is then ob-
tained by 1 u:early 1nterpolat.l.ng between these t"-'0 curves, as stown in F'i.g. 6-6.
The intcrpol.atioo ~ is
Q(u,w) • P(u,O) (1 - '-') -. P(U, l)\o.' (6-20)
1'<1 II

\\•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

l>fO.(ll I0 Ql~ O.St

[x(u,w), y(u,w), z(u,w)J Figure 6-6 lofted Surface.


• ((1-u)(l-w) (1-u)wu(l-w) w) P(O ,Ol again note that
P(O,l)
P(l,O) 0(0,0) = P(O,O), etc.
p(l I l) F\.trther note that the edges of the mter-
- ((1-u) (1-w) Cl-u)w u(l-w) w) 0 0 0 polated s\lt'f.ace and the given data curves
0 1 0
are coincident, i.e.,
l 0 1
01l O(u,O) = P(u,O)
Figure 6-Sb 'lhree-dirrensional Q(u,l) = P(u,l)
bilinear surface. Alternately we can assme that P(O,w)
and P(l , \,.) are knc1Hn. 'Ihe lofted surface is then given by
Q(u,w) • P(O,w) (1- u) + P(J,w)u (6-21)
N}ain it is easy to shc:M that
0(0,0) = P(O,O), etc.

Ex:anple 6-2: U>f1w SURFJ\CE

'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.

fr-7 Ltt-lfAR Qxx.Js S~FACE

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

Q(u,w) • Ill- u) ulfP!O,w>J + (P(u,O) P!u,l>)[l-wj- 11- u u}rP(O,Ol P(O,ll 1 [1 -w]


LP<l,w) w IPo,o> PU,uJ w
or nore <XJLpactly as
Q(u,w) • [1- u u 1] -P(O,O) -P(O,l) P(O ,w) 1 - w
-P(l,O) -P(l,l) P(l,w) w
P(u,O) P(u,l) 0 1
'ltle functioos (1 - u), u, (l - w), and w are rolled blending fmct.ions because
t:Ney blend the boundacy curves to produce the internal shape of the surface .

Exarrple 6-3: LINEAR cx:x:Ri SURFACE

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

Other points en the surface are calculated in a similar manner.


An algorithn which will ~ate a
linear COOns surface as described by
Eq. (6- 24) is given in Appendix c.

6-8 BIClBIC Ste=ACE PATOi

'1lle previous sections have discussed


the representatioo and descriptioo of
s.inple surface patches fmn a CO'ICEptual
point of view. Ne l"'f:M turn our at tention
to sane practical aspects . One of the
nore useful patch descriptions uses para-
It rretric cd>ics for the edge curves P (u,O) ,

z P(u, l) and P(O ,w) , P(l ,w) and the blend-


ing functions . 'l'he blending fU'Ictions
IJJ for this schene are derived below .
) Fran our previous work (cf Sec . s-3)
'' recall that the fotm of a parcmetric
C\bic is (cf BJ. (5-ll))
P(t) ~ B + 8 t + B t 2 + B t 3 (6- 25)
1 2 3 4
Figure 6-7 Linear Cbon' s surface .
"'here P ( t) is a vector-valwd fmct.ion
having x-, y-, ~tpcue.nts. For cawenience we limit the range of the para-
nenter to 0 ~ t ~ 1; i.e., we use a nox:rna1 ized pararretric cubic. For the
bo\J'ldary curves of a surface, t "" u for one pair of curves and t • w for the
other pair.
We no,..t derive the blending functions which will allow interpolation of
the points oo the unit square beb.~ the bolo paranetric Cl.bics describing the
edge curves , i.e ., bebo."een P(O) and P(l) . '!here are four \l1'lltnam coefficients
i.n BJ. (6-25) , and thus we nquire four i.ndepenoont equations . Pecalli.ng that
the derivative of the pararretric cd:>ic is
P' (t) = 82 + 283t + 3B4 t 2 (6- 26)

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)

where in general, ~i.th t as the paraneter,

(F (t) F (t) F (t) F (t))


1 2 3 4
= (t3 t
2
t 1) f 2 -2 1 1 (6- 33)
-3 3 -2 -1
0 0 1 0
1 0 0 0
'Ihe F i ( t) ' s CM be oonsidered as scalar blending fU'lct.ioos for the pararretric
ctbic. 'lhey blend the quantities P(O), P(1), P'(O), and P ' (l) ~ther to !onn
a cx:nti.nuous C\l.t'W. Figure 6-8 sho..rs these blencll.ng functions.
toJe nt:JW utilize these results to gererate a b1C\bic patch. 'lhe sane pn:r
~ure that ~·as
used to develop the fonn for the bi 1 inear patdi is enployed.
~~ first oonst.r\ct surfaces which will satisfy one family of boundaxy ccndi-

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.

Before prooeeding, sare notatiooal details are islportant. For oc:nvenien~


in later work we int..roduce a superscript notatioo for the derivatives of posi-
tioo wctors . In particular

Pa (u) .. a<lp (u)


aua

\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)

Alternately Fq. (6-36) may Le written tJore oonpactly as

Q(u,w) "' (u 3 u 2 u l)N P NT [w3 w2 w l)T (6-37)


~re N is tho squaro I"Adt.rix given previously in Eq. (6-31), ll1ld P is the ~r
matrix given in Fq. (6-36). NT is the t.ransposc of N.
Examination of Fi:JS. (6 36) and {6-37) shaRS t.hat biai:lk surfac:r patch
is defined by the Cl.bic blending functions r 1 , F2 , r 3, F4 , four Cl.bic bo\a'ldary
curves , four oorner points , eighL tanCJent vectors at the oorncrs, and four twist
wctors at the oorners .
'nle 4 x 4 P-rnatrlx may be considered as a boundary oondition rr..).trl.x. It
cxntains only infonratioo aboul oome.r points, oorner tangent vectors , and
oomer twist ~ctors. For a given surface patch all thP elennnts in the P-
mrtrlx are kno.m oonstants. Examination of the P-matrix s}n..os that the t:errs
can be c lass1tied as
rCoTJ"Pr I w-tangent
ooonlinates : vectors
p;: _ _ _ _ _ _ _.,. _ _ _ _ _

1
u-t.angcnt Twist
I
vectors 1 vectors

Sinoe for the surfao:> palc:h to be physically ~le , adjao>nt boundary


curves nust intersect at a oomer, calStraints are placed on the specific func-
tioo used to represent the bou'ldaty curves . For eY.anplc , at oo~r A in
Fig. 6-9, P(O,w) ... P(u,O): at corner B, P(O ,,~) = P(u,l) 1 at oomer C, P(u,l) •
P(l,w); and al corner o, P(l ,~r1) = P(u,O).
A carp t ete deri vatim of the oonstraints inposed on the blending functialS
in order that they satisfy certain booodary CXX"'ditlons was derived in ~f. 6-4
and is giwn in Table 6-1.
The sh~ of a bicubic patch is oontrolled by the ca'\tents of tho 4 x 4
P-rratrix, i.e., by tho l.ocatioo of the oorner PJSitioo vectors and the fT\agl\i-
tWe and direction of the correr tanqent and bast vectors . Figure 6-lOa
stn.os the effect of c:hanging thr> magnit\XP but not the dirccticn, of the oor-
ner tangent vectors along the (O ,w) ari<J Cl, w) boundaries. Figure 6- l<b sho.ols
the effect of chanqinq the direct.J.on , bul not tl'lr> JTagnitude , of these sare
comer tangent vectors. Figurr.s 6-lOc and 6-lOd show the cff<'Ct o f addi.ng a
twlSt. ~ to an initial surfacr; patch wit.h zero b.tist \JIC!Ctors .
174 NM'liEM\TICl\L EIJOJ-1ENI'S FUR OO.v.Pt7IER GRAPHICS

'lhe bicubic surface patch has been suc-


cessfully used to design surfaces (cf
P.efs. 6-5 and 6-6). Ho..-e'lleJ", several
discdvant.a9es exist when usmg bicubic
1
p 11.1)
surfaro patdles in a carputer-aided
design system. '1he rrajor disadvantage
exists because three different quantities,
position, tangent and odst vectors all
generally of different orders of rragnitu3e
nust be specified to describe the surface .
For ex:anple, for .a patch 10 units long,
the tangent vectors mi¢\t ha'v'e an order
P<O.O) 1\ of n-agnitu.Oe of 10 units, the twist vec-

zw tors 100 units, and the position vector


1000 units. FUrt:har, the user typically
lacks intui tioo when creating surfaces by
changing elemnts in the definiJ'Ig rratrix.
For ex.oop1e, the oorner tangent vector
P 0 • 1 (0,0) p:>ints toward the interiol. o f
Figure 6-9

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

*Prirres indicate differentiatioo with respect to the


indepe.r.dcnt varicble either u or w.

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 (

Figure 6-10 COntrol of bieti:>ic surface patdles .


0 1
t:.angent vector P ' (0 ,1) points ;rway f.ran the inte.rior of the boundary curve
as shom in Fig . 6-ll . Also note that increnenting the y-cx:xrp::l')ent of the
ex>mer tangent vector P0 ' 1 (0 , 0) causes the (0 ,w) boondary CUlVe to bend q:> ,
0 1
"hereas incresnent.i.J'lg the y-cx:rrponent of the corner tangent vector P ' (0,l)
an equal anount has the opposite effect at the (0 ,1) corner. '!be sare ll"teX-

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.

6-9 THE F-PATOi

In order to eliminate sare of the prcblems lolhidl oca.tr when manipulating


bic\bic surface patdles, a si.JTplified version originally due to Ferguson (cf
Ref . 6-7) , called an f'-pat.ch , is sorret.:i.Jres used. An F-patc:h is silrply a bicubic
surface patch with zero blist vectors . Ql.ly first-order CXXltinuity is possi-
bl e across the boundaries of an F-patdl, because the surface is oonstrained to
leave zero cross derivatives at tile oorne.rs . This on occasion may lead to
176 l~J\!HE.l>oo-ICAL EUMNI'S FOR C'G'.PUTER GRl\PHICS

surfaces which are not sufficiently srrooth


for sene appllcat.la15 . Nevertheless , it
~-~6-:-:- is easier to oonstruct and rodify an
pO.Iw o F- patch, and they are suitable for many
pO lw 1 types of surface definition. In partic-
ular, F-patdJeS have proven to be useful
) \
for axisymnetric surfaces, e . g ., vases ,
\
a lnattal cunc cups , bottles, aixa:aft bodies , etc .

6-10 BEZIER SuRFACES

'lhe previous sections have dis-


cussed a n\.Dibe.r of aspects of surfaoe

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 )

seocnl p:>int on the first 8ezier tx>lygon


in the w-clirectioo. The p:u.nts
• 8 1,3'
8 2,4' 83,4 ' 84,3' 8 4 , 2' and 8 3,1 are de-
fined in a similar manner. 'lbe tx>ints
~, , 8 , , B , , and
2 2 3 3 3 s 3 , 2 interior to
the defining £X>lygonal surface are used
to define the twist vectors at the cor-
ners A, B, C, and 0 respectively. --- " ( 1 - .....

As shown in F'ig. 6-12 the Bezier


surface is cnuplete1y defined by a net
of design {X)ints Cl'l the p:>lygoo.al sur- --· Unundar ) ,-,r Ocl ttt •ur(act
face . 'Ihese £X>l.Ilts serve to define a - Sur (;aH Llc ~li!O ntt
two-pararreter family of Bezier curves on
Figure 6-12 4 x 4 Bezier surface
the desiCJll surfac:o. To generate a para-
~ture .
rretric curve on the Bezier surface shown in Fig. 6-U, let the pararretric curve
be defined by 0 ~ u ~ 1. 0 and w = 'i., where 0 < 'i. ~ l. 0. Before this curve
can be generated, the elerrents in the s-tensor given by Eq. (5-53) DUSt. be
known. For w = S, the matrix product
3
[81 (1 - w) (6-40)
3(1 - w)~
3(1 - wlif
w3
w=C
1
produces four position vectors P , P , P , and P for the Bezier polyyon which
1 2 3 4
defines a Bezier C'UI"Ve with a pararretric value of w "" The point P lies
1
'i..
on the surface bo\D'ldary OW, and the p:>int P lies on the surface bourdary 1w.
4
The points P and P are slq:e des1gn points which lie o ff the curve.
2 3
'nlen, the rMtrix prodoct

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)

'llle equatioo for the bouOOary along u =0 is


C a [(1- u) 4 4u(l - u) 3 6u2 (1- u) 2 4u3 (1- u) u4 J (6-48)
-- I
)

a,, ---v. -o-

Figure 6-13 3 x 5 Bezier surface.


'lhe surface equatioo is then given by
4 2
P(u,w) = ((1- u) 4u(l- u) 3 6u (1- u) 2 4u3 (1- u) u4 ][Bl f (l- w) 2 (6-47)
t~l -
w)w

A five-point Bezier boundary curve has an advantage over a four-point


curve, since a change in the central design point does not effect the slope at
either end of the bouroacy cu.rve. 'lllus, t.l)e surface shape can be changed with-
out disturbing the slope design points, which may then be independently spe<:J.-
fied to satisfy continuity requi..rerents with adjacent surfaces.
'1lle Bezier surface discussed above can be represented in the fonn of a
cartesian product surface. In particular the surface .l.S gl.Ven by
m m
Q(u,w) • L L: Bi+l , j+lJn,1. (u)Km,J. (w)
i • O j-o
{6- 48)

\o.t lere by anal ogy with F.q. (5-63),


• •
Jn,i- ~)ul.(l - u)n-l. (6- 49)

K . • f.!iwi (1 - w)m-j (6-50)


n,J J
and m and n are one less than the mll'ber of pol}'9011 vertices in the w- aoo

Bezier has been successful in using his technique in a production environ-


n-ent as described in Ref. 6-8. In the Uni.surf system at Rclgie Pcnault a free-
hand curve is first drawn with a pencil in the xy-plane to give y • f(x) . A
o::rrputer controlled drafting lT\!lChine used as a ctigither receives the input
ooordinates of the polygon vertices which roughly define the curve. '1lle result-
ing Bezier curve is then drawn by the CXZtpUter controlled drafting rrach.ine. If
rn::rli ficaticns are needed, the pol~t vertices are adjusted and the curve is
redr1Jwn mUl the designer is satisfied. A th:reE~immsional curve is oo~
by repeating the process to produce z : f (x) •
nus rrethod is used to define the four bomdaJ:y curves for a surface .frane-
\o."Ork. The surface definitioo is then catpleted by specifying the coordir\ates
of t.ie rc:na.in.ing surface design ~rk points. 'lhls data is then input into
a CCITpUte.r prograrmed to prrrlx:e rotated, scaled, or perspective vieo..'S of the
described surface curves or into a c:arputer ccntrolled cutting rnach.iJ1e to pro-
dice a ional nodel !ron a block of polystyrene foam.
A. P. Annlt (~f . 6-9) has also developed a design system called MJLTim
which makes use of Bezier surface patches. His system allows easy use of various
types of Bezier boundary curves, rangin<J fran a three-point to a seven-point
curve definihoo. 'Ihis capability is dependent \¥Xl the binomial. nature of the
blend.i.ng functic:ns . A surface f~rk of six-point and four-point curves ~'85
found useful for m:my applications. '!he system allo.ols for curve splitting at

any point to produce a pair of cxmtinlDus C\.I["\1!!5 of the sarre order as the pre-
vioos single curve. 'Ibis system is described in Raf. 6-5 and discussed in detail
in Raf. 6-9 .
Serre of the difficulties associated with Eq. (6-48) as with the eezier
curw are concerned wi. th local control. This is because the Jl'O\Ie'!'ent of one
point on the polygonal generating surface will affect the entire Bezier sur-
face . 'lhls can be a distinct disadvantage to the designer, especially for detail
work. In order to obtajn local control a patch nust effectively be sulx1ivided.
'lhe use of a B-spline basis, i.e . , by using B-spline curves as bl.endin<} fmc-
ticns, eliminates this problem. This is discussed in the next sectioo.
An al9Qrit:hn which will generate a Cartesian product surface based oo
Eq. (6-48), using eezier curves as the blending f\.D"'Ctions, is given in AWen-
dix c.

6-11 B-sPLINE SuRFACES



IITplernentatioo of 8 spline surfaces can take many foxms. Perllaps the
si.nt>lest is the cartesian produ:t surface analogous to the Eozier surface of
the previous section . Fbr a a-spline surface the corresponding Cartesian pro-
dlX:t surface is
rn rn
Q(u,w) = L: L
i=O j=O
8.+1 ' +lN. k(u)M. L(w)
~ ,] ~. ],
(6-51)

\o.'here by analogy with F.q. (5-78)


l i f x~. !. u .!. x.~ + 1
N.
l., 1
(u)
l0 otheiwise
"" (u - xi)Ni,k-1 (u) + (xi+Jc - u)Ni+l,k-1 (u) (6-52)
N. k(u)
1., xi+k-1 - xi xi+k - xHl
and the xi are the elem:mts of the k knot vector discussed in Soc. S-8 .
Further,
i 1 i.f yi s.w s. yi+l
~ , 1 (w)
lo~ise
(w - y.) M. L-l (W)
= J ], + (yj+L - w)Mj+l,L-1 (w) (6-53)
yj-+L-1 - yj yj+L - yj+l
and the Yi are the elat\.!nts of the L koot vector discussed in sec. 5 8, and m
and n are ale less than the m..1rber of vertices in the dt:fininq (.Olyqons in t.~
~ and w-directions respectively. The Bi+l, J+l are the pos1boo vectors of. the
def.ininq polygonal surface, as srown for exanple in fi.q. 6-12.
As with B-spline curves , knot vectors with vanous dL--qroes of rrultipll.C"ity
can be defined in either the ~ or w-directions. ~r , the above fonrat:ion
requires that each defining polygon in a given di.J:ectia'l must h.Jve the sarre
degree of mult iplicity in a given direction. Alternate for:nul.at.u::ns could
allow various degrees of knot IT'l.llt.iplicity in a given di.rectl.on in order to
i.ncrGase the flexilJility of local ea1trol. Further di.scussioo of h::w &-spline
curves can be used to form surface patches is given by s. A. Coons, ~-1. J.
Gordon , R. F . Rieoonfeld, and others in Pef. 6-10.

6-12 teeRALI ZED ~S ~FACES

Exatninatioo of the results di.scussed above SUJ9f!Sts a uore qeneral repre-


sentation for a surface. Follc:Ming Forrest (Pef. 6-11) ~ introduce a <je.l"lel"al

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 .,

BO ,l (w) is the ble.ndi.ng function weighting the curve P(u,l).

s0 , 0 Cu) ls the b l ending f~oo \\-eighting the curve P(O ,w) .

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

Q(u,w) • (1 - u) (1- w)P(O,O) + (1 - u)wP(O,l) + u(l- w)P(l,O) + uwP(l,l) (6-19)


Now suppooe t.hat we replNP the linear blending functioo (1 - u) by s0 , 0 Cu) but
still require that s0 , 0 CO) .. 1 and s0 , 0 (1) = o. Further, we replace the linear
blending function u by SO,l (u) and require BO,l (0) • 0 and s0 , 1 (1) • 1, (1 - w)
by s0 , 0 (w) and require that s0 , 0 (0) -= 0
= l and s0 , 0 (l) and w by s , (w) with
0 1
B , (0) and s , (1) • 1. Equatioo (6-19) m:ty then be written as
0 1 0 1
O(u,w) • r 0, 0 CuJB0 , 0 !wJP(0,0) + e0 , 0 CuJ60 , 1 ~J P(0, l ) • a , 1 CuJ & , Cw)P (l,Ol ~ s ,
0 00 0 1 Cu)~O,l(w)P(l,l)
\\hlch may be written as
l l l l
Q(u,w) • L s0 . (u)P(i,w) + E a0 j (w}P(u,j) - E E B
0 .~
(u}B j(w)P(i,j) (6-54)
0'
i-o , l. j~O ' i=O j=O
Noting that in Eq. (6-54 ) r • o, we see that thesla s.inple bilinear COOns
surfaces admit only positional continuity.
The bicubic surfaces discussed in Sec. 6-8 can also be written in a rrore
general form. First let's coosider the bicubic lofted surfaces represented by
fl:!s . (6-34) and (6-35) .
In the lfOre general notatic:n Eq. (6-34) m:ty be written as

and F.q. (6-35) as


Otu,v) • (6-56)

~<~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 ' '

By substitutioo and/or differentiatioo it can be sho.m that at the oorncrs


Q(i,j) a P(i, j)
Ol' O(i,j) • Pl,O(i, j)

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)

0o, l(u, j) ~ PO, l(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

where the blending functions have the properties


p
Br, i C~l = opr • 6ik for 0 ~ p ~ m1 (6-60)
p
as , j (~) = 6ps . ojk for 0 ~ p ~ nj
Equation (6-59) represents the rrost general foon of a CCons surface. It should
be noted that rrost inplenentaticns do not utilize this fonn, but rather ooe of
the special cases discussed previoosly.
Forrest (Ref. 6-11) points out that i f in Eq. (6-59)

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)

which is a typo of ruled or lofted surface. Siroilarly J.f


1 n.
p r,O(.l.,W ) = L ~ pr' s(i,j)B ). (w)
j=O s=O s,
then the surface eguation l.S

1 n.
Q(u,w) = E :f: PO, s(u, j)f;s
j ::{) s::::O I
J. (w) (6-62)

which is a .ruled or lofted surface using the a1t.ernat.Et boundary conditions .


If both the condi.ti01S represented by Eqs. (6-61) and (6-62) are iJTposed,
then the surface equation is
1 1 rni n.
Q( u w) = L .L L ~ pr' s(i-j)Br i (u)Bs j(w) (6-63)
, ieO J•O r-0 s;O I I

which is the so-called tensor prodoct or cartesian product surface. F.quation


(6-63) is .i.Jif.Orto!lnt because it represents the natural extension to surfaces of
the c:auron rrethods of curve approximation. The cartesian surface represented
by Eq. (6-63) or the lofted surfaces represented by Eqs. (6-61) and (6-62) are
the nost frequently :irrplerrented forms of Coals surfaces.
Yhen m
1 )
=
n. = 1 and the 8 . . 's are given by Eq. (6- 57) , Eq. (6-63) repre-
l. , J
sents A bic\bic patch, i.e.,
1 1 1 1
Q(u,w) a L: E L: L: pr' s(u, j)Br i (u)Bs ). (w)
i=O j=O r-0 s-0 I ,

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)

Here the blend.i.ncJ curves satisfy t..OO relatioos


p
6r,i (~) •6
pr
p
8S,J. (wk): 6pr · 6jk 0 -< P -< n). 0 ' k <- N
Notice that the degree of the int:erp:>lated nomal derivatives is given by mi and
nj. Further notice that for N = N -= 1, F.q . (6-64) roduces to the COons surface
described by Fq. (6-56) . Figure 6-14 il l ustrates the difference bet:\..Jcen the
surfaces described by Eqs. (6-56) and (6-64). Figure 6-14a sho....s an exterior
blended sur£aoe. only the boundar:y cuzvcs P(u,O), P (u,l), P(O,w), and P(l,w)
and the corner points, CO!i1er tangent, and twist vectors at A, B, C, and 0 are
considered in blending the center of the surface patch. Figure 6-14b shot.-s an
interior blended surface where the interior curves P(u ,O. S) and P(O.S,w) are
also consideruc:.
'!he generalized lofted surface and the cartesian product surface can be
obtained in a manner ana.l.ogous to trose in t:re previous section . They are
given by
H m1.
Q(u,w) = ·L0 L:0 r 0
p ' (u. ,w) 8
~ r,~
. (u) (6-65) PlO.II
>.= r- -._.;...
P..:Iu.:.::I)_ -!:!PII. II
('
N n.
Q(u,'W) = L ~ 0 5
P ' (u,-w)B
5
j (w) (6-66)
j=O s=O '

and P(u.OI

(6-67)

6-13 CooCLUS I(lll

'llle final two chapters have been an


introduction to scrre of the current rreth-
ods for curve and surface descriptioo.s .
l>\any other techniques have been suggested
and used with varying ~s of SIXX)eSS. h

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

6-9 Armit , A. P. , "~ti.patch ;mel f.Ultiobject Desiqn Systerrs," Ptoc. ~­

Soc. (I.a1don) , 'A:>l. A32l, pp. 235-242, 1971.


6- 10 Bamh.il1, R. E. , and Riescnfeld, R. F. , "c:::onvuter Aldecl Gea1et:ric: Desiqn,"
Academic Press , New ¥ork, 1974.
6-11 Fo rrest, A. , "On CXlons and other M2thods for t;M Representation of CUrved
Surfaces ," Colputer Grapucs and Image Processinq, Vol. 1, pp. 341-359,
1972.
APPENDIX A

COMPUTER GRAPHICS
SOFTWARE •

IP
lit

I~I

In developing the cx:n:::ept.s for a cr:rtprl:er graphics software system it is


ronvenient to diVJ.de the overall system into several parts . '1\.o of the obvious
parts are the sq{X>rt CXJTpUter and the graphics device itself. These are t:oth
harct~e. In considering these descriptions a not too nant:M vi ew sh::luld be

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.

A-1 U:wuJtR tMPHICS PRIMITIVES

As Feinted out aOOIIe, .....tlen designing cr ~a corputcr graphics systan


it is convenient to define those areas ~e the 51J(JEX>rt cx:xrputer I!USt interl!ct
with the grat:nics device. All graphics devirns, of course, reoeivc info:omtion
fran the supp::>rt cx:xnputer as a data stream <X:Il'{X)SCd of binary bits. In partic-
ular cases cne or rrore bits tray be Sl.gnificant.. However, except for very
sofhisticatcd users , the c:arposition of this data st.rerun is seldan of i.nt.&cst.
It. is rrore convenient. to think of the fun.d.anental effoct.s that tho data stream
has oo the graphics device. 'lhese fundamental effects are called graphic
primitives . 'Ihcy generally fall into three areas: cursor control, device state
or rrode control , and graphic input. Here cursor is used in a general sense to
rrean the e.lec:..t:on beam on a Q{}' graphics device, the print head on a teletype,
high-speed printer , electrostatic dot matrix printer, or the pen oo a pen and
ink plotter, ~- We Wl.ll briefly
IIRIT discuss the grat:hic primitives associ-
ated with each of these areas. Fran
these graphic primitives several carr-
pouro graphic cx:xnrands can be developed
which are of nore general interest.

OOA ~PI.lATIDl :: i rumtl llJ'Mf.R '


These will be discussed in the next
secticn.
'lbe boO graphic primitives associ-

!£VI~ MlA &'~ ated with cursor control are

t.nve the cursor


TUrn the cursor en/of!

'lhe function of each of these primitives

.-1-.I is sel £-explanatory.


'nle graphic primitives associated
C,_.,UCS
tEVTCfS W1th device state or nrx3c control are,
for exanple:

Al(ilantm'eriC !rode (1)


Figure A-1 Q:r)ceptual vie.~ of a
cx:xrputer graphics software system Graphics m:x1e (2)
190 MM'HENATICAL ~ FOR CCK't1l'ER GRAPHICS

Standby rrode (3)


Absolute o:x>.rrlinate node (4)
lelati~ (increrrental) o:x>rdlnate ucde (5)
Frase the screen (6)
Dash line rmdc (7)
01rVcd line nnie (8)
I.oc:2l t.racki.ng a\ (9)
I.ocal tracking off (10)
etc.

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

I reasooably sophisticated graphics device. Before continuing, a ~d about the


I~
II
function of each of these various m::rle.s or states is in order.
Alphammaric and graphics mxles are generally associated with devices \oo'bich
can interpret a data stream as either alftl,anllroric characters or graphic elements.
St.andhy rrnie generally is nsed to disable the terminal such that it ignores data
sent to it and also data ge.'lerated by interactive devices such as key boards,
light pens, etc. J;bsolute and relative cx::ordi.nate nodes detel:mine W'lether the
o:x>rdinatcs specified in the graphic primitive positioo <:Xm'\\Uld are to be inter-
preted as absol ute or ro.lative o:x>rdinate data. '!be erase node i s .ittp>rtant
far stora<Je b!he CRr graphics devices. Dashed line noie allows the generatiat
of dashed lines using the hard..are characteristics of the grapucs device.
CUxved line node is used to activate hard.mre curve generatl..oo . UX:a1 track.in9
node can be used to act.l.vate hardware, whlch allows a visible cursor at a CRI'
~cs device to fol.l.ow the IrOveJTent of an interact!vc input device such as
a light pen or the pen at an analog table.
'lhe graphic primitive associated with graphic .input is

read the cursor {X)Sitian .

positioo vector, i.e., either x,y-pai rs or x,y ,z-triplets. All .interactive


co•puter systems and higher level languages have adequate faci 1 i ties for accept-
ing alphamJroric character input, and hence character in?Jt is not considered
as a grafhic primitive .
Fran the above see that there are essentially four g:raprlc primitives
\o.e

which CXIOCCptnally can be represented either as ccmrands within or subroutines


of a hlgher level langu.l9e su:h as BASIC or FCRI'RAN. 'these four primitives are
cn-1Ptm:R GRAPHICS sc:FJW\RE 191

CHFP (control variable)


1-DVE (coordinate, coordinate, <.coordinate>)
KlE (control variable)
oc (coordinate, coordinate, <coordinate>)

~ < > 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.

A-2 CdwreR GRAPHIC Eumrrs


'1lle cxxtputer graE=hic primitives discussed in t:lx! previous section can be
cxxtbined into OCITpUter gra{ilic elerrents. 'lllese are generally c:crtp;:lUnd operations;
i.e., they generally involve rrore than ooe of the graphic primitives. 'lhe
grapti.c elercnnts are of nore fundatrental interest to the user than the ~c
primitives. In fact , tOO user may not be aware of the graphic primitives .
h}a.in, as with the graphic primitives, the graphic elerents can be placed in
three categories : drawing functions, term.ina.1 or picture control f\..B"'ct.ials, a.OO
interactive device control func:tials.
'1lle classification rrethod discussed in Sec. 1-6, as ~Nell as traditional
drawing rrethods, assist in dete.Imini.ng the fundarrental d.rawi.r¥;J elorents. A user
will .....ant to be able to nove the cursor about without drawing, to draw a lule,
and to plot a point. It is convenient to be able to do this in either absolute
o r relative coordinates. 'nlese ideas lead to six gr~c elcroonts:

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

1. Set graphic rrode - z.m£ 2



2. '1\lrn cursor off - Q.'D"F 0
3. Set absolute ooordinate m::xie - 1'100£ 4
4. r-bve to the coordinates sped ficrl - MJJE (coer. I coer . 1 <ooor. >)
5. Set alfila m:x:ie - MD£ l

The Point 1\bsolutc algoritlln might be •

l. Set graphic rrode - l-o:>E 2


2. '!'urn cursor off - CNJFF 0
3. Set absolute coordinate rrode - 1'100£ 4
4. l1olle to the coordinates spec:i fi ed - MJJE (coer. 1 coor. 1 <coor . >)
5. '1\u:n cursor on - CNJfl' 1
6. '1\u:n cursor off - CNJFF 0
7. Set alpha node - M:DE l

'lhe Draw Absolute algoriilin might be

1. Set gra{Xric m:x:ie - 1-o:>E 2


2. '1\lrn cursor on - CNlFF 1
il 3. Set absolute ccardi.nate nu de - MDE 4
ll
I~ 4 • Move to the coerdinates specified - l-oJE (ooor. 1 coer. 1 <ooor. >)
II
5. '1\lrn cursor off - CN)FF 0
6. Set alpha rrode - ra>E l

a:x1 the Text .Absolute algorithn might be

1. Set graphic JtPde - M.DE 2


2. '1\u:n cursor off - CN:lFF 0
3. SeL absolute coordinate rrode - t-roE 4
4. l>bve to location - M:NE (ooor. 1 ooor. 1 <ooor . >)
5• Set ctlpha rrode - l-DDE 1
6. '1\lrn cursor on - CN)FF 1
7. Print characters
8. '1\lrn cursor off - CN:lFF 0

'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

1. Is the devi~ in graphic rrode? lf yes - CQ'lt..lnue I tf no - sci CJr•lrflic


node - r-a:£ 2 •
2. Is the cursor off? If yes - CQ'ltinue, i f no - tum cursor off - c:N:E'F 0.
3. Is the device in absolute coordinate node? If yes - CXlntinue, if no -
set absolute coordinate node - ln:E 4.
4. ~bve to the coordinate spocified - ~OVE (coor. , coor. , <coor . >) •
5. 'l\J.rn cursor on - OOOFF 1

'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

Initialize the ~vice

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

Reading the CUrsor Positi.oo


Activat.i.ng an Analog Tablet •
Activating a Jat Stick
llctivating a Light Pen
Acti.vatin<J Cootrol Dials
1\ct..ivating f\lnctioo Switches

Others can be &dded as is required or a general graphic input elerrenL can be


developed. As an ex.anple, the algorithm for activating an analog table with
local tracking might be

~~ l. Set gratillcs rr00e - tOE 2


I~ 2. Set absolute coordinate node - KX>E 4
I

3. set local tracking - t-IDE 9


4. lead the cursor positioo
5. Read any table switch posit.i.a\s
6. Turn off local tracking -raE 10
7. Set a4ila node - MX1E 1

'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

It is necessary to carplete our discusstoo of graphic syste.rrs by considering


the various spaces or coordinate systems \o.tlich are o f interest to both the user
and the system architect.
1here are three spaces that are of interest-user sp.x:c, canonical space,
am device spaoe. user space represents the coordinates or uruts in \o.bich the
application is perfonmd, cancniCAl space is a pseWo space used to obtain
device , am device space represents the coordi.n.atc system in \o.hlch
the graphics device nust be <Oiressed, e.g., raster points or units for CRI'
devices, inches or oentirreters for plotters, etc. 'lhese are illustrated in
Fig. A-2.
'Ihe cxu::ept of a caoonical or pseudo space is of interest. By using a
standard cananical or pseudo space for all graphic devices, device-independent
CXJ•IPU'reR GAAPHICS SFlW\RE 195

graphic software CM rrore eas1.ly be


obtained. In pa.rtio1lar, the picture is
first trans!Onred fran user spoet or m-
ordinates to the st.andard canonical space
I and then transfoDOOd fran the canonical
0 1'--- ---- --~ space to the appropriate dPvioe space.
A s.i.!Tt>le concept for the canonical
space assures lhat the addressable area
is the unit square in the first quadrant;
• I ' - ----:-
0 I n User space
6 211
i.e., the addr~ssable area of the psa;ido
graphic device represenl-ei by the caocn-
ical ~ is 0 -< Xa-
< 1 . 0, 0 -< ya-
< 1.0 •
..r -
Although this aF{Cars to limit thc p1.cture
to a square format, this is not necessar-
ily true. 'lhe 1.0 x 1.0 square fo.mat is
assl..llled for · arrong graphics
devices and is predicated on the basis
that many plotters and uost storage bJbc
CRr grafhics devices have a square ad-
----- dressable area . tiJWever, addressable and
viewable areas are not necessarily iden-
tiCA'll. Frequently the vielriable area is a
rectangle; e . g. , rrost storage tube CRl'
0'---- - - - 1 graprics devices have a viewable area that
0 J b Canon•c al ip.acc
is approx:i.Jrately 0.8 of the aMressable

(\. )') 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

1024 figures ....ould occur; i.e., a circle "Ould


(say)
be seen as an ellipse. 'lb.i.s is , of oourse,
Figure A-2 Grat:hlc spaces unaccepta.ble for gearctric oc::rtpUter ~ ·
APPENDIX B

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

A zero matJ-i.z is one in which every e 1errent is zero. i<lcr.titJ.! rnat.t~:..X An


is one in \lohich every ela:ent is zero, with the exceptioo of the diatplal
elerents , l.o.hich are all U'l.ity. An exanple of a 3 x 3 identity rutri.Jc is :
1 0 0
0 l 0
0 0 1
'l'No matrices are qual only when each e1eroont in one is equal to the corresp :n:l-
ing elerent in the other; that is, they r.ust be i..de.ntical.

B-2 AooJTIOO AND SuBTRACTICtf

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

B-3 t'u..TI PL ICATION

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

"'1 3- r1 21 - l+ 9 2 + u, = -10 141


4 2 L) 4j 4 + 6 8+ 8 10 16 1
1 1 1 + 3 2 + 4 4 6
6 4
l3 2.,.
G. 12 12 + 16J
+ 6 6 + 8
18 28
L 9 14_
The operatioo of matrix nultiphcation is ~ o::rrm.rt:ative. 'Ihat is, 1.n

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

l a31 a32 a33J

~1 a12 ~3

21 ~2
4 8
23
a31 a32 a33 !

• ~ (~2a33- ~3a32) - a12 ra2la33 - a2~3l)


+ al3 (a211132 - ~2a31 )
nus gives a single m.rerical value for the dete.t:mmant. Q::nsider the evall2ttm
of
3 9 4

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

B-5 INVERSE OF A SGt..IARE f'1ATRI X

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

The algorit:l"cns presented m t.l'ri.s sect.ron are based on the rmtheratica!


d' SC.JSsion presented in the l:x:xly of the te."«. 'they are given as subprogrc'li"S,
...Titten l.1l Oartrouth SJ.Xth Eiht.J.on Bi\SIC. They can easily be converted to other
la."'9".1a9es . The algont:h:':'.s are rot intended to be tlY.. rrost efflcient posslhle.
'!h..~ are mtended to be in.st:.n.r=tive. Eac.'ll of the transfomation a:go:·ithlts
asst.meS that the data base is presented in ord:.nary coordinates. 'llle algorithm
then develops the necessary hcn:x;eneous coordinate representat:.J.cn, performs the
transfot:m:iticnl and returns to ordinary cxx:>rdinates. The aw-1re.nt ineffic~c..-.cy
associated "'ith reconversion to ordina.ty coordinates has boon deliberately
acx::epted since experience indicates that users norrrally W:J.ll perfonn or.e or o.o
transfon:ations, display tr.e result, \oohl.ch requires ordir.ary coord.lnatcs , and
then c::ontwoie . If a&H tior.al efficiency is required the reader can either rrc:xti£y
the algoritnr.s or develop his or her own based on t:re theory presented in the
body of the text;.

An algcnth:n for a."\ arbitrary translation uti Hzing han::qU'lE.'OUS coordl.J'lates


is g!.ven bclo..~ il.S a BASIC !a.n3ua9e s...:bprogra:'n. It is based on sec. 2-15.
2DTRANS

100 SUB" 2DTRAl5" : P, X( ) , Y() ,M, fJ ' 2-D TRANSLATION


110 ' P:Ntl-:BER Of X,Y- PAIRS
120 ' X( ):ARRAY CONTAINit\G X-ax:JRDitU.'TES
130 • Y() : ARRAY CONTAlNir\G Y-COORDir~TES
l 40 'M:X TRANSLATION FACTOR
150 ' N:. Y TRANSLATION FACI'OR
160 DIM U(100 , 3) , V(100,3) I 100 POSITICN VFrl'ORS
170 ~~T U=ZER(P , 3) • R£DIMFt:SION ~v FI LL WI1li ZC.Ros
180 MAT V:ZER(P , 3)
190 FOR 1:1 TO P ISET UF H(l.l(Xjfljf:OOS
200 LET U(l , 1}:X(I) • POSITION VECTORS
210 LET U(l , 2):Y(I)
220 LET U(l , 3)=1
230 NE:.XT I
240 MAT T:ZER(3 , 3) I REDIM.ElJSION T ~ILL ~lTH ZEROS
250 LET T(1 , 1):T(2 ,2}:T(3. 3)=1 I PLACE 1 I s ON LIA OF 'I MATH IX
260 LET T(3 , 1):M ' SET X TRANSLATION F/,CTOH
270 LET T(3 , 2):N 'SET Y TRANSLATIO!I FACTOR
280 ~1AT
V:U•T 'CALC, TRANSLAT~ POSITION VECTORS
290 FOR I=1 TO P ' RETURN TO PHYSICAL CWR .
300 LET X(I):V{l , 1)
310 LET Y(l):V(I , 2)
320 NEXT 1
330 SUBEND

A SC'Il ing algoritm is given bela;o~ as a 81\SIC language subprogram. The


algorittm based on Sees . 2-11 and 2-15 provides both l ocal and overall scaling.
'lbus , distortion of a shape can be aa:aupl..ished. It util izcs l"otogetle()US coordi-
nates.

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

290 II.AT O=S*T 'CALC. TRANSFOJito1ED POltn'S


300 FOR 1:1 TO P 'CALC. PHYSICAL ODOR.
310 ~f X(I):Q(l , 1)/0(1 . 3)
320 Ltl ¥(I):Q( I, 2)/Q(I,3)
330 NEXT I
]llO SUBEND

C-3 A Tlo.O-DII'a4SIONAL Pm..ECTION Ai..GOOJ~

A siJlt>le algorithn to reflect al:x:lut either the x- or y-axis is given below


as a BASIC language subprogram. 'Ihis routine depends on tro analysis of Sec. 2-5
and uses l'xxtogeneous coordinates. This operation is also frequently referred
to as mirror itrage.

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

170 HAT Q:ZER(P,3)


180 FOR I : 1 TO P 1SET UP l0100ENEOUS

190 LET S(I, 1)=X(I) ' POSITION VECTORS


200 LET S( I,2):Y(I)
210 LET S(I,3):1
220 ~'EXT I
II
230 MAT T:ZER(3 ,3) ' REDIMENSION T FlU. Wlnt ZEROS
II
2ll0 IF H:2 THEN 280 1
SET UP TRANSFORf'1ATION 11ATRIX
250 LET T( l , 1):T(3. 3)=1
I! 260 LET 1(2,2):-1
270 GO TO 300
280 LET T(2 , 2):T(3, 3)=1
290 LET 1( 1,1) : - 1
300 MAT O=S*T ' CALC. TRANSFOIIMED POINTS
310 FOR I:1 TOP 'CALC. PHYSICAL COOR.
320 LET X(I):Q( I , 1)
330 LET Y( l):Q(I , 2)
]110 NEXT I
350 SUBEND

C-4 A G€NEAAL. TclJNENSIOOAL RoTATION ~11H'1

An algont:hn for o.o-dirnensiooal rotation arout an arbitrary point is g1ven


below as a Bol\SIC langu.'lge subroutine. It utilizes the analysis of Sec. 2-16 .
2DROT
100 SUB"2DROT" :P, X() ,Y() ,T1,H,N '2-D ROTATION
110 ' P:NUMBER OF X,Y-PAlRS
120 ' X( ):ARRAY CONTAINING X-COOP.DINATFS
130 'Y():ARRAY CONTAINING Y-COORDINATES
140 'T1:ROTATl0N ANGLE IN D£n11EES
150 ' H:X TRANSLATION FACTOR
160 ' N:Y TRANSLATION fACTOR
170 DIM S( 100 , 3) ,0(100,3) I 100 POSITION VEX:TORS

180 HAT S:ZER(P, 3) 'REDIMENSION S&O FILL


190 HAT Q:ZER(P , 3) 'WITH ZEROS
200 FOR I=1 TO P 'SET UP H~OGfliEOUS
210 LET S( I, 1):X(I) I POSITIOt; VECTORS
220 LET S(l , 2):Y(l)
230 LET S(l, 3):1
2110 NEXT I
250 LET T2:T1/57. 2957795 'CONVERT TO RADIANS
260 HAT T:ZER (3, 3) 'REDD1ENSION T FILL Wlnf ZEROS
270 LET T(l, 1):T(2,2): COS(T2) 'SET TRANSFORMATION MATRIX
280 LET T(1,2):SIN(T2)
290 LET T(2, 1 ) : ~IN(T2)
300 LET T(3, 1):-M• (COS{T2)-1 )+N•SIN(T2)
310 LET T(3 ,2):-M•SIN( T2)-N•( COS(T2) -1 )
320 LET T(3, 3):1
330 HAT Q:S•T ' CALC. TRANSFORMED POINTS
340 FOR 1:1 TO P •CALC . PttYSICAL COC>R.
350 LET X(l):Q(I, 1)
360 LET Y(l) :Q(I, 2)
370 NEXT I
380 SUBEND

C-5 A T~-Dit-£NS ICJW. Sc.ALir«; AL.~Infl


An alC}:)ritnn for t.hree-di.n'I!!TI.Sional scaling is given as a BASIC language
sui~"'gtam. It is based on Eq. (3-4).
3DSCALE

100 SUB11 3DSCALE" :P, X() ,Y() ,Z(},A,E,J,S '3-D SCALE


110 ' P:NUMBER OF X,Y, Z- TRIPLETS
120 ' X():ARRAY CONTAINING X-COORDINATE
130 'Y():ARRAY CONTAINING ¥-COORDINATE
140 ' Z():ARRAY CONTAINING Z-COORDlNATE
150 ' A:X STRETCHING FACTOR A)1 STRETCHES, A<l C~'TRACfS
160 ' E:Y STRETCHING FACTOR E>1 STRETCHES, E<l CONTRACTS
l70 1 J:Z STRETCHl t\G fACTOR J>l STRETCHES, J<l CONTRACTS

180 1
S:OVERALL SCALit:C S> 1 ENLARGES S<1 REDUCES
190 DIM U( 100, 4) ,V( 100 ,4 ) 1 100 POSITION VECTORS

200 ~tAT U:ZER(P 11) 'REDIMENSION U&V Fill WITH ZEROS


210 ~!AT V:ZER(P, 11 )
220 FOR I: 1 TO P ' SET UP HCMXJENEOUS
230 LET U(I , l):X(I ) ' POSITION VEC10RS
240 LET U(I, 2):Y(I)
250 LET U(l, 3):Z(l)
260 LET U(I , 4): 1
270 NEXT I
280 HAT T:ZER( 4, 11) •REDI.HENSION T FlU. WITH ZEROS
290 lET T( 1, 1) :A ' SET X STRETCHING FACTOR
300 LET T(2, 2)=E •SET Y STRETCHING FACTOR
204 t-IA'mEMI\TICAL ~ E'OR CO>IP\Il'ER GRAPHICS

310 LET T(3 , 3)=J •SET Z STRETCHING FACTOR


320 LET T(4 , 4):1/S ' SET OVERALL STRETCHll~ FACTOR
330 NAT V:U1 T ' CALC . TRANSFORMED POINTS
340 FOR I: 1 TC P ' CALC. PHYSICAL ODOR .
350 LET X(I):V(I , 1)/V(I , 4)
360 LET Y(I ):V(l, 2)/V( I , 4)
370 LET Z(I):V(I , 3)/V( I , 4)
380 tiEXT I
390 st.'BEND •

C-6 ~ Al..GORITif-1 FOO THREE-DIMENSIONAL lbTATION ABour TI£ x-Ax is

"'t.e algorithm given belo..1 as a BASIC language subprogram alla..'S rotatjoo


of the position vectors of an object a1x>ut the x-axis . I t utilizes tatogenecus

coordinates.

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

C-7 ~ AI..GORITlf-t FOO T~EE Dit>ENSIOOAL RoTATION Aaoor n£ v-Axis

'llle algorittln given belo..1 as a MSIC language subprogxam alla..'S rotation


of the position vectors of an object alx>ut the y-ax.u;. It utilizes taJcxJeneons
coordinat:£!s.
3DYPOT

tOO SUB" 3DYROTW:P,X(} , Y(),Z(),T1 '3- D ROTATIC~ AEOui Y-hXIS


110 'P:NUMBER OF X,Y , Z-TRIF~Jr.S
120 ' X( )::ARRAY CONTAINING X-<XX>RDWATES
130 ' Y():ARRAY CGN'fAINitiG Y-COORDHJATES
140 ' Z():ARRAY C0~7AINING Z-COORDINATES
150 'T1::ROTATIOt\ At.CLE IN DECREES
160 DIM U(100 , 4),V{ 100 , 4) ·100 FOSITICN VEC"IORS
110 ~!AT U:ZER(P , 4) ' REDDiENSION U&V FlU. WITH ZEROS
180 ~!AT V:ZER{ P, 4)
190 FOR I: 1 TO p I SET UP HCt-1CKiE.NFDUS
200 LE1 U( I , 1) :X( I) I POSITICtl Vf.CTCRS
21C LET U{I ,2):Y(I)
220 LET U(I , 3):Z(I)
230 LET U(I , 4): 1
21.;0 NEXT 1
250 LET T2:T1157 . 2957795 'CONVERT TO RADIANS
260 MAT T::ZER(4 , 4) ' REDIMENSION T FILL WITH ZEROS
270 LET T(1, 1}::T(3,3):COS(T2)
280 LET T(3, 1}:S!N(T2)
290 Lt.'T T( 1, 3) :-T(3, 1)
3CO LET T(2, 2)=T(4. 4):1
310 HAT V::U•T ' CALC. TRAl\SFORHED FOINTS
320 FOR 1::1 TOP ' CALC. PHYSICAL COOR.
330 LET X{I)::V(I, 1)
340 LET Y{I):V(l ,2)
350 LE: Z(I):V(I , 3)
360 NEXT I
370 SUBENO

C-8 ~ Al..GoR Jnt1 FOR Tt-REE DWENSIOOAL RorATIOO ABouT n£ Z-Axl s

The algorittln given below as a BASIC language sut:program p.rovides far three-
diJrensional rotation about the z-axis .

3DZROT

100 SUB"3DZHCT":P , X(),Y() , Z() ,T1 '3- D ROTATION AB0111' Z- AXIS


110 'P:NUMB~n OF X, Y, Z- TRIPLETS
120 ' X{)=ARRAY C(»lTAINI NG X-COORDINATES
130 'Y():ARRAY CONTAlttH.'G Y- COORDDJATES
140 1 Z():ARRAY OONTAINih'G Z- OOORDltlATES

150 'Tl:ROTATICN ANGLE IN Dt::GREES


160 DIM U(100, q} , V(100 , 4) ' 100 POSITION VECTORS
170 HAT U:ZER(P, II) ' RED~SION U&V FILL WITH ZEROS
180 11.AT V:ZER(P, 4)
190 FOR I: 1 TO P ' SET UP HOKCKifllEDUS
200 LET U(l , l):X(l) 1 POSrTION VECTORS

210 LET U(I , 2)=Y(l)


220 LET U(l , 3)=Z(I)
230 LET U(I , 4):1
2qO UEXT I
250 LET T2:1 1/57.2957795 ' CONVERT TO RADIANS
260 11AT T:ZER( 4, 4) 1 REDD'.SiSION T FILL WITH ZEAOS
270 LET T(1 , 1):T(2, 2):COS(T2)
280 1.1-.'T T( 1, t'):-SW(T2)
290 LET T(2 , 1):-T{l , 2)
3CO LET T(3 , 3):T(~ . ~):1
310 ~~T V:U•T 'CALC. TRANSfORMED POitrrs
320 f"Ok I: 1 TO P ' CALC. PHYSICAL COOn .
330 LET X(l):V(I , 1}
3~0 LET Y(I):V(I,2)
350 LET Z(l)=V(I , 3)
360 f,E.XT I
37C SUBEND

C-9 ~ AlGCRint1 FOR THREE-DU'£NS IOOA1.. R£fLECTlct4S

An algorithm which will perfonn three-dJ'iJTellSi.onal reflectialS th.rough the


ooordi.nate plat'.es ~,
xz, or yz is given bel~ as a BASIC language sutpr:ogxam.
Reflections about other planes can be cbtained by a cacb.inatioo of rotation and
reflection .
I~
3DREFLT

100 SUb"3DREFLr' :P, X(} , Y() ,Z{) ,N ' 3~0 REFLECTIOtiS


110 'P:NUMBER OF X,Y , Z-TRIPLETS
120 I X( ):ARRAY CONTllillt:G X-COORDINATES

130 'Y():ARRAY CONTAlfnNG Y-COORDINATES


1110 'Z( ):ARRAY CONTAHIING Z-COOf!DINATES
150 I N:REFLECTION CODE: 1:)[{-Pl.ANE, 2:Yl-PLAflE, 3=XZ-PLA~t:
160 DIM U(100 ,4}, V( 100, 4} ·100 POSITION VECTORS
170 f"IAT U:ZER( P, 11) ' REDIMENSION U&V FlU. WITH ZEROS
180 ~~T V:Z~R(P , ~)
190 FOR 1:1 TO p ISET UP fD'.OOEl~S
I 20C LET U(l , 1 ) :X( I} 1 POSITION VECTORS
II
I
210 LEi U(I , 2):Y(l)
I 220 LET U(l , 3):Z(I)
230 LET U(I ,11):1
' 240
250
flEXT 1
~.AT T:ZER( 4 , L) ' REDIMENSION T FILL WI'Ill ZEROS
260 If N:2 THEN 310 ' SET UP TRANSfORMATION ~lATRIX
270 If N=3 THEN 3~0
280 LET T(1 . 1 ):T(2 , 2):T(~ , 4):1
290 ~i T{3 ,3):-l
300 GO TO 360
310 LET T (~ . 4):T{3 , 3):T(2 , 2) :!
320 LET T{1 , 1)=-1
330 GO TO 360
340 LET T{l, 1):T(3,3)=T(4 , 4):1
350 LET !(2 ,2) =-1
360 f".A T V: U•T 1CALC , TRANSFOR.'IED POHITS
310 FOR 1:1 TO P •CALC. PHYSICAL COOR.
38C LET X(I):V(I , 1)
390 LET Y{I):V(I , 2)
~00 LET Z(l):V(I,3)
~ 11 UEXT 1
~20 SUBEND
DATA 81& f.'.ANIPUI.ATIQl ALOJRITI!I-ts 207

c-10 AA h.GORJTK'l FOO TlffE-Dit-ENSI~AL. TRANSlATIOO

An algorit:hn for translation in three dinlmsi.al!> is given below as a BASIC


l anguage ~rogram . It mlkes usc of~ coordinates.

100 SUB" 3DTRANS" :P , X(),Y(),Z() , L ,l'I,N '3-D TRANSUTJQN


110 ' P:NUMBER Of X, Y, Z- TRlPLeiS
120 ' X():ARRAY CO~TAIN!NG X-COORDINATES
130 I Y():ARRAY CONTAINING Y-COORDINATES
140 •Z{):ARRAY CONTAHUNG Z-COORDINATFS
150 ' L.:X TRANSLATION FACTOR
160 ' N:Y TRANSLATION FACTOR
170 I N:Z TRAl&SLATION f'ACl'OR
180 DIM U( 1 00 , 4) , V(100 , ~) ' 100 POSITION VECTORS
190 MAT U:ZER(P , 4) • RFDINENSION U&V f'ILL WITii ZEROS
200 MAT V: ZER(P , 4)
2 10 FOR 1= 1 TO P 'SET UP HCI'lOOfllf..OUS
220 LET U(l , l):X(I) 'POSITIOt~ VECTORS
230 LET U(l , 2):Y(I)
240 LET U(I ,3)=Z(I)
250 LET U(I , ~)=1
260 NEXT I
270 HAT T:ZER(4 , 4) I REDD-IENSION T FlU. WITH ZEROS
280 LET- T{ ' , 1):!(2, 2):1 • PLACE 1•s ON orAG . OF T-MATRIX
290 LET T{3,3)=T(4 , 4)=1
300 LETT(li,1)=L 'SET X TRANSLATION FACTOR
310 LET T(4,2):H ' SET Y TRAMSLATIOt~ FACTOR
320 LET T(4 , 3):N 'SET Z TRAUSLATION FACTOR
330 HAT V: U*T 'CALC. TRAt~ POSITION VECTORS
3110 FOR I: 1 TO P ' CALC. PHYSICAL COOR.
350 LET X(I):V(I , 1)
360 LE~Y(l):V{l , 2)
370 LET Z(l):V(l , 3)
380 NEXT I
390 SUBEND

C-11 /'Jt4 Al.GORJlH"t FOO lt-REE-Dit-e4SIONAL ~TAT I ~ Ainrr Pt~v ARBI'TAARY Axis IN
SPACE

An algori t:hn which will produce a ional rotat im about an


arbi trary axis in SP-loe is given below as a BASIC language subprogram. It is
based on Eqs. (3-17) ctnd (3-18).

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

II An ll9Qritl"rl ft;_,r a s.wq::le c~.J.c proJectl.oo c.nto a ~ro plane per-


I
II IY-"ldlcular w MY of the tl'.ree o~nal axes is g1~ l:x:lo.~ e.s a BASIC la.'lqllage
S'~Og't'al"'.

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

C-13 A DIMETRIC PROJECTIVE AlGORITif'l

An algoritlm which i.nplercents the specific dirretric transfornatioo given


in Eq. (3-26) and ass\11\ing projection ooto the z = 0 plane is giwn belo.~ as a
BASIC language subp.rogmrn.
Dlt1E1RIC
100 SUB"Dlt-IETRIC": P, X(), Y() ,Z() ' Dlt-IF1'RIC Pnc)JFCTION
110 ' P:NUMBER Of X, Y,Z-TRIPLETS
120 ' X():ARRAY ~iAINI~G X-COORDINATES
130 ' Y():ARRAY CONTAINING Y-COORDllJATES
140 ' Z():ARRAY CONTAINING Z-COOPD~ATES
150 DIH U( 100 ,4) ,V(100,4) ' 100 POSITIO~ VECTORS
160 MAT U:ZER(P , 4) ' REDIY.EriSION UbV FILL WITH ZFROS
170 MAT V:ZER(P , 4)
180 FOR I= 1 TO P ' SET UP OOMOOENIDUS
190 LET U(I,l):X(I) 'POSITION VECTORS
200 LET U(l , 2):Y(l)
210 LET U(l , 3):Z(I)
220 LET U(l ,4)= 1
230 flEXT I
240 MAT T:ZER( 4, 4) 'REDIMENSION T FILL WIW ZEfiOS
250 LET T(1,1):0.925820 ' SET UP TRA NSFOR~ATION ~~TRIX
260 LET T(1 ,2):0.133631
270 LET T(2 ,3): 0.353553
280 LET T(1,3):-0. 353553
290 LET T(2 ,2):0.935414
300 LET T(3,1):0. 37796Q
310 LET T() ,?):-0. 327327
320 LET T(3 , 3):0.866025
330 LET T(!l ,4):1
340 t'AT V:U•T ' CALC. TRAfJSFORfiATlON
350 FOR 1:1 TOP ' CALC. PPYSlCAL ODOR.
360 LET X(I):V(l ,1 )
370 LET Y(I):V(l,2)
380 LET Z(I):V(I , 3)
390 NEXT I
400 CALL "PROJ": P,X() ,Y(),Z() ,3 'PROJECT ON TO Z=O PLA~f
410 SUEEIJD
C-14 fJ/~ lsa-£TR1C PRoJECTIVE /\.GOOint1

An algonthn \ofu.ch ir.ple-ents the i sa etric tranSfon ation disc:ussec! in


Sec. 3-!.o (1 .e., c.q. (3-26) wit.'"t e =35.264° CiOO ~ = 45°] aro assu-.J.ng proJect:..ioo
on the z • 0 plane is given bel0oo1 as a BASIC 1~ sd:program.

1CC SUE"lSOt'..ET":F,X(),Y(),Z() ' ~!C PPJJex:Timl


110 'P:t~EP OF X,Y,Z-!RIPL~
120 ' X():APPAY COh'TAII~I.ll; X.COOPDll\A!ES
130 ' 't():APPAY CC:;tAINn~ Y-cooPDINATES
11;0 ' Z{) :t.PP.AY CONTAINL~ Z...COOPCI~iATES
150 DIY U(100 ,u ) ,V(100 ,JJ ) ' 100 POSITIOt: VECTC?S
160 f'I.AT U:ZE.Il(P,1.) ' fEDI'"ENSIOt: ~V Fn.L ~ITr ZEPOS
170 f'I.AT V:ZEP(P,~)
160 f"'F I= 1 TO P •SET HJKXjE!."EOUS
(p)
190 LETU(I ,l ):X(l) ' POSITICN VECTOPS
It 200 LET U(I ,2): Y(I)
210 LET U(I ,3): Z(I)
220 LET U(I ,~ } =1
230 t,"EX7 I
zuo ~.AT T:ZEP(4 , U) ' FED!~!:~ T FILL ~!TH ZEPCS
250 LET 1(1 , 1) : 7(3,1): 0.707107 ' SE! L? !PA~~fCP~ATICS ~~!PIX
260 LET 7(1,2):0.4082~8
210 LET T(? ,2):-C. C82~8
280 LET 1(1,3): -0.577353
290 LE: !(!, 3):0. 577353
300 LET 1(2 , 2):0.816~97
310 LE7 !(2,3)=0.577345
320 LET T(1.,4):1
330 I"J.T V: U1 T ' CAU:: . TRAl~FQFI.#.ATIO~
340 FOR I: 1 TO P 'CAU::. PHYSICAL CXJP .
350 LET X(I):V(I ,1 )
360 LET Y(1):V(I ,2)
370 LET Z{I):V(I,3)
380 NEXT I
390 CALL "PPOJ":P,X() ,'t() ,Z () , 3 'PRCJECT Q:rG Z: O PtA1:E
1100 SIPI....£ND

C-15 Pi~ fu;oo tnf'l FOO PeRsPECTtVE TRANs~ATlOOS

An alqontlrl ~o.hl.ch will generate a ~ perspective V1ewi 1s given b?lcy

as a Bl-SIC lan<Jua9e subpro<JX&.t.

l UJ SUC." FC.r~FEC": f 1 ,X( J , Y() , Z() , F, C, F. • fE.f.SPECT 1\'E. !f..:J...Fvf.YJ.UC!i


11 C: ' P 1:MJ.'o.!:Ef' Vf X, Y, Z- :?IPLETS
1eO 'Y (): A"FA Y CG.,1/.l1.lt.G >:- CCA..FIL:tJ.rt..S
130 'Y():ARRAY-CO~TAltcll\G Y-COOfiDINATES
140 ' Z():ARRAY CO~TAI~1NG Z-COO~Dl~ATES
150 1
P:X- AXIS POINT (;f PROJt.CTlOI•
160 'C:Y-AXIS f'Ol~T Of PROJECTIOf,
170 ' R:Z-AXIS POINT OF PROJECT!~
180 DIH U( 100,4),V(100,4) I 100 f'CSITIOJ'oc VE.C'I\JhS
190 MAT U:ZER(P1, 4) I REDlMEI..SlU. ~ v FlU. ~11li ZE.hGS
200 MAT V:ZER(P1 , 4)
210 FOR 1:1 1U P1 ' SET UP IUIC(jEM:OUS2 10
220 LET U( l ,1):X(l) I POSITION VEX:TORS
230 Lt.T U(l , 2):Y(l)
240 LET U(l, 3):Z(l)
250 LiT 0(1,4):1
260 HI:.XT I
270 NAT-T:ZER( 4,11) REI.ilMOOlON T- FILL ~ITh ZEhOS
I

260 LET T( 1, 1):T(2,2):1 I PL.ACf. 1' s 0~ D lAG. Gf T I'IATfHX


290 LeT 1(3, 3):T(4, 4):1
300 Ll:.-r T(1,4): P ' SET X PROJbCTiotJ Pvl~~
310 U-1' T( 2,4 ):0 I SE.T y Pf\GJECUON POltlf
320 LET T(3,4):fi I SET z PftbJECTION PU 11.1
330 MAT V=U•T ' CALC . TfiANSfORMA1'lON
340 FOR I:1 10 Pl ' CALC. PHYSICAL COOn.
350 Lli X(l}:V(1 ,1 )/V(l ,4)
360 LI:.T Y(l):V(I ,2)/V(l , 4)
370 LiT Z(l):V(I,3)/V(I , 4)
380 NeXT 1
390 SUbE.t<U

C-16 Ttte-DWENSJONAL RECONSTROCTJON Au~rm'IS

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

to reconstruct t.~ transformation used to obtain a perspective


An algoritlln
projection fran the )o1or..n location of six p::>i.nts in the I=bYsical and projectiO'\
spaces is given below as a BASIC language subpt'Ogram. It is based on F.q . (J- 50)
in the oor.nalized fonn.

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

C-17 A STEREO ~Illfl

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

100 SUB" STERfl>" : P1 , X( ) , Y( ) , 1 () , K, E' , A( , ) , B( , )


110 ' P1:tlUM!ER CF POINTS USED 10 DEFitiE OBJECT
120 ' X0=ARRAY OOtri'AINI~G X-COORDD;ATES
130 ' Y():ARRAY OOtri'AI NING Y-GOOPDINATES
140 ' Z( ):ARPAY rotri'AINING Z-cODRDINATES
150 ' DIM X(Pl) , Y{P l), Z(Pl) It-; t-'Alt\ PflOORAt-1
160 ' K=FOCAL LENGTH OF STFRW VJE'fo'ER
170 ' E:DISTAt\CE EETWEEti EYES Of OBSERVE? (RELATIVE' 'IO OUTPUT g:ALE)
180 ' A( , ):RESULTUlJ X1 -, Y1 -COORDINATES FOR LEFT EYF
190 ' DIM A(P1, 2) IN MAIN PROGRAt-1
200 ' B( , ):RESULTING X 1 -,Y 1 -COO~DINATES FOR RIGHT EYE
210 'DIN B(P1 ,2) IN t'.Alll PROGf!AtJ
220 Dlfo! U( 100, 4)
230 DUI l( 100 , b)
214 ~CAL ElEMENTS FOR a:t-1Plll'ER GRAPHICS

240 DIM R(100 ,4)


250 DIH P(100 ,4)
260 DIM 0(100 , 4)
no FOR I:l TO Pl ' SET UP ~"<XJENEOUS
280 LET U(I ,l):X(I) ' POSITION VECTORS
290 LfT U(l , 2):Y(I)
300 LET U(I , 3): Z(I)
310 LET U(I , 4): 1
320 t~XT I
330 ~AT T:ZER(~ , 4) 'CREATE LEFT- EYE PEPSPECIIVE
340 LET T( 1, 1):T(2,2):T(3, 3):T(4 , 4):1
350 LET !(3 ,4 )=- 1/K
360 LET T(4 , 1):K/20
370 I".AT L=U1 T
380 LET !(4 ,1 ):-K/20 'CREATE PICHT-EYE PERSPECTIVE
390 1
fo'.AT R:U T
400 LET X2:X6=0 •
410 LET X3=X7=99999
420 FOR 1:1 TO P1
430 LET P(I,4):0(1 ,4 ): 1 ' NORMALIZE RESULTS
440 LET P(I,l):R(I ,1 )/R(I ,4)
450 LfT P(I , 2):R(I , 2)/R(I ,4 )
46o LET C(l , 1):L(I, 1)/L(I, 4)
470 Le-r 0(1 , 2):L(I , 2)/L(I , 4)
480 LET X1:P(I , 1) ' FIND X1 t-'AX/MIN FOR LIR EYES
490 LET X5=0(I ,1 )
500 IF X1>X3 THEN 520
510 LET X3:X1
520 IF X1<X2 T~F.N 540
530 LET X2: Xl
540 IF X5>X7 THEN 560
550 LET X7=X5
560 IF X5<X6 THEN 580
570 LET X6:X5
580 NEXT I
590 LET O:(X6+X7)/2- (X3+X2)/2 ' F~D EYE SEPARATION DISTA~CE
600 LET L:D+(E-D)/2
610 t-'.AT T: ZER(ll , 4) 'TRANSLATE PICHT- EYE VIEW
620 LET T(1 ,1 ):T(2 ,2):T(3 ,!)=T(4 , 4):1
630 LET T(4 ,1 )=L
640 ti.AT R:P1 T
650 LET 1(4 ,1 ):- L 'TRANSLATE LEFT-EYE VIEW
660 t-'.AT L=01 T
670 MAT A=ZF.R(P1,2)
680 MAT S:ZER(P1 , 2)
690 FOR 1: 1 TO P1 ' SET UP RETURN ~ATRIX
700 LET A(1 ,1 )=L(I ,1 )
710 LET A(I ,2): L(I , 2)
720 LET B( I, 1):R(I , 1)
730 LET E(l ,2):R(I , 2)
740 ~EXT 1
750 SUE!EtJD

C-18 ~ Al.GOO lnt\ FOR A CbwARN"ETRIC CIRCLE

'Ille Al.goritnn given below as a BASIC l..anguage subprogram generates a circle


based on a nonpa.rairetric representatioo. It is based on the discussi oo of Sec.
4-5. The Algorithm 1.n the next section is reo:xntended for circle generation .
t-.PCIRCU

100 SUB"hPCIRCLe" : H, K, R, t-. , X() , Y() ' f,(ltiPARAMITRIC CHiCLE


110 ' H, K:X&Y COOR . OF CEIITER
120 ' R: RADI US OF CIRCLE
130 ' t-.: NlR-lbER Of POIf\ T!:> L'£.SII1ED
140 ' X( ):ARitt.Y COUTAit>lhG TI-E X-cooROIMTES Cf CIRCU:
145 ' Y( ):ARRAY CONTAlhlt.'G lliE Y-OX)RDlkATFS OF ClkCLE
150 ' NOTE :t\ HliST BE DIVISIBLE BY EIGHT . If NOT PPOGkAM WILL
160 ' USE ~EXT HIGHEJ\ NUMBER Dl VISIBLE BY EIGhT
170 LE.T A::lloT(~/8) ' DE1'E.I<iHt.E If DIVISIBLE BY EIGhT
180 If A:N/8 T~EN 2 10
190 U.T t. 1::(A+1 ) 1 8 ' SET h1 DIVISIBLE BY EIGPI
200 GO TU 230
210 LET N1::N
230 MAT X: ZER(t-. 1+1 )
240 HAT Y: ZER(~ 1+1 )
250 u..,- D:R1 ( 1-1 /SCR(2))/(N1/8) ' CALC. INCREl'IF.NT
260 LiT X( l) : R ' CALC. INI1IAL POIN1
270 LET Y(l ):O
280 FOR 1:1 TO N1 ' CALC . POINTS AROUND ORIGiN
290 I F 1: 1 TIJE.tl 370 ' DETERMINE SECT. FOR CALC .
300 I F A&S(X(I))<0. 0005 THEN 320
31o GO ro 340
320 lF Y(l )>O THEtl 440
330 GO TO 590
340 IF Y(l)<0. 0005 THEt~ 500
350 IF Y( 1)<0. 0005 11-lEN 430
360 1F Y(l )>: R/SCR(2) - 0.0005 Thlll 400
37C U.T X( I+l ): X(I) - 0 ' CALC. PO~TS 0-~5 DEG.
380 LET Y(l+1):SQR(ABS(R• R- X(I+1 ) 1 X(I+1 )))
390 au 'IV 640
400 LlT Y( l+1):Y(l) +D ' CALC. POit.TS 45- 90 DEG.
410 LET X( l+ 1):SCR(A6S(R*R- Y(l+1)• Y( l +1)))
1120 GO ro 640
430 IF Y( l )<:R!SCR(2)+0. 0005 Tr~ 470
440 Lli Y( l +1):Y(I)- D •CALC. POlt.TS 90-135 DEC.
450 LlT X( l +1):-SOR(A&S(R*R-Y(l+1 ) 1 Y(l+1 )))
460 GV TO 640
ll70 LE.T X(l+1): X(I) - D ' CALC . PO:U.TS 135- 180 Df..G .
480 LeT Y(l+1):SCR(AbS(R*R- X(I+1 )*X(l+1 )))
490 GO TV 640
500 IF X( l)>- 0.0005 THEN 580
510 IF -Y{l) >:R/SQR( 2) - 0. C005 THEN 550
520 LET X{ I +l) :X(l)+D ' CALC. POINTS 18D-225 DEG .
530 Le7 Y( l +l) : - SUR(AbS{n*R- X( l+l )• X(l+l )))
5~0 Gu TO 6UO
550 LET Y( l +l):Y( I)-0 ' CALC. POINTS 225- 270 DEG .
560 LET X( l +1):-SCR(AfS(k*R- Y(l+l )•Y(l+l )))
570 GC TO 640
560 l f - Y(l)<:R/SCR(2)+0. C005 THEf4 620
590 LeT Y{l +l):Y( l)+D ' CALC . POINTS 270-315 DEG.
600 LET X(l+l ):SCR(ABS(R• R-Y{1+1 ) 1 Y(I+1 )))
6 10 cv ro 640
620 Lei X( l +l) ;X(l)+O ' CALC . POINTS 315-360 CEC.
630 llT Y( 1+ 1 ):- SQR(ASS( R*R- X( 1+ l) I X( 1+ 1)))
6fJO NEXT I
650 FOh 1: 1 TO ~ 1+ 1 ' T'RAHSLA'I£ ClRCl.E
660 LlT X{l):X(I)+H
670 llT Y(l):Y(l)+K
680 NEXT I
730 SllBENO
216 MAmEl-MICAL EUMNl'S FOR CXMroi'ER GRAPHICS

C-19 P« At..GORITK'i ~A PAJW£mtC CIRCLE

An algontiln for a pararootric representati.al of a circl e is given as a


BASIC language subprogxam. I t is based oo f):}s . (4-28) and (4-29) of Sec. 4-6 .
CIRCU:.

100 SLb"ClitCLE":t1 , }, , P, /. , X() , Y() ' PAF-AI'iETFIC CIRCLE


110 'h:X- CUJ110I;,ATE. OF CE.hTE.h OF THE CIRCLE
120 ·~=Y-COORDihATE Of CENTEfi OF tr.E CIFClE
13C ' .h:F.ADIUS
1l40 ' N:NUMbE.H Of POIM'S Ql', CIRCLE
150 ' X() ARkAY COI~TAirJING THE X-COORDINATES Of FOWTS Of~ CinCLE
160 ' Y() ARRAY CONTAlllUIG Tr.E Y-COOFDI!,ATES OF POINTS Qt. CIRCLE
170 LeT P:2*3.111156/(tl- 1) ' CALC . INCREMEliT Th THETA
180 LET C1:CUS( P) ' CALC. CuNSTANiS
190 LET Sl:SIN(P)
200 LE.T X(C):H+R ' CALC . INITIAL POit.T
210 ~T Y(O):K
220 FOR H: 1 TO N ' IM~ER LOOP
II 230 LET X(M):H+(X(M-1) - H) 1 C1- (Y(K- 1) - K) ' S1
2110 LET Y(H):K+(X(M- 1) -H) •S1 +(Y(M-1) - K) ' C1
250 NEXT H
~ .<\llf,ff.JO

C-20 PARN~ETRIC Eu.IPSE Al..GOOmt\

1he alC}Clrit:hm given below as a BASI C l.angu8<Je su~rnm generates an


ellipse. It is based oo Eqs. (4-38) and (4-39) of Sec. 4-8.
E.LUl'SEl
lCO Sl.c"ELUPSC.l" :H,K ,A,B,I,ri, X(} , Y(}
110 ' r:X-COOFDI~ATE Of CENTER Cf THE ELLIPSE
120 ' 1\:Y-coofiDINATE Of CEtiTER Of THE ELLIPSE
130 ' A:LEt.GTH Of SEMI- MAJOR AXIS
1~0 ' b: LEl:CTH Gf Sffil - t-:IIJOR AXIS
150 'I:INCL~ATIU• A~GLE OF MAJOR AXIS IN ~cGREES
160 ' N: MJMBER Of POlt1TS ON ELLIPSE
170 ' X() :ARfiAY CXitiTAThmG THE X-CGOROI.NATES Cf POit>TS ON ELLIPSE
180 ' Y(}:ARHAY ca~TAl~ING TP£ Y-COORDlNATES Of POI NTS ON ELLIPSE
1<;0 LE.T P:2• 3.1.1!156/(t-.-1 } 1 CALC . THE INCREMEliT IN TilE PARAMETER

2CO LET 11: 1/57 .2957795 ' CONVERT I TO RADIANS


210 LET C1:CGS(I1) ' CALC . THE COSINE AND
220 LET S 1:SIM 11) ' Sll~E CR Til£ l t.CLlNATION At-GEL
230 U.T C2:COS( P) ' CALC . TilE lt-.CFIEMEh'TS HI COSINE
21l0 U.T S2:Sit.( P) ' A~O SINE OF THE PAPAMETER u;cREME~;r
250 Ll1 C3:1 •INITIALIZE THE ACCU~ULATIO~
2£0 LET S3:0 ' VARIABLES
270 FOR M: 1 TG t. ' BEllIt-. INNER LOOP
280 LET X1:A1 C3 ' CALC. Ir.CRE11EUTS It. X AND Y
29C LET Y1:61 S3
3CO LET X(~)=H+X1 1 C1 -Y1 1 S 1 ' CALC . ~~~ X At.O Y
310 lti Y(I1 )=1<+Xl ' Sl+Yl 1 C1
320 LET T1:C3'C2-S~' S2 •CALC . NFJoi At.GLE fOWLLAS
33~ LET S1: S31 C2+C31 S2 'DOUblE ANGLE. F'Ofi SI,_E
3~0 LEi Cj:Tl ' OOUE!LE. AIJGLE FGk COSINE
350 hEY.T M
360 SUbEtrD
C-21 ~ Al.G001nt1 ~ A PARN£rRIC PARA&U

'Ihe al<JOrithm for a pararretric parabola given bela..• as a BASIC language


subprogram is based oo Eqs. (4-54) and (4-55) of Sec. 4-9.

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

c-22 ~ ITWIS Foo PAIWETRIC HvPEROOLAS

An algoritbn which generates a pa.ranetric hyperbolll is given belCM as a


BASIC snbpxogcan. 'lhe al<JOritbn is based oo Eqs. (4-57) and (4-58) of sec. 4-10.

l1YPE.I1b 1

100 SUB"HYPEfiB l" :A , b , N, X{),Y() 'PAAAH.ETRIC HYPERBOLA


110 ' A:DISTA~CE FllOI-' Cl:.mER Of HYPERBOLA TO VERTEX
120 ' B:DETEfiHH4ES SLOPI:.. FO ASYP.PlGTES:+-6/~
130 't.:tMlEE11 OF POI~TS Otl HYPERBOLA
140 ' X():ARRAY CONTAlt.U~ X- COORDINATES OF POINTS ON HYPERBOLA
150 ' Y( }:ARRAY CONTAH INC Y- COORDINATES OF POit.TS ON HYPERBOLA
200 LET P:) .l 41592654/(2*( N- 1)) ' CALC . PARAt'.ETEk INCREJ.~E.NT
210 Lf.,T C2:CGS( P) ' CALC. COSlNE ,SlNE , TAMiENT
220 LE.T S2:SW( P) ' OF PARAfJETER I~CRENENT
230 LET 12=T~(P)
240 LCT Q9:b1 T2
250 ~1 S9:b1 C2
~60 LET X(l):A 'INITIALIZE
270 LET Y(1):0
280 FOF< H:2 TO N 'U,NER LCOP
290 LET X(M):(S• X(H-1))/(S9-Y(N-l)•S2)
300 LET Y(H):(b' (Y(~-1)+09))/(8-Y(M- 1) 1 12)
310 t\E.XT ~
320 SIJSEND

Another al<JOritbn which generates a param!triC hypertx>la is given below as


a BASIC subprogram. '1his al<JOritl-rn is based on Eqs. (4-61) and (4-62) of
218 MMl!E:'.ATICAL EILMENl'S FOR a::MPUlER GRAPHICS

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

C-23 ~ Al.OORillfl ~ ACIRCLE TtmG! T~ PoiNTS


'!he alcprithm given below as a BASIC Stq>rogra.'ll detelll\i.nes the circular arc
passing through three points. It is based oo the discussioo of Sec. 4-ll.

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)

140 ' fi:RADIUS (RETURNED)


150 ' S():ARRAY CON1AIN1NC X-OOORDI1~ATES OF CIRCLE
160 1
T():ARRAY CONTAINING ¥-COORDINATES OF CIRCLE
170 ~~T A:ZER(3) •DIM & SET EQUAL TO ZERO
160 MAT B=ZER( 3)
190 FOR 1: 1 TO 3 ' CGPY X() & Y() ~~~ h() & B()
200 LET A(l):X(I)
210 LET B(l):Y(I)
220 !~EXT I
230 CALL"21YfRANS.":3,A(),B() ,-A(1),-8(1) ' TRANS. 1ST POINT TO ORIClt\
240 CALL"SOLVE" :A() , 8() , H1 ,K1 ' SOLVE fOR CENTER Of TRANS. ARC
2SO LET H:X( 1)+H 1 ' CALC. C~TER-COOJ\OINATES
260 LET K:Y(1)+K1
270 LET R:SOR(H1*H1+Kl ' K1) ' CALC. RADIUS
260 CALL"2DTRAt~.":3,A(),8() ,-h1 ,-K1 ' TnAfiS. CIRCLE TO ORICD;
290 CALL" ATAt," : A( 1) , 8( 1), T1 ' CALC. BECit,NlM; & ENDING At.GLES
300 CALL"ATAh'':A(2) , b(2) ,T2
310 CALL"ATAtt" :A( 3) ,8(3),T)
320 LET 11:11*57 .2957795 1 ' CHANGE RADlAhS TO DEGREES
330 LET T2=T21 57.29577951
~0 LET T3:T31 57 . 29577951
350 IF T1<T2 ~£H 420 ' TEST FuR DlfrlkEN1 CASES
360 IF T2>T3 1hEl• 470 'Tl >T2>T3
310 l.I:.T t3:T3-360 ' T1>12<T, CASE 1
380 IF ABS(T3-T1)<360 ThE.l~ 470 1 1l.ST lf CASE 1 COfifii:.CT

390 LET T3=T3+360 ' T1>T2<T3 CASl 2


400 LET T1:T 1-360
410 GO TO 470
420 lF T2<T3 THE-N 470 'Tl<T?<13
430 LLT Tl:Tl-360 ' T1<T2>13 CASE 1
440 lF ABS(T3- T1 )<360 HltJ, ll70 ' TEST If CI.SE 1 CCR!lECT
450 LlT T1:T1+360 'T1<T2>T3 ~ASE 2
460 LET T3:T3- 360
470 CAl.L"AkCA":H.K,fi,T1,T3,N, S() , T{) ' IlM\<1 ARC TifHIJ Tift 11iftE.E Ptilt.TS
1180 SUBEND
490 SlJB11 SOl.VE11 : A() , B() , H1, J\1 ' SOLVE FLR COOlfi at- ClhCI.£
500 1 A() , B():COOR OF 3 POINTS WHEn£ A( 1):8(1):0

5 10 ' Hl , Kl:X , Y-COOR OF CEhTER (RE1'URt.Et}


520 MAT C:ZER(2,2)
530 t1AT D:ZER( 2 , 1)
540 f-1AT E:ZER( 2 ,2)
550 JI.AT F':ZER( 2. 1)
560 FOR 1:2 TO 3 I SET UP MATRIX
570 LET C( l-1, l ):~A(I)
sao LLT c< I-1, 2>=~~<I>
590 l.lT D( l-1, 1):A(I) 1 A(l )+B(l) 1 8(1)
600 NEXT I
610 MAT E:~~V(C) ' CALC. CE~TE11
620 HAT F:E'D
630 LET H1:F(1 , 1) ' SET CEliTER ECUAL TO H1 , K1
640 LLT K1:F(2 , 1)
650 SUBEI\D
660 SUB" ATAt.'' :X , 'i , A ' TAl\ G- (YX)
670 I x.
'i:PROGftAH Flt.:DS TAf.GI:.liT Of ('i/)1)
680 ' A:TAtiC~'T Of ( Y/X) It• RADIAl-S ( RETURUE.C)
690 IF Y<O THEh 760
700 IF X:O THEI-l 740
710 IF X<O 'Ilil:.tw 760
72G l.CT A:A1N{Y/X) ' Q-90 DE.C.
730 GO TO 850
71lO LET A:1.570796327 ' 90 DEG.
750 GO TO 850
760 LET A: 3 . 141592654 -AT~(ASS(Y/X)) ' 90- 180 D~G .
170 00 TO 850
780 IF X:O ThE~ 840
790 lF X<O THEN ~20
Boo LE.1 A:6 .2o3 1&5308-ATil(AbS(Y/X)) ' 270- 360 CEG .
b 10 (j{j 111 850
b20 LET A: ATir(ABS(Y/X))+3 . 1111592654 '180-270 DEC.
b3o oo TL o5o
SliO LlT A:4 . 71236698 1 ' 270 DEG.
85o st..w.o
86C S{j8"ARCA" :X,Y , R,Tl.T2 . l•.X() , Y{) ' PARA!-'E'Tn:C CifiCULAk AliC
670 ' X: X-CUJfd.at~A TE CR CEfiTEf. <F AfC
66o • Y= Y- COOROl!';ATE: OF' cEt.n.R oF Afie
b~O ' J<: RADIUS <..f AP.C
900 ' T1 , T2:bi:.GlliNH,G AND Etl!il"G AtiGlFS II~ r.t:.GfiEES
9 10 'f•:NlJJ-.bE.h <l-' POl l, T!S TO REPFIESENT ARC
920 ' X( ):AfilfAY COt•TAit.II.C lliE. X-CCORDDd\TES GF 1llE AF.C
930 ' Y( ):Ak~AY COtlTf,It\It..C 'WE Y-COORDI.KATES Of TFE ARC
220 MMREl-'J\l'ICAL El..EMENTS FOR ClH'U'I'ER GRAPHICS

guo LiT T3:T1/57 . 395b ' CHA~E OtCREES TO RADIA~


95C LET P:(12-T1)/()7 .295b •(~-1 )) ' CALC. lNCkEr-1E(ti-1)T IN RADlA(h-l )S
960 LET C1:CGS(P) ' CALC . COS & Sltl Cf' lliCREJ-'.EtlT
970 U:."T Sl : Slr~(P)
98C l£'1 X( 1):X+R1 COS(T3) ' ll.lTIIILIZE TilE ACCI.i1Ut..ATIOtl
99C LeT Y(1):Y+h 1 Slh(T)) 'VARABLE
1COO Fu£4 1'.: 2 TO N ' CALC . X, Y <XX>R .
1010 LET X(N):X+( X(l'l-1 ) - X)•C 1-( Y(N-1 )- Y)*S 1
1020 LET Y(I'I):Y+(X(~l-1)-X) * S1+(Y(t-1-1}-Y}•C1
1030 fJUT ~
1040 SUBErlu

C-24 ~ Au:.ootnt1 Foo C£NERAT1NG Cusrc SPurt:s

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

100 SUB"SPLit.E" :S ,t. ,P( , ) , Cl ,C2 , N( ,) ,B(,) ,L(), Z, U(,) ,C(,)


110 ' S:CONTROL VARIA8LE S=2 FOP 2-D CURVE, S=3 FOR 3- D CUIWF.
120 • tl=t:tJPEER OF DATA rorrrrs
130 ' P( , ):ARRAY COt.'TA lt.l}.{; DATA POINTS
1!10 ' Cl:WITIIil END COt\DITIOr,
150 ' 1: RELAXED
160 ' 2:CLAt·IPED
170 I 3=CYCLIC

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

1800 ' SET UP I NTERIOR 1-'.ATPIX AND mVERT


1610 FOR J:2 TO N1 ' CRF:ATF t.'O~ZEhO VALUE"S FOR
1820 LET H(J ,J-1)=L(J) 'lh1'ERNAL FOWS OF 11-t-IATFIX
1830 LET M(J ,J ):2*(L( J )TL(J-l))
1840 FOR K: 1 TO S ' C~F.ATE RO~!S Of' 8-t-I.ATRIX
1b50 LET B(K,J)=31(L(J- 1)-21 (P(K , J+1)-P(r , J))+L(J)-2*(P(K ,J)- P{Y. ,J-l)))
1860 LET B(K , J):B{K ,J)/(L(J) •L(J- 1))
1870 t-EXT K
1880 hEXT J
1890 ~~T V:INV(M) ' INVERT M-f".ATP.IX
1900 FOR K:1 TO S
19 10 FOR J: l TO n- 1
1920 LET C(J):B(K ,J) ' CALC. SINGLE llOI C-11.ATPIX
1930 NEXT J
1940 MAT H:V 1 C ' CALC . TA"GEliT VECTOR VALUFS
1950 FOR J: 1 TO N- 1
1960 LET U(K ,J):l\(J) ' CREATE TAt.GElli' VECroP 1-'.ATRIY
1970 I•EXT J
1980 NEXT K
1990 IF C1=4 THElJ 2040
2000 FOR K= 1 TO S
2010 LET U(K ,IH:U(K, 1) ' SET FINAL TANGE:toT:lliiTIAL TANGM
2020 NEXT K
2030 GO TO 2070
2040 FOR K: 1 TO S
2050 LET U(K , ti):- U(K , 1) ' SET fiNAL TANGEtiT:- IIHTIAL TANGENT
2060 NEXT K
2070 SUBEND

C-25 ~ t\Lc;oo(llf1 FOR PARABOLIC &..ENDING

An algoritlm which iJTplenents the parabolic blending t.ec::hni.q\e described


in Sec. 5-6 is given belCM as a BASIC language S\i'p1 o.:~ram.

PARBLEND

100 SUE"PAP£·l£f<O" : R( , ) , f• , C( , ) • PARABOLIC BLEt.Olt!G


110 ' R( , ):ARRAY CONTAitW~ nil:. OX>RDit.ATES Of FOUR POltiTS
120 ' R( 1, ):X-COOnDlNATES
130 ' R(2 , ):Y-OOORDINATES
224 1-!M'HI:MM'ICAL EI»!ENIS FOR CGlPUI'ER GRAPHICS

140 ' R(3 , ):Z-CCORDUJATfS


150 ' N:NUHBER (F POINTS ~ CURVE
160 'C( , ):ARRAY roNTAir.ING POUlTS Ot• ELEt:DED CURVE
170 ' C( 1, ): X-CCORDINATFS
180 ' C(2, ):Y-COORDINATES
190 ' C(3, ):Z-ccORDINATES
200 I t.OTE : c 1-1l.ST HAVE DD'!EliSIONS (F (3 ' t!)
21C 01._, P(3 , 611) ,0(3,61;) ' Al.LO\\S UP 1U 6!1 SEG'tliTS
220 ~'ATS:ZfR(3, 3) ' IrJI1IALIZE AtiD Dl~EllSIOl>'
230 ~AT T:lER(3 , 3)
2110 HAT F=ZEfl(3 ,N )
250 HAT C=ZER(3 , tl)
260 LET TO:SQR((~(1 , 3) -R(1 , 2))-2+ (R(2 , 3) - R(2 , 2))-2+(R(3 , 3) -R(3 , 2))-2) ' CALC . TO
270 FOR J : 1 TO 3 ' SET UP TO GEtiERATf PARAEOLAS
280 FOR 1:1 TO 3
290 L£T S(l ,J):R(I , J) 1
THRU FIRST WREF.• POHrJ'S
300 LET T(I,J):R(I,J+1) ' THRU LAST 'JllRE£ POIN1S
310 NEXT I
320 NEXT J
330 CALL"GEtl" : S( , ) , 1, TO, N, P( , ) ' GENERATE PARAFOLA 'JllRU FIRST THR~E POINTS
3140 CALL"GEN" : T( , ) , 2 , TO , N,O(,) ' GEtlERAT£ PARABOLA WJ!U LAST TI1REE POilns
350 LET K:O
360 FOR 1:0 TO 1 STEP ( 1/(N-1 )) ' GElJERATE IlLEt'IDED aJRVE
370 LFT K=K•1
38o FOR 1:1 TO 3
390 LET C(l,K):( t-T) 1 P{ l,K)+T*O(I , K)
LIOO t.'EXT I
1110 f;EXT T
420 SUEEtiD
430 SUB"GEJ~":P( , ) ,St , TO , N, X( , )
1140 'P( , ):ARRAY CONTAihlt.x:i ntf;E'E POlh-iS FOR PARABOLA
450 ' P( 1 , ) :X CCt-'POtiENT
460 ' P(2 , ):Y COMPONE~T
470 ' P(3 , ):Z COf.1l'Ot,ENT
1180 ' S1:C0tn'ROL VARIABLE l :FIJ!ST PARMlOLA , 2:SECOND PARABOLA
490 ' N:tml-1I!ER CF POINTS 01~ PARAE<JLA
500 ' TO:CHORD LENGT1i B£'l'W~ MltDLE POI ~1'S
510 ' X( , ):ARRAY roNTAINThG 1l!E POUlTS 00 niE PARABOlA
520 ' X( 1, ):X-COI1.POt~ENT
530 ' X(2 , )=Y- CC+IFONEI!'T
5110 I X( 3 • ) =Z-COI'POf~fl;T
550 ~~T T:ZER(3) 'INITIALIZE & DII~EliSIO
560 HAT S:Z£R(3)
570 liAT IJ:ZER( 3)
580 FOR I= 1 TO 3 ' SET UP
590 LET T(I):P(I , 2)- P(l , 1) ' P(SUBII)- P(SUB3)
600 LET S(I):P{I ,3)- P(l , 1) ' P(SUD5)- P(SUB3)
610 LET I~( I):P(l,3)-P(I , 2) ' P(SUB5) - P(SUBII)
620 J,f.XT I • ( CF' EO. 5-Sll)
630 NAT U:S*S ' CALC . D-2
640 LET D:SOR(U) ' CALC. 0
650 HAT V:T*S ' CALC. n'E 001' PflOOOCT (CF EC. 5-Sll)
660 I..E'T X:V/U ' CALC . X (CF' EO. 5-54)
670 LET A:1/(U•X• ( t-57X)) ' CALC. ALPHA (CF 8Q. 5- 57)
680 If 51:2 THE~ 720
690 fiAT W:fi*S ' CALC . COS(nlFTA) (CF' EO . '.)-5Q)
700 LET T1 :\,/(T01 D)
710 0010 730
720 LET T1:V/(TO*D) ' CALC. COS(TI'f'TA) (Cf ro. 'i-SQ)
730 lf1' K:O
740 F'OR T2=0 TO 1 STEP(1/(~-1 )) ' CALC. POUlTS ctl PAPAKILA
750 LET K=K+1
760 LET T=i0 1 T2 ' CALC. T
110 LET R=T*Tl
780 IF S 1=2 TH£1'.; 800 ' 'If.ST FCR FlPSl OR SECOND P ARAf~ A
790 LET R=R+X1 D
800 FOR J=l iO 3
810 LET X(J 1 K):P(J 1 1)+(RID} 1 S(J)+A1 P1 (D-R)I(T( J)-Y ' S(J ) )
820 NEXTJ
830 t;EXT T2
840 SUSf.tiD

c-26 A Bezi ER CtJM Al.GOOITif'\

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

100 SUB"BEZIER": N1,,S,X(,),Y(, ) 1 Z(,) , P,R(,) ' EEZIER CURVE


11 0 ' Ul:NlJI.BER OF VERTICES IN eEZIEJl POLYGON
120 ' S:COtiTROL VARIABLE 2=PLAtiE CURVE , ) : SPACE CUPVE
130 ' X( , !):ARRAY CONTAINit,G lliE X- CCfo!PQt,Et-,T <F POLY<n: VERTICES
1110 ' Y( 1 ~ ~.:ARRAY COI~TAINl~'G ntE Y-CGt'POtiEtiT Of POLYGON VERTICES
150 ' Z( I 1 ):ARRAY COtiTAINIMJ ~E Z-C<l'!PONE~'T CE POLYGON VERTICES
160 ' P:t;UiffiER OF POIIJTS ALO~G EEZIER CURVE
170 'R( 1 ):ARRAY CONTAINING WE POlt"TS ALOMI WE BEZIE.R CURVF.
180 I R( 1 I )::X-cOt'PONEtfT
190 1
R(2 1 )=Y-cOfJPONEln"
200 I R(3 , ):z-co~Por. Etrr

210 ' INITIALIZE AND DINEt-.SlON AlL fJATRlCES


220 ' ASSU1"ES A HAXIYtR-" Of 10 POLYGOt\ VERTICES
230 NAT J=ZER( 1 1 N1)
240 ~~T C:ZER(1 1 1)
250 ~tAT D=ZER( 1, 1)
260 MAT E=ZER(1 1 1)
270 l£T N:tll-1
280 ' DEFINE F1JNCTION TO EVALUATE BIN011IAL EXPANSION (Cf &'. 5-65)
290 DEF FNF(X)
300 IF X:O THEN 360
3 10 ~T Y=1
320 LET Y:Y1 X
330 LET X=X-1
31:0 IF X:O THEt\ 380
350 roro 32o
360 LET fllf =1
370 0010 390
380 LET fliF: Y
390 Pt;a.o
400 LET K: 1
410 f'OR T:O TO 1 STEP 11 ( P-64 1) ' GF.tlEfiATE EASlS FUt!CTiot, ( CF EO. 5-64)
420 FOR I= 1 TO t.
430 LET J( 1I I+ 1):( FNF(~)/{F11F( l)*FtlF(N- I)) ) ' TAl* ( 1-T)- ( t.- I)
ll!IO r.EXT I
450 t".AT C=J'X ' GEUERATE POI~'TS AWiC A
1160 P.IAT D=J'Y 1 2- D OTi 3- D BEZIER UJRVE (CF EO . 5-66)
226 MJ\1111:M\'riCAL lill.1'U:N'l'S FOR CCl1PlT.IER GAAPHICS

ll70 LF.T h( l , K):C( 1, 1) ' CREATE POUlT RESULTS


ll80 LFT R(?, K):0(1 ,1 )
lJ90 IF S:2 THEN 520
500 ~AT E:J• z
5 10 LEi R(3 , K):f(1 ,1 )
5?0 LET K=K+1
510 IIEXT T
5ll0 SUB€ND

C-27 8-SPLINE ALGORITHM

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

100 SUb "BSPLli~E" : A, C, V( , ) , S , P , R( , )


11 0 'A:Nl.I-'BER CF POLYGOt. VEfiTICES ~n:us at-E
120 ' C: O"rfR Of 8-SPLlNE bASIS
110 ' V( , ):ARRAY CONTAINit.'G DEFINING POLYGON VEPTlCFS
140 ' V( 1, ) COti'TAI NS X-COORDWATES
150 ' V(2, ) CONTAIKS Y-COORDUJATES
160 ' V( 3, ) COtrfAlt.S Z-COORDINATES
170 ' S:CONTROL VARIABL.E S:2 FOR 2- 0 CUflVE , S: 3 FOR 3- 0 CURVE
180 ' P:THE UU}1JER Of POit;JS GEJ•ERATED ALOfXi ntE CURVF
190 ' h(, ):ARRAY COtiTAlNII-.G 1lfE F£SULTit.G B-SPLINE CURVE
700 I k( 1. ) CONTAI~ X-COORDINATFS
210 ' R(2, ) CONTAINS Y-GCORDINATES
220 I R( '3 , ) CONTAINS Z-COORDitlATES
230 ' N( ,):Io.ElGHTlNG fUt.CiiON (Cf EO. 5- 78 )
? liO DlM N(25 , ?5) , X(100)
250 !~.AT 1\:ZER((A+C) , (A+C)) ' REDlMEt.S lCti N & FlU. Win! ZF'POS
260 LET B:A-C+2
270 CAU.." KNaf":V( , ) , B, C, X() , S
280 FOR w:C- 1 TO C.B
290 FOFI 1=0 TO B+( C-1) • 2-1 ' INCREMENT KOOT VFC'TOR SUBSCRIPT
300 IF I<>H THE~ 350 ' CHECK FOR A GF.OMFTRIC KOOT
~10 IF X(l):X(l+l ) THEN 3~0
320 LfT Ml , 1): 1 ' CALC. VALUF.S
330 GO TO 350 ' fOR N(l , l) i U~ES 260- 320
3~0 LET N(I , 1):0
35C NEX1 I
3N' F'CJR T:X(\.1) TO X(W+-1)-. 0S STEP . OS 'INCFI&.ENT PARAtAfTER i
370 L£T L=L+ I
3b0 FOR K:2 TO C ' CALC. VALUES OF N(I , K) IN
390 fOh 1:0 TO A ' LINES 3~0-4 lJO
liDO If N(l , K-t )<>O 1HEIJ 1J30
4 10 LET 0:0
420 GO TO 11110
430 LEi D:((T-X(I))• tHI , I<- 1})/(X(I•I<- 1)-lC(I)) ' fiRST TERH ,
440 If fl(l+1,Y - 1) <>O THEN 470 ' FC'. ( 5- 78)
450 LfT E=O
460 GO 10 480
470 LET f::((X(l+K)-T) 'tl(I+l , K-1) ) /(X{ +1!'}-Y(l+l)) ' SECGW JF~•· ,
!lliO LET N(l ,K)=D+E 1 E(.l. ( 5-/r )

490 LET G:V(1 , I) • U(l,K)..C ' X-COY.POt,fJ;T OF P{T)


500 lEI' I!=V(2 ,I) l t-;(I , K)+H
510 If 5::2 THEN 5 30
520 LET 7.:V(3, I) •N(J,K)+Z
530 NEXT 1
540 IF K=C ~E~ 590
550 LET G:O
SM LET H:O
570 LET Z:O
500 t1EX1 K
590 LET R(L, 1):G
600 LET R(L ,2):H
610 If S:2 THEN 630
620 LET R(L, 3)=Z
630 LET G:O ' RESET INITIAL X, Y, Z VALUES
640 LET H:O
650 LET Z=O
660 NEXT T
670 NEXT W
680 LET L=L+ 1
690 LET R(L, l):V(l , A)
100 LET R(L , 2):V(2 , A)
710 IF S:2 THEN 730
720 LET R\L ,3):V(3 , 1)
730 SUEEND
740 SUB"KNGr": V( , ) , B,C, X() , S
750 ' V( , ): ARRAY CONTAINII«:i DEFINH!G POLYGON VERTICES
760 I B:l-ii\XIKUI~ T VALUE=A-C+2
770 ' C:ORDER OF B-SPLIUE BASIS
780 ' X( ):ARRAY OONTAINlt\G YtJCYf VECTORS GEIJERATED W TIHS SUPRO\fl'ltiE'
790 ' S:O:JNTROL VARIABLE S=2 PLANE' S:~ SPACE CURVE
800 FOR I=O TO B+(C-1) • 2
8 10 IF I>C-1 THEN 840 ' ASSURE MULTIPLICITY Cf' DEGRE'F' C
820 LET >:(1):0 ' I.S..<;IGN ~IULTIPLE El4t KmT VELIORS
830 GO 10 960
840 IF I<B+C 1liEtl 880 ' CHECK If END J:IICYf VErl'ORS REAC~FD
850 LET X(I):X(l- 1) ' ASS!Gt, NULTIPLE OP DUPLICATE KNOTS
860 GO 1U 960
870 IF S=3 THEN 9 10
880 IF V(l , l-G)<>V( l, I-c+l) Tf-1Efl950 1CHfC(( FOR REPEATIIOCI VERTICES
890 IF V(2 ,I-C)<>V(2 , I-C.1) THEtl 950 'C~ECK FOR REPEATltol; VF'RTICFS
900 GO TO 650
9 10 IF V(l , I - C}<>V(l , l-C+l) 111Eil 950
920 IF V(2 , I - C)<>V( 2 , I-C+1) 11-lHJ 950
930 IF V(3 ,1-C)<>V(3 , I-C+1) THEt. 950
940 GO TO 850
950 LET X(I):X(I- 1) +1 ' ASS IGf~ SUCCFS.<;IVF IN'Jl:RtfAl. Vtx:lORS
960 tlF.XT I
970 SUBEND

________________________________________.....
C-28 fw AlroRlnt'l FOR A Blllt£AR ~ACE PATOi

An alqorithn which will create the bilinear surface patch describ>rl in


Eq. (6-19) is given belo.tl as a BASIC language subpro:Jram.

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

C-29 fw AL.GORrllfl FoR LrNEAR ~s SmFACE

An alqor:l.ttm \llhi.ch will generate the linear COOns surface descrjbed by


Eq . (6-24) is given below as a BASIC language ~rogrmn . The algorithn
that the botndary curve c:-.an be described by equally spaced (in paranet:er
a5Sl.l1'eS
values) p:>ints on the OOundal:.y curves. '1he P(u,O) and P(u,l) curves are assured
to be describ>rl by the sarre Ill.l1ber of points as are the P{ O,w) and P(~w) curves.

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

170 ' C( , )=ARRAY CONTAINING THE POINTS ON THr PC O,W) CURVE


180 ' HAS D~ENSIONS OF M1 3
190 ' D( , ):ARRAY CONTAINING THE POl~TS ON TPE P(1,~) CURVE
200 1 HAS DUIENSIONS Of M' 3
210 'Q( ,):ARRAY OONTAINI~G THE CURVES WHICH DESCRlfE THE SUnFACE
220 ' HAS DWEIIoSIOOS Of (N1 M) 1 3. THE FO!lMAT IS FOR A FIXED
230 'VALUE Of U. THE NFXT M 110\ot'S Cf" ~E 0 t'A'I'IflX CONTAIIJ
2~ 0 ' THE VALUES FOR VARIABLE W.
250 ' OOTE: 0 MUST 1£ DU:£NSI~ED W DRIVER PR(.(jFAN
260 MAT Q:ZER(N1 M, 3) ' R£Dli-1EM0tl 0 & FilL \oilTH ZEPOS
270 FOR K: 1 TO ~I ' CALC. SURFACE
280 LET U=(K-1)/(11-1)
290 FOR J= 1 TO N
300 LfT ~~(J- 1 )/(N-1 )
310 LET S:S+ l
320 FOR L= I TO 3
330 LET O(S ,L}:A(K ,L)• (1- W)+B(K , L) 1 W+C(J,L)*(l-U)+D(J,L)*U
340 LET ~(S,L):O( S ,L ) -A (1,L) 1 (1 -U) ' ( 1-W)-B( 1,L ) ' ( l-U) * ~
350 lEf O(S , L):C(S ,L)-A(N ,L) 1 U' ( 1-W)-B(N , L) * U'~J
360 NEXT L
370 NEXT J
380 NEXT K
390 SUEEND

C-30 PH AL.Goolltt1 FoR A BICUBIC ~ACE PATCH

An al<JOrltbn ~ will generate the bicubic surface patch described l:1f


Eq. (6-37) is given below as a BASIC l..anguage subprogram. 'Lhe routine assures
that the boundary condition and the blending functioo rratrioes are known .

eiCUBI C

100 SUB"BICUBIC ": U 1, ~1 , X( , ) , Y( , ) , Z( ,), O (,) · ~-CUEIC SURFACE


11 0 ' U1:NO Of H~REI-lEt-.TS ALONG u-DIRECTI ON
120 ' Wl:NO rR It:CRE~Et-.TS ALONG W- DIRECTI ON
130 ' X( , ):~ X 4 ARfl AY COfJTAINil\G THE X- COHPOUEtn'S Of WE
1~0 ' P OOutfDARY CONDITION 111\TRIX EO. (6- 36)
150 ' Y(, }:4 X 4 ARRAY CONTAINI OO THE Y- COI'PONEt\TS Of TiiE
160 ' P BOUtlDARY CONDITION 1-'ATRIX EQ. (6- 36)
170 ' Z(, ):4 X ll ARRAY C:OttrAI NlNG THE Z-COMPOtiENTS OF THF
180 ' P BOUtiDAHY COI4DITION l1ATRIX EO . (6- 36)
190 ' P(,)=~ X 4 BOU~DARY CO~DITION MATRIX EO . (6- 36)
200 ' N(,):4 X 4 BLENDING FU~CTION MATRIX EC. (6- 31)
210 ' U( , ):1 X t1 ClTBIC BLENDING VECTOP EO. (6- 37)
220 ' W( , ):!1 X 1 CUBIC BLENDING VECTOR EO. (6- 37)
230 ' 0( , ):MATRIX COt\TAWUIG THE POSITIOU VECIOFS FOR 1llE
240 ' FHCUBIC SURFACE , !-lAS Cll1EriSIOt\S Of ( U1+1)*('-1+1) Y ~
250 ' FIRST COLUt-.1" IS X-COtJPOtlENT
260 ' SECOIJD <XlL~N IS Y- COt-'POtiENT
270 ' THIRD COLWN IS Z- COI'.PONElli'
28o 'FIRST WI+ 1 l:Ul·1FJJTS FOR U:O
290 ' SECOND Wl+ 1 El.~Eltl'S fOR U: 1/U 1, ETC .
300 t'.AT P::ZER(4,4) ' REDD'£t1Sl0N 11.ATRI CES &
310 ~.AT N:ZER( 4 , 4) ' FILL WI1} ZEFOS
320 ~.AT U=ZE~( 1,4 )
330 MAT W:ZER( 1,4)
3~0 ~:AT C=ZER((lJ1• 1)• n.1+1) , 3)
350 ·~T A:ZER(ij,l)
360 ~AT E=ZER(~,l)
370 ·~T C:ZER(4 , I)
380 HAT t:ZEfl( 1, 1)
390 LfT U( 1, 1):2 ' SET UP t.~..ATRIX
~00 L:."J li( 1, 2):N(2 ,3>=- 2
1110 LET t1(2 , 1)=-3
1120 LET N(2 , 2):3 •
1!30 LET N(1 , 3)=N(1 ,4):U(3,3):tl(4,1):1
~~ LET IJ(2 , ~)=-1
~50 !-I.AT M=TFt. (t:} ' CALC. TRANSPOSf Of' N-t-'.ATRIX
1160 t1.AT P:X ' CI.LC. X-CXWPOHEliTS CF
1170 LET K=K•l ' SUFFACE EUYEltfS
480 FOR I=O TO U1 'SET UP U-NATfiiX
490 LET U2:l/U1
500 LET U(1 ,1): U2~3 •
510 LET U(1 , 2) =U2•U2
520 LET U(1 , 3)=U2
530 L£T U(1 , 4):1
5110 FOR J=O TO \:1
550 LET L:L+1
560 LI::T •/2:J/W1 ' SET UP \o\-1-'.ATRIX
570 LET W(1,1):~2~3
580 LET w( 2. 1>=W2*~.2
590 LET W(3,1):W2
600 LET W(4 , 1):1
610 11./iT A::JII U ' CALC . SURFACE ElEl1BlT
620 NAT E=P*A
63C NAT C:JJ*B
6110 f'1AT D:U* C
650 LET C(L,K):D(l, 1)
660 liEXT J
670 t;EXT I
f.8o IF K:2 THEN 720
690 IF K>2 WElJ 740
700 ,...AT P:Y ' CALC. Y-rot-'PO~Ef'ITS OF
710 GO TO 1170 ' SURFACE fl.E}lEWI'S
120 I'..~TP:Z ' CALC. Z-OJI-IPONENTS Of
730 ro ro 470 I SURFACE ELE:l-'ENTS
740 SUSEtiD

C-31 BEziER SuRFACE I£NERATIOO Al..GOOJTHH

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

100 SUo"£.EZSIJPF":X( , ) ,Y( , ),Z( ,),t.,I",P,S( , ) ' I:EZIE~ SURFACF


110 ' X( , ):1\Rf<AY Q)~,TAllUI«; THE X-CC,..FCtlEt.TS OF 'nlE' POLYGOt. VERTICES
120 'Y (, ):AflfiAY Q)t.TAilllNG THE Y- C()I.fCtlEliTS OF nw POLYCO~ VFRTICFS
130 ' Z( , )=ARrAY Q)t.TAWit.C WF Z- CQIPCt:EliTS OF WE' POLYCO~ VERTICFS
140 ' t,OTE: X, Y, Z HAVE Dl!'EIJSIOt-:5 OF N X ~
150 ' FORf'lAT IS nlAT Si"O\\IJ IN FIGS. 6-1 2 & 6-1 3
160 ' N=ORDEfi OF niE DEFINING BEZIER POLYGONS FOR U:CI AllD '=1
170 ' I'I=ORDER CF niE DEfiNI NG BEZIER POLYGONS FtiR W:Q ANO \.-1
1
180 P:NUI'BER CF GRID LINES FOR TilE DEf'IlUNG SURFACE
190 'S( , ):POSITION VECTORS FOR SURFACE rEF~lNG GRID
200 ' S( 1, ):X~ENTS
210 ' S(2 , )=Y-c:ot-'PONF~'TS
220 ' S(3 , )=Z-00-\PONEM'S
230 ' F'ORt-IAT IS niAT FOR A FIXED VALUE Cf' U TilE tJEX7
240 ' fl El..El!E"TS 00t4TAIN 1liE \IALUES FOP TiiF CURVF C( U(SUP [), W)
250 ' S HAS OlfiEt:SIO~S OF 3 X P-2
260 11AT B: ZER( N, H) ' REDIMOOIOf, & ZEPO INTERf'..AL Nf\TRIX
270 ~F FNf( X) ' DEFINE f'UNCfiON TO CALC. FAC10HlAL Cf EC. ( 5- M)
280 IF X:O THEN 340
290 LET Y:l
300 LET Y=Y*X
310 LET X=X-1
320 IF X:O THEN 360
330 ooro 300
340 LET fliF: 1
350 GOTO 370
360 LET Ft:F=Y
370 FNEND
380 FOR C: l 70 3 ' FOR EACH C011PONENT CALC. SURFIICE
390 LET \ 1:0 ' GRID POSITION VECTORS
400 ON C GOTO 410 ,430 , 450
4 10 fi.A i B:X ' X- CCI1PONENT
420 GOTO 460
430 HAT E=Y 'Y-W1 PO::ENT
1140 GOTO 460
ll50 tAT E.:Z ' 2-cot'POUEt.T
460 FOP U: 0 TO 1 STEP 1/( P- 1) ' FOR FIXED U CALC. VARIOUS \t' S
470 FOR H: 0 TO 1 STEP 11( P-1 )
460 LET Wl:\\1+ 1
ll90 f'OR 1:0 TO N
500 LET Jl:(FNF(N)/(FNF(I) *ftlF(N-1))) 1 0-I*( 1-U)-(tJ- I)
5 10 FOR J: 0 T0 M
520 LET K1: (FlJF(~1)/(PNF(J ) 1 FNF(V-J)) )•w-J 1 ( 1- W) -(H-J)
530 LET S(C , \1 1 ):S(C ,W1)+B(l~l,J+1 ) * J 1* J\1
5~0 NEXT J
550 NEXT I
560 NEXT W
570 NEXT U
580 NEXT C
590 SUBEfiO
INDEX


A/0 ccnverter, 8 Axis:


APr, 1 arbitrary, 43, 54, 56, 207
Absolute coordinates, 4, 191 nde~:2'1c::e , 93
Active ax>rclinates, 4, 191 Axoncrnet.ric projection, 60, 62, 64, 208
Affine transfonnation, 59
Algorithms, 200 BASIC, 200
Alphan\ft!ric keytx>ard, 8 Basis, Bernstein, 140, 145
Alpham:rreric node, 190 Basis function, 140, 145
.Analog tablet, 8, 10, U, 30, 194 Be;un, 4
.AnalytiC ge<:llCtry 1 94 Begin frame 1 19 3
Analytic space curve, 118 Bernstein basis, 140, 145
Analytic surface, 158 Bernstein polynani.al, 140
Angular perspective, 69 BEZIER, 225
~tions, 55 Bezier:
hlticycl.ic spline, 126, 129 curve, 139, 225
Arbitrary axis, 43, 54, 56 p:>lyycn, 176
Arc. paratoh.c, 108 surface, 176, 179, 230
Area, 34 BEZSURF I 230
Array, 4 BICUBIC, 229
Associatl.ve, 198 Bicubic lofted surface, 182
INr.Ev. 233

Bl.cubic surface patch, 170, 173, Circular helix, US


183, 229 c~ end, 12s, 129
BIL.INEAR, 228 Clipping, 6
BiUnear Coals surface, 182 Closed curve, 93
Bilinear surface, 165, 167, 228 nx3es, 188
Bilinear transfonmtion, 47 Color CRI', 190
Bistable stora<Je tube , ll COnnutative, 198
Bits, 4 carprt:er aided &!si911, l, 157
Bivariate vector, 164 CCIIpJter aided lMI"IUfacturing1 1
Blended exterior surface, 185 catprt:er graphics, 1, 3
Blend,ed interior surface, 185 Concatenation, 6, 44
Blending curve, 134 , 143 COnic:
Blending functioo, 140, 169, sections, 94, 111
1 71 , 174 ncnparametric, 102
Blending, parabolic, 133, 137, 223 parmretric, 103
8:>undary cooditicn matrix, 173 COnstructive surface, 165
B::>u!ldary coodltions , 91, 120, 124 Continuity, 123 , 142
174 second-order, ll9, 121
B::>ur.dary curve, 176 OOOtrol djals, 8, 10
BSPLINE, 226 co::NSLIN, 228
B-spline, 226 Ooans surface, 168, 170, 181, 228
curves, 144, 148, 151 bilinear, 182
surface, 180 generalized, 181
linear, 168, 170
cabinet projection , 65 COOrdillate trode, 190
ca 11 i graphic, 12 Coordinates:
Canonical space, 194 , 195 absolute 1 4 1 191
cartesian product surface , 179, 180, display, 6
184 txxrogeneous, 4, 38, 42, 46, 200
Ca.trode ray tube , 4, 11, 16, 18, 23 incra'rental , 4
Cavalier projection, 65 relative, 4, 191
center of projection , 40 , 60 , 67 transfonood, 25
Otaracte.rs, 7 user, 6
CIJCIE, 216 Cross derivatives, 160
Circle, 95, 96 Cross prcdu:t, 57, 161
nonpararretric, 214 CRl' display, 73
parametric, 103, 215 CUbic, 92
Circular arc, 93 , 98, 112, 115, Bez.ie- curve, 141
218 blend:in9, 172
Circular arc inte:q;olatian, ll3 pararretric, 170
234 INDEX

spline, 1191 1301 220 Direction oosine , 55


spline, parmretric, 119 Directnx, 95
spline segrrent, 121, U3 Discriminate, 96
CUrsor, 4, 10 , 20, 189 Display buffer, 12
oottcns, 20 Display oontro11er, 12
<Xlntro1, 189 Display coordinates, 6
CUrve: Display file, 5
B-spl1ne, 144, 148, 151 Distortion, 32
Bezier, 139, 225 Distributative, 198
bl~, 134, 143 ~t tratrix plotter, 11, 16, 23
boundary, 176 D>t product , 57, 161

cl osed, 93 l):)uble buffering, 13
cubic, Bezier, 141 Draw absolute, 192
fitting, 91, 139 Drawing f~mctions t 1881 191
9Merator, 3 DJ:un plotter t 13
mathematical, 89 raster scan, 13
I:XIal
nonparamrt.ric, 90 0\mp blffer, 193
pararretric, 92 Dyr-.amic notion , 2 , 11, 13
plane, 89
second deqree, 91 Eccentricity, 95, 97
space, 116 £le!l'elts 1 196
CUrved line Jrode t 190 EIL.IPSE1, 216
CUrved surfaces, 164 Ellipse, 95, 97
Cyclic spline, U6, 129 , 132 parametric, 104, 216
Elliptic integral, 104, 115
Dashed l.ine rrode, 190 Encaste.red spline, 125
Data base, 4, 188 ~ conditioos , 128
Olta stream, 189 End tangent, 159 , 176
Derivative, partial, 163 Enla.rgerrent 1 32 t 41
Derivatives, 162 Erase, 11
Determinant, 198 Brase node, 190
Device independent, 189 Euclidean gearetry, 59
Device space, 194, 195 F.\1lers equation, 119
Device state, 189 Explicit representation, 90
Diagonal elenents I 196 Explicit space curve, 117
Dials, control, B, 10 Exterwr blended surface, 185
Digitizer, 20
DIMETRIC, 209 File, 4
Dllretnc, 60, 63 Fitting, cutVC, 91, 139
projcct.l.on , 209 Flat bed plotter , 13
fl.&Ckt•J" , 7 , II , l l Uflll it•J t rl pi ~·I •LHJOI 111)
l·'oc:u:.• , 9'> llfl'l i c 1t p.:-r :111 ~ , 117
1'-p.ll d a, 17C, rn •r t:'fr• •u 1 ~.,..... , <1
J'unctlm: h tc•tr.:tll nl:h 1 uuo:Jp , I 3
IJ luwliJ~<J, 140 , If I), 171 , l7 4 Tnriuiu lr'l", ?i. , 11'1
tlr.twmrl , Ulll , l 9 I Ju f] IY'l:lflfl JI(HIII 1 ~],

f.J11ll •r ,l) l ~('(j r.r..ti.J r, 1HI lnitl, 11:.-~ . l'IJ


hyp• riA" )lu•, 11 0 lrtf HJl , fll uph i t• ••1•'""' , 1 ~4
l ntPr. wt i\11 11t -v an • CYIIII rnl, I<JI lnlr•JroJI, •• II 1 t 11 , 1()1\, lJ 'j
poi nL, I &2 lnl••rc ity trr~rtulo~t ir11a, ~!
L'Wi.t..cJM•s , 8, 10 , lJ fll ti'Y•II''li\11• I~·VlC tUI I 1'! 11 1111'1! I l OtiO ,

t r•nnir~tll cnnl m l, I 111 Jlil


\1\_'Ct.o r Vtlll~ ...) , H•4 l nt~'l•IC'I h."• ()r otiA liC.:S, I, 7
w. •ll)ht inq 1 lit 'J Tnl• ·r fd• •, 1118
rntr rl()l blourlod hll l lol•"'', lll'J
("; •Ot •r c'l l I :71Vl C.':r~u Hurf.'l(Y• , JRI lnl rJJrlloal 'tl t uri '""' , lltfi
t:C•n.•ralizt'fl l>CJ J ,Jt {unclior., 101 liiU:I"(.IfJ l• L 1011 , ')0 I I I uI II\ II
<'I 'Jl •rtJlOr , 1111 Vf' , 1 ~ J rt.'\ll • ll .rc, 1 11
( l '()rl'(•lry, ('f' ·r.,( • 'l lVI ' , '}!) I i iM ,J J I J(,')

f.rc.JJ,hir (•l(tlt ·n t , L9l lnt• rf'.tort IIIIJ I i 111· 1 10 1 4:.l


r.rc~flluc inpul, laCJ 111\11 rtP ),YJ• rioJa (."Uoll ' ' • 110
c;r••rJhu: pnmll t VI , J89 HX~:I 1 :110
r.r••ph l o> : ISu•r tr ll , (,I) , (, I

tk:vit"'' • IRii prQ I' •I I t •II , 2]()

llall•roK1 i Vf•, I, :l
llrx ~ ·, 190 .Jt'fol [,IJrY, H, 10, lO
P· U lVI • , 14, HJ

IJ,, rclcrlf 'Y, I l , I I


lf.lrtt.l.ar• d~ 1r1Clt•r '1'1'1" 1>1 t.lJr, 7 ,,,, i l 1711•, J<;ll
IIHJh 1'"' 'f d pr an ti r, Jl , 2] lJ :l .t JUdi . I ')}

llrFno:J•I~o..t liJS C"Y "I lrlll r lol at ~ · . , 4, IR1 4l , L l~l· t 1 ~. n, '10


4(, , 200 r.lsll! pr:intt•r , H,
IM'I:JQH, ]17 t.i 01 Jll tit l iH•J I JO , I}
IM1!1Ch..? , /Ill 111 f 11'1 , IMI , 1/0
llypt rt/) ) ,, , 1,.,, ,.,,

pM.urt t 1 lc, I ()A , 1.17 h 1etvl 1 Jr,C)


ltypt·rl/>I tr: h~ •c.1. ioo , I I 0 int t·rJ.n l. I u .. ,, lf,r.
t r''" I o nrut 1 .lfa' , •,
J.illl .. :
236 INtEX

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

Parametri c ell i pse, 104, 216 Points, t.race, 73


Paratrctric hyperbola , l OB , 217 Points , transfo rmation of , 25 , 28
Parametri c parabola, 106, 217 Polygon, 139, 146
Pararretric space curve , 117 Bt..~ier, 176
Pararretric surface, 159, 162, 164 Pol}"C]alal surfAce , 177
P.ARBIDID, 223 Polyncrnial, 91
Partial derivatives, 163 Bel:nstllli'\, 140
Passi ve graphics, 14, 16 spline, 147
Patch surface , 159 , 176 Position vector, 92, 120, 159 , 166, 190
Pen , 4 Potentiareters , 8
Pen and ink pl o tter, 11, 16, 23 PROJ , 208
Perspective , 4 7 Project ion , 40
angular1 69 axonamctric, 60, 62 , 64, 208
gearet.r:y , 59 cabinet, 65
oblique , 72 cava l ier, 65
projection, 60 , 66 , 67 center of, 40, 60 , 67
s ingle point, 69 d.i.netr ic , 209
three point, 72 i.scr!etric, 210
transfo rtl\l1tion , 76, 77 , 210 oblique , 65
two-point , 71 , 75 orthographic, 208
Phospror, 12 perspective, 60, 66, 67
Picture, 3, 4 st:.ereographic , 84
Picture control functions , 191. 193
Pi ecewise cubic, 120, U2 , 147 Raster scan , 11, l3 , 23
Piecewise surface, 164 Rea) t.iJre, 2
Planar bilinear surface, 166 Rec:::OI'lSt:ruction, 78 , 2ll
Plane curves , 89 laluc:tion , 41
Plane surface , 162, 165 Reflect1on , 26 , 31, 47, 51 , 53 , 202 , 206
Pl otter , dot matrix, 11, 16, 23 refresh rate, 12
Plotter, flat bed, 13 ~fresh tube , 11 , 19 , 23
Plotter, pen and ink , 11, 16, 23 Pel.ative ooordinates , 4, 191
Pl otting head , 4 Relaxed end , 126, 129 , 132
Point absolute, 192 , 193 lesol ution 1 23
Point at infinity, 68 , 77 Rotat ion , 31, 33, 36, 40, 43 , 47, 50 ,
Point functi.oo , 162 52, 56 , 202
Point, inflection , 92 ab:lut arbitraty ilX.i.!J, 207
Point-plo tting, 20, 23 al::out x, 204
Point , vanishing, 68 , 73 , 76 about y , 204
Points, 41 24 about z , 205
Points a t infinity , 4l Ruled surface, 166, 184
238 INDEX

Scale transfo:rnation, 48 Steroo viewer, 84


Scaling, 26, 32, 34, 40, 47, Stereographic projection, 84
201, 203 Storage tube, 11, 16, 18
Scan conversion, 13 Storage buffer, 193
Scissoring, 6 Straight~. 27, 28 , 92
Secmd degree curve, 91 Stretching I 26 .
Second degtee surfaces, ll7 SUperscript notation, 171
Second order CXX'Itinuity, 119, Ul Support carp.rt:e.r, 188
Shear, 26, 34, 40 Surface:
Shearing, 47, 49 Bezier, 176, 179, 230
Single point perspective , 69 Coons, 168, 170, 181, 228

Sketching, 136 analytical, 158
Slcpe, 29, 163 bicubic lofted, 182
Slope, infinite, 92, 99 bilinear, 165, 167
Snoothness, 123, 147 bilinear, Coons, 182
Software systan, 188 b-spline, 180
Space, canonical, 194 cartesian product, 179, 180, 184
Space curve, ll6 ccnst.r\rtive, 165
analytic, US curved, 164
explicit, ll7 exterior blended, 185
.inp1 icit, ll7 generalized Cool IS 1 181
pararretric, ll7 interior blended, 185
Space device, 194, 195 intc.qx>lated 1 166
Space, three-dirrensia'lAl, 37 linear O:x:ns, 168, 170
Space, user, 194, 195 lofted, 1661 184
Sphere, 158 no.tml.ls, 160
S[:herical surface, 159 parametric, 159, 162, 164
SPLINE, 220 pa.ra.nctric lines, 163
Spline: patch, 159, 176
anticyc1ic, 126, 129 patch, bicubic, 170, 173, 183, 229
cubic , 119, 130, 220 patch, bilinear, 228
cubic segrrent, 121, 123 planar, bD inear, 166
cyclic, 126, 129, 132 plane, 162, 165
1oftsmans, ll9 polygmal, 177
mathsnatical., 119 representaticn, 157, 162
po1ynanial , 147 nll.ed, 166, 184
Square matrix, 42 , US, 196 secmd degree, ll7
s~ rrode, 190 sphe.rical 1 159
STERI:X> I 213 tensor product, 184
St.eroo pair, 213 vector valued 1 164
nmr:< 239

Tangent, end, 159, 176 TWist vector , 160, 173


Tangent vector , 93, 120, 122, 200EnECT, 202
159, 173 2DR:Jr, 203
Teletype, 16, 22, 23 2D6CALE, 201
Televisicn, 12
Tensor product surface, 184 'tWo-point pe.rspecuve, 71, 7".:J
Te.Irni.nal ccn trol functioos, 191,
193 I.NIAPI', 1
Text absolute, 192 Lnisurf system, 179
Textual material 1 31 191 Chit sphere, 159
300fNJVl' 1 201 !.hit square, 34
3DRBc:x:Nl, 211 Unit surface normal, 161
3DREFLT, 206 L"nit vector, 62
JOOCALE, 203 Unit vectors, 159
3t:1l'RANS , 207 User coordinates, 6
30>rn0l', 204 User space, 194, 195
3DYrol', 205
JDZJOr, 205 Vanishing {X>int, 68, 73, 76
Three diJrensional data, 23 Vanishing {X>int.s, 74
Ihree cllirensimal Sp&ee , 37 Vector, 24
JPCIRI\K: I 218 cross product, 161
'lbree {X>int perspective, 72 generator, 20
'lh\Eb wheels, 20 magnibxJe, 160
Trace, 196 position, 92, 120, 159, 166, 190
Traoe {X>ints, 73, 74 tangent, 93 , 120, 122, 159, 173
Track ball, 8 , 20 twist, 160, 173
Transfonnaticn: unit, 62
affine, 59 valued functioo, 164
bilinear , 47 val ued pa.ra.neter, 164
linear, 5 unit, 159
lines , 27 Vertex definitioo, 108
rratrix, 28, 47 Viewport, 6
midp:>.int , 28 Visioo windc:M, 7
perspective 1 76 t 77 1 210
{X>ints, 25, 28 Weighting functioo, 145
scale, 48 Wi.nd:lW, visicn, 7
Transformed cx:ordi.nates , 25 ~li..rxbwing, 6
Translation, 39, 44, 47, 54, 200, 207 Wbrk length, 4
Tridi.agonal rratrix, 124, 126
Trilretric, 60 zero ~ratrix, 197


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

You might also like