-+-+-+-+-+-+-+-+ START OF PART 11 -+-+-+-+-+-+-+-+ X794 y($)f(define)h(phigs$wstype)h()0 912 Xy Fq(For)11 b(example)h(to)f(use)h(the)f(DECW)n(indows)g(workstation,)e(type V) Xi(21)n(1:)54 1029 y Fi($)18 b(define)h(phigs$conid)h(decw$display)54 X1079 y($)e(define)h(phigs$wstype)h(211)54 1129 y($)e(run)h(myprog)0 X1246 y Fq(then)11 b(to)g(switch)f(to)h(the)g(colour)g Fn(P)p XFm(OST)p Fn(S)p Fm(CRIPT)i Fq(workstation,)d(type)h(62:)54 X1364 y Fi($)18 b(define)h(phigs$conid)h(output.ps)54 1413 y($)e(define)h X(phigs$wstype)h(62)54 1463 y($)e(run)h(myprog)0 1581 y Fq(T)m(o)12 Xb(display)e(the)h(current)g(settings)f(of)h(these)h(logical)e(names)j(use)f X(the)f(command)h Fi(show)p Fq(:)54 1698 y Fi($)18 b(show)h(logical)g X(phigs$wstype)54 1748 y($)f(show)h(logical)g(phigs$conid)0 X1916 y Fr(3.3)59 b(Example)16 b(C)g(pr)o(ogram)0 2037 y Fq(This)10 Xb(section)g(gives)g(an)h(example)g(C)f(program)g(which)g(uses)h(the)f(PHIGS) Vg X(T)m(oolkit.)k(The)d(program)f(creates)h(a)g(structure,)f(using)0 X2087 y(the)h(HashStrings)g(library)f(to)g(name)j(the)e(structure)f XFi("line")p Fq(,)j(and)f(posts)e(the)i(structure.)49 2200 y XFh(#include)k()49 2246 y(#include)g()49 2291 Xy(#include)g()49 2337 y(#include)g("ptk.h")49 2428 Xy(#define)g(WS1)h(1)49 2520 y(main\(\))49 2565 y(`7B)81 2611 Xy(Pwstype)g(wst;)81 2657 y(Ppoint)g(pts`5B2`5D;)49 2748 y(#if)f(VMS)0 X2956 y Fq(13th)22 b(May)m(,)12 b(1992)636 b(22)839 b(2.01)p Xeop X%%Page: 23 24 Xbop 0 -137 a Fq(PHIGS)11 b(T)m(oolkit)f(User)i(Manual)1235 Xb(PTK/100)81 8 y Fh(printf\("Opening)17 b(DEC)f(PHIGS...\\n"\);)81 X54 y(popenphigs\(0,)h(0\);)81 100 y(popenws\(WS1,)g(0,)f(0\);)49 X145 y(#endif)49 191 y(#if)g(SUN)81 237 y(printf\("Opening)h X(SunPHIGS...\\n"\);)81 282 y(popenphigs\(stderr,)g(PDEFAULT_MEM_SIZE\);)81 X328 y(wst)f(=)h(phigs_ws_type_create\()g(phigs_ws_type_sun_tool,)65 X374 y(PHIGS_TOOL_LABEL,)g("SunPHIGS)g(Tool)f(Workstation",)65 X419 y(0\);)81 511 y(/*)g(open)h(the)f(workstation)h(*/)81 602 Xy(popenws\(WS1,)g(\(Pconnid\)NULL,)g(wst\);)49 648 y(#endif)97 X739 y(/*)g(initialise)f(hashtables)h(*/)97 785 y(ptk_inithashtables\(\);)97 X830 y(ptk_createhashtable\("structureid",)h(1,)f(300\);)97 X922 y(ptk_openstruct\(ptk_stringtoint\("structureid",)i("line"\)\);)97 X967 y(pts`5B0`5D)e(=)f(ptk_point\(0.0,)h(0.0\);)97 1013 y(pts`5B1`5D)g(=)f X(ptk_point\(1.0,)h(1.0\);)97 1059 y(ppolyline\(2,)g(pts\);)97 X1104 y(ptk_closestruct\(\);)97 1196 y(ppoststruct\(WS1,)g X(ptk_stringtoint\("structureid",)h("line"\),)f(0.0\);)97 1287 Xy(sleep\(10\);)97 1378 y(pclosews\(WS1\);)423 b(/*)16 b(Close)g(workstation. V) Xh(*/)97 1424 y(pclosephigs\(\);)423 b(/*)16 b(Close)g(PHIGS.)h(*/)49 X1469 y(`7D)0 1638 y Fr(3.4)59 b(Example)16 b(Fortran)f(pr)o(ogram)0 X1760 y Fq(This)c(section)f(gives)g(an)h(example)h(Fortran)e(program)g(which) Vg X(uses)i(the)e(PHIGS)h(T)m(oolkit.)j(The)d(program)f(creates)i(a)g(structure, V) X0 1810 y(using)e(the)i(HashStrings)e(library)g(to)h(name)h(the)f(structure)g XFi("line")p Fq(,)i(and)e(posts)g(the)g(structure.)97 1926 y XFh(PROGRAM)17 b(drawline)97 2017 y(include)g('phigs77.h')97 X2109 y(INTEGER)g(ptkf_stringtoint)97 2154 y(REAL)g(xpts\(2\),)f(ypts\(2\))97 X2246 y(print)h(*,\('Opening)g(SunPHIGS...'\))97 2337 y(call)g(popph\(6,)f X(0\))49 2428 y(C)32 b(open)17 b(the)f(workstation)97 2520 y(call)h(popwk\(1, V) Xf(0,)h(phigswsttool\))97 2611 y(call)g(ptkf_inithashtables\(\))97 X2657 y(call)g(ptkf_createhashtable\('structureid',)h(1,)e(300\))97 X2748 y(call)h(ptkf_openstruct\(ptk_stringtoint\('structureid',)h('line'\)\)) V0 X2956 y Fq(13th)k(May)m(,)12 b(1992)636 b(23)839 b(2.01)p eop X%%Page: 24 25 Xbop 0 -137 a Fq(PHIGS)11 b(T)m(oolkit)f(User)i(Manual)1235 Xb(PTK/100)97 8 y Fh(xpts\(1\))17 b(=)f(0.0)97 54 y(ypts\(1\))h(=)f(0.0)97 X100 y(xpts\(2\))h(=)f(1.0)97 145 y(ypts\(2\))h(=)f(1.0)97 191 Xy(call)h(ppl\(2,)f(xpts,)h(ypts\))97 237 y(call)g(ptkf_closestruct\(\))97 X328 y(call)g(ppost\(1,)f(ptkf_stringtoint\('structureid',)i('line'\),)f X(0.0\))97 419 y(call)g(pclwk\(1\))97 465 y(call)g(pclph\(\))97 X556 y(STOP)97 602 y(END)0 2956 y Fq(13th)22 b(May)m(,)12 b(1992)636 Xb(24)839 b(2.01)p eop X%%Page: 25 26 Xbop 0 349 a Fj(Chapter)24 b(4)0 585 y Fs(Pr)n(ogramming)j(tools)0 X835 y Fq(This)11 b(chapter)h(describes)g(the)f(programming)f(tools)g(in)h X(the)g(PHIGS)h(T)m(oolkit.)i(These)e(are)g(as)g(follows:)64 X955 y Fl(\267)21 b Fp(The)13 b(T)m(ransformations)f(Library)g XFq(\261)h(a)h(collection)d(of)i(functions)e(for)i(constructing)e(and)i X(manipulating)e(coordinate)104 1005 y(transformations.)64 1088 Xy Fl(\267)21 b Fp(The)8 b(HashStrings)g(Library)g Fq(This)g(is)g(a)h X(collection)e(of)g(functions)g(which)h(enable)g(text)g(strings)e(to)i(be)g X(used)h(in)e(situations)104 1138 y(where)12 b(integers)e(would)h(normally)f X(be)i(required.)64 1221 y Fl(\267)21 b Fp(The)16 b(PHIGS)i(Utilities)d X(Library)h Fq(\261)g(a)g(collection)f(of)h(utility)e(functions,)i(providing) Ve X(operations)h(\(such)i(as)g(`60copy)104 1271 y(element'\))d(which)f(are)h(no Vt)f X(directly)f(provided)g(by)i(PHIGS,)f(as)i(well)e(as)h(common)g(sequences)h X(of)e(PHIGS)h(function)104 1321 y(calls)d(`60bundled)f(up')h(into)f(single)h X(functions.)64 1404 y Fl(\267)21 b Fp(The)c(PHIGS)h(T)m(raversal)f(State)f X(List)g(Library)h Fq(\261)f(a)i(collection)d(of)i(functions)e(for)h X(inquiring)e(information)h(of)i(a)104 1454 y(simulated)11 b(structure)f X(network)h(traversal.)64 1537 y Fl(\267)21 b Fp(The)10 b(colour)f(library)g XFq(\261)h(a)g(collection)e(of)h(functions)f(for)i(de\256ning)e(colour)h X(values)h(using)e(English)h(words)g(and)g(phrases.)64 1620 Xy Fl(\267)21 b Fp(Miscellaneous)11 b(functions)p Fq(.)0 1788 Xy Fr(4.1)59 b(The)17 b(T)l(ransformations)d(Library)0 1910 Xy Fq(This)c(module)g(provides)f(a)i(comprehensive)g(suite)e(of)h(routines)f X(for)h(manipulating)e(three-dimensional)i(coordinate)f(transfor)o(-)0 X1960 y(mations)i(using)f(matrix)h(methods.)0 2039 y(Functions)f(are)i X(provided)e(for:)64 2159 y Fl(\267)21 b Fq(T)m(esting)11 b(equality)f(of)h X(real)h(values.)64 2242 y Fl(\267)21 b Fq(Converting)9 b(vectors)i(to)g X(points,)f(and)i(vice)f(versa.)64 2325 y Fl(\267)21 b Fq(Manipulating)9 Xb(vectors:)15 b(sum,)d(dot)e(and)h(cross)h(product,)f(modulus,)f(unit)g X(vectors.)64 2408 y Fl(\267)21 b Fq(Manipulating)8 b(matrices:)16 Xb(creating)10 b(a)h(unit)f(matrix,)h(matrices)g(for)f(scales,)j(rotations,)d X(translations)f(and)i(shears,)h(com-)104 2458 y(bining)h(matrices,)18 Xb(box-to-box)13 b(transformations,)j(matrix)f(inversion,)g(printing)e X(matrices,)18 b(maintaining)c(stacks)i(of)104 2508 y(matrix)11 Xb(transformations.)64 2591 y Fl(\267)21 b Fq(Converting)9 b(between)j(3D)f X(and)g(4D)g(homogeneous)g(representations.)64 2674 y Fl(\267)21 Xb Fq(Evaluating)10 b(viewing)g(parameters.)912 2956 y(25)p Xeop X%%Page: 26 27 Xbop 0 -137 a Fq(PHIGS)11 b(T)m(oolkit)f(User)i(Manual)1235 Xb(PTK/100)0 8 y(Using)9 b(homogeneous)h(coordinates,)g(we)h(represent)f(a)h X(3D)f(transformations)e(using)h(a)i(4)6 b Fl(\264)g Fq(4)k(matrix)f(is)h X(used.)16 b(If)9 b Fl(\()p Fk(x,)e(y)n(,)g(z)p Fl(\))12 b Fq(is)d(the)0 X58 y(vector)j(before)g(transformation,)f(and)h Fl(\()p Fk(x)p XFl(\242)p Fk(,)7 b(y)p Fl(\242)p Fk(,)g(z)p Fl(\242\))14 b XFq(the)e(transformed)g(vector)n(,)h(then)e(the)h(transformation)f(can)h(be)h X(expressed)g(as)0 108 y(follows.)h Fp(Note)e(that)e(we)i(use)g(column)f X(vectors)h(to)f(r)o(epr)o(esent)k(points.)418 186 y Fg(0)418 X259 y(B)418 284 y(B)418 311 y(@)480 219 y Fk(x)p Fl(\242)480 X269 y Fk(y)p Fl(\242)481 319 y Fk(z)p Fl(\242)475 369 y Fk(w)p XFl(\242)534 186 y Fg(1)534 259 y(C)534 284 y(C)534 311 y(A)582 X294 y Fq(=)617 186 y Fg(0)617 259 y(B)617 284 y(B)617 311 y(@)674 X219 y Fk(a)41 b(b)i(c)k(d)675 269 y(e)c Fl(\246)e Fk(g)46 b(h)678 X319 y(j)h(k)h(l)e(m)674 369 y(p)41 b(q)j(r)51 b(s)911 186 y XFg(1)911 259 y(C)911 284 y(C)911 311 y(A)957 294 y Fl(\327)977 X186 y Fg(0)977 259 y(B)977 284 y(B)977 311 y(@)1035 219 y Fk(x)1035 X269 y(y)1036 319 y(z)1034 369 y Fq(1)1075 186 y Fg(1)1075 259 Xy(C)1075 284 y(C)1075 311 y(A)1232 244 y Fk(x)p Fl(\242\242)43 Xb Fq(=)12 b Fk(x)p Fl(\242)p Fq(/)q Fk(w)p Fl(\242)1232 294 Xy Fk(y)p Fl(\242\242)43 b Fq(=)12 b Fk(y)p Fl(\242)p Fq(/)q XFk(w)p Fl(\242)1235 344 y Fk(z)p Fl(\242\242)42 b Fq(=)12 b XFk(z)p Fl(\242)p Fq(/)q Fk(w)p Fl(\242)0 481 y Fq(The)17 b(true)f X(coordinates)g Fl(\()p Fk(x)p Fl(\242\242)p Fk(,)7 b(y)p Fl(\242\242)p XFk(,)g(z)p Fl(\242\242\))p Fq(,)21 b(which)16 b(should)f(be)i(used)f(for)g X(supplying)e(coordinates)i(to)g(PHIGS,)h(are)g(derived)f(by)0 X531 y(performing)10 b(the)i(homogeneous)f(division)e(by)j Fk(w)p XFl(\242)f Fq(as)h(shown)g(above.)k(In)11 b(some)h(cases,)i XFk(w)p Fl(\242)e Fq(may)g(be)g(zero,)g(in)f(which)g(case)i(the)0 X581 y(application)d(program)h(must)g(take)h(appropriate)e(action)h(and)g X(avoid)g(the)g(division.)0 726 y Fu(4.1.1)50 b(A)14 b(note)f(about)g(points) Vf X(and)h(vectors)0 832 y Fq(The)f(PHIGS)g(T)m(oolkit)e(uses)i(the)f XFi(Ppoint)i Fq(and)f Fi(Ppoint3)h Fq(datatypes)e(in)g(all)g(cases)i(where)g X(a)f(pair)f(or)g(triplet)f(of)h(\257oating)g(point)0 882 y(numbers)e(are)h X(required,)g(with)e(the)h(exception)g(of)g(colour)f(representations.)14 Xb(The)c(SunPHIGS)f(and)h(DEC)f(PHIGS)g(C)g(language)0 932 y(bindings)g(both) Vg X(use)j(the)e Fi(Pvector)i Fq(and)f Fi(Pvector3)h Fq(datatypes)f(in)f(several V) Xh(functions.)j(W)m(e)d(believe)g(that)f(this)g(is)g(a)h(hindrance)0 X981 y(rather)g(than)g(a)g(help)g(to)g(the)g(PHIGS)g(programmer)n(,)h(and)f X(we)h(therefore)f(provide)f(a)h(set)h(of)f(functions)e(which)i(enable)h X(standard)0 1031 y(PHIGS)h(functions)e(to)i(be)g(called)g(using)f(the)h XFi(Ppoint)h Fq(and)f Fi(Ppoint3)h Fq(datatypes)f(instead)f(of)h(the)g XFi(Pvector)h Fq(and)f Fi(Pvector3)0 1081 y Fq(datatypes.)i(These)e(functions V) Xd(from)h(part)g(of)g(the)g(Miscellaneous)g(Functions)f(library)m(,)h(which)g X(is)g(described)h(in)e(Section)h(4.6.)0 1226 y Fu(4.1.2)50 Xb(Using)14 b(the)f(T)l(ransformations)h(Library)0 1332 y Fq(T)m(o)c(use)h X(the)e(transformations)g(library)m(,)h(at)g(least)g(one)g(transformation)e X(matrix)h(must)h(be)g(declared,)i(as)e(the)g(following)e(example)0 X1382 y(illustrates,)i(which)h(sets)h Fi(mat)g Fq(to)e(be)i(a)g X(transformation)e(which)h(scales)h(by)f Fl(\()p Fq(3)p Fk(.)p XFq(0)p Fk(,)c Fq(4)p Fk(.)p Fq(0)p Fk(,)g Fq(5)p Fk(.)p Fq(0)p XFl(\))k Fq(:)54 1495 y Fi(Pmatrix3)37 b(mat;)54 1545 y(Ppoint3)g(pt;)54 X1645 y(pt)18 b(=)h(ptk_point3\(3.0,)h(4.0,)f(5.0\);)54 1694 Xy(ptk_scale3\(&pt,)i(PREPLACE,)e(mat\);)0 1808 y Fq(T)m(ypically)m(,)10 Xb(when)f(specifying)g(transformations)f(several)i(matrices)g(need)g(to)f(be) Vh X(combined)f(together)g(to)g(produce)g(the)g(desired)0 1857 Xy(transformation.)20 b(For)12 b(example,)j(the)e(function)f XFi(ptk_shift3)j Fq(takes)e(as)h(input)e(a)h(shift)g(vector)n(,)h(and)f(a)h X(matrix)e Fi(mat)p Fq(.)22 b(It)13 b(\256rst)0 1907 y(creates)g(an)f X(internal)f(matrix)g(comprising)f(just)h(this)g(shift)g(\(call)g(it)g XFi(shm)p Fq(\))h(and)g(then)f(combines)h(it)f(with)g Fi(mat)h XFq(according)f(to)g(the)0 1957 y(parameter)h Fi(operation)p XFq(,as)i(follows:)p 364 2035 1139 2 v 363 2085 2 50 v 389 2070 Xa(Operation)p 835 2085 V 304 w(Name)p 1152 2085 V 220 w(Ef)o(fect)p X1502 2085 V 364 2087 1139 2 v 364 2097 V 363 2147 2 50 v 389 X2132 a(PREPLACE)p 835 2147 V 264 w(Replace)p 1152 2147 V 185 Xw Fi(mat)e Fl(\254)f Fi(shm)p 1502 2147 V 364 2148 1139 2 v X363 2198 2 50 v 389 2183 a Fq(PPRECONCA)-5 b(TENA)g(TE)p 835 X2198 V 76 w(Preconcatenate)p 1152 2198 V 68 w Fi(mat)12 b Fl(\254)f XFi(mat)h Fl(\264)f Fi(shm)p 1502 2198 V 364 2200 1139 2 v 363 X2250 2 50 v 389 2235 a Fq(PPOSTCONCA)-5 b(TENA)g(TE)p 835 2250 XV 51 w(Postconcatenate)p 1152 2250 V 51 w Fi(mat)12 b Fl(\254)f XFi(shm)h Fl(\264)f Fi(mat)p 1502 2250 V 364 2251 1139 2 v 0 X2348 a Fq(Often,)d(it)f(is)g(necessary)i(to)e(manage)i(sequences)g(of)e X(transformations)f(which)h(may)h(be)g(nested,)h(and)e(the)h(functions)e XFi(ptk_stackmatrix3)0 2397 y Fq(and)11 b Fi(ptk_unstackmatrix3)p XFq(,)k(which)c(push)g(and)g(pop)g(matrices)h(using)e(a)i(stack,)g(are)g X(provided)e(to)h(assist)g(with)g(this.)0 2543 y Fu(4.1.3)50 Xb(A)14 b(simple)g(example)0 2648 y Fq(Suppose)9 b(we)i(wish)e(to)g(generate) Vh X(a)g(transformation)f(matrix)g(that)g(is)g(equivalent)g(to)g(a)h X(window/viewport)d(mapping.)14 b(The)c(bot-)0 2698 y(tom)f(left)g(and)g(top) Vg X(right)f(hand)h(corners)h(of)f(the)g(window)f(are)i(given)f(by)g XFl(\()p Fk(x)1073 2704 y Ff(min)1120 2698 y Fk(,)e(y)1155 2704 Xy Ff(min)1203 2698 y Fk(,)g(z)1236 2704 y Ff(min)1284 2698 Xy Fl(\))i Fq(and)h Fl(\()p Fk(x)1409 2704 y Ff(max)1461 2698 Xy Fk(,)d(y)1496 2704 y Ff(max)1549 2698 y Fk(,)g(z)1582 2704 Xy Ff(max)1635 2698 y Fl(\))i Fq(respectively)m(.)0 2748 y(These)k(must)e(be) Vg X(mapped)h(onto)e(the)i(corresponding)d(corners)j(of)f(the)g(viewport,)f XFl(\()p Fk(u)1238 2754 y Ff(min)1285 2748 y Fk(,)d(v)1320 2754 Xy Ff(min)1368 2748 y Fk(,)g(n)1406 2754 y Ff(min)1454 2748 Xy Fl(\))k Fq(and)g Fl(\()p Fk(u)1585 2754 y Ff(max)1637 2748 Xy Fk(,)c(v)1672 2754 y Ff(max)1725 2748 y Fk(,)g(n)1763 2754 Xy Ff(max)1815 2748 y Fl(\))p Fq(.)0 2956 y(13th)22 b(May)m(,)12 Xb(1992)636 b(26)839 b(2.01)p eop X%%Page: 27 28 Xbop 0 -137 a Fq(PHIGS)11 b(T)m(oolkit)f(User)i(Manual)1235 Xb(PTK/100)0 8 y(The)11 b(transformation)e(can)i(be)g(partitioned)d(into)h X(three)i(simple)f(steps.)15 b(The)c(window)e(is)i(\256rst)f(shifted)f(to)h X(place)h(its)f(bottom)f(left)0 58 y(hand)j(corner)g(at)g(the)g(origin.)k(It) Vc X(is)f(then)h(scaled)h(about)e(the)h(origin)f(to)g(match)i(the)f(size)g(of)g X(the)g(viewport.)k(The)d(scale)g(factors)0 108 y(in)e Fk(x)p XFq(,)h Fk(y)p Fq(,)g(and)g Fk(z)f Fq(are)h Fk(S)306 114 y Fe(x)321 X108 y Fq(,)g Fk(S)364 114 y Fe(y)379 108 y Fq(,)g(and)f Fk(S)493 X114 y Fe(z)518 108 y Fq(where:)766 196 y Fk(S)787 202 y Fe(x)843 X196 y Fq(=)913 168 y Fk(u)934 174 y Ff(max)995 168 y Fl(-)e XFk(u)1048 174 y Ff(min)p 913 187 183 2 v 915 225 a Fk(x)933 X231 y Ff(max)995 225 y Fl(-)g Fk(x)1045 231 y Ff(min)0 334 Xy Fq(and)i(similarly)f(for)h Fk(y)h Fq(and)f Fk(z)p Fq(.)16 Xb(Finally)10 b(the)h(window)g(is)g(shifted)f(so)h(that)g(it)g(is)g X(coincident)f(with)g(the)h(viewport.)0 409 y(Since)h(post-multipli)o(cation) Vc X(is)j(used,)h(the)f(order)g(in)g(which)g(the)g(procedures)g(are)h(called)g X(is)f(the)g(reverse)h(of)f(the)g(logical)g(order)0 459 y(in)g(which)g(the)g X(transformations)f(are)i(applied.)j(The)d(sequence)g(of)f(calls)h(is)f(as)h X(follows:)72 555 y Fi(Pmatrix3)37 b(matrix;)72 605 y(Ppoint3)g(scale,)19 Xb(shift1,)h(shift2;)72 705 y(shift1)f(=)f(ptk_point3\(umin,)j(vmin,)e X(nmin\);)72 804 y(scale.x)g(=)f(\(umax-umin\))i(/)f(\(xmax-xmin\);)72 X854 y(scale.y)g(=)f(\(vmax-vmin\))i(/)f(\(ymax-ymin\);)72 904 +-+-+-+-+-+-+-+- END OF PART 11 +-+-+-+-+-+-+-+-