-+-+-+-+-+-+-+-+ START OF PART 261 -+-+-+-+-+-+-+-+ X *topnodestid = structptr->name; X `7D X else X *err = 2; X `7D X else X *err = 1; X`7D /* ptk_inqtopologyhighlightnode */ X X/*-------------------------------------------------------------------------- V*/ X X/* end of topo.c */ X $ CALL UNPACK [.SOURCE.LIBRARY]TOPO.C;1 690273317 $ create 'f' X/*-------------------------------------------------------------------------- V-- X X Module name: transformations utility package.`20 X`20 X Authors: W.T. Hewitt, K.M. Singleton. X`20 X Function: contains functions for performing two-dimensional and`20 X three-dimensional transformations.`20 X X Dependencies: machine.h, transformtypes.h. X X Internal function list: validbounds. X X External function list: ptk_equal, ptk_point, ptk_point3, ptk_vector, X ptk_vector3, ptk_vec3topt3, ptk_pt3tovec3, ptk_limit, ptk_limit3, X ptk_dotv, ptk_crossv, X ptk_nullv, ptk_modv, ptk_unitv, ptk_scalev, ptk_subv, ptk_addv, X ptk_unitmatrix3, ptk_transposematrix3, ptk_multiplymatrix3,`20 X ptk_concatenatematrix3, X ptk_shift3, ptk_scale3, ptk_rotatecs3, ptk_rotate3, ptk_shear3, X ptk_rotatevv3, ptk_rotateline3, ptk_pt3topt4, ptk_pt4topt3, ptk_transform4, X ptk_transform3, ptk_matrixtomatrix3, ptk_outputmatrix3, ptk_box3tobox3,`20 X ptk_accumulatetran3, ptk_evalvieworientation3, X ptk_evalviewmapping3, ptk_stackmatrix3, ptk_unstackmatrix3,`20 X ptk_examinestackmatrix3, X ptk_3ptto3pt, ptk_0to3pt, ptk_oto3pt, ptk_invertmatrix3. X X Hashtables used: none. X X Modification history: (Version), (Date), (Name), (Description). X X 1.0, 2nd February 1986, W.T. Hewitt, First version. X X 1.1, 1st April 1986, K.M. Singleton, W.T. Hewitt, Added viewing`20 X and other utility routines. X X 1.2, 8th June 1987, K.M. Wyrwas, Added routine to invert a matrix. X`20 X 1.3, 8th July 1988, S.Larkin, Modified to work with VAX PHIGS$. X X 1.4, 30th October 1990, W.T. Hewitt, Fixed to work with VAX PHIGS$. X X 2.0, 4th January 1991, G. Williams, Converted from Pascal to C. X X 2.1, 13th February 1991, G. Williams, Added functions - ptk_vector3, X ptk_vec3topt3 and ptk_pt3tovec3. X X 2.2, 3rd May 1991, G. Williams, Added function - ptk_3x3to4x4. X X---------------------------------------------------------------------------- V*/ X X#include X#include X#ifdef SUN X#include X#include X#endif X#include "machine.h" X#include "ptktype.h" X#include "trantype.h" X X/* Pointer records */ X Xtypedef struct ptksstack3`20 X`7B X Pmatrix3 ptkamat; X struct ptksstack3 *ptkpnext; X`7D ptksstack3; X Xtypedef struct ptksstack X`7B X Pmatrix ptkamat; X struct ptksstack *ptkpnext; X`7D ptksstack; X X#define ptkcdtor (3.14159263 / 180.0) X Xstatic ptksstack3 *listhead3 = NULL, *newone3 = NULL; Xstatic ptksstack *listhead = NULL, *newone = NULL; X X/* global variable for ptkcpceps */ X XPfloat ptkveps = ptkcpceps; X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern ptkboolean ptk_equal(C(Pfloat) one, C(Pfloat) two) XPreANSI(Pfloat one) XPreANSI(Pfloat two) X/* X** \parambegin X** \param`7BPfloat`7D`7Bone`7D`7Bfloating point number`7D`7BIN`7D X** \param`7BPfloat`7D`7Btwo`7D`7Bfloating point number`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns TRUE if \pardesc`7Bone`7D and \pardesc`7Bt Vwo`7D X** are equal, or their difference is less than the global`20 X** constant tolerance \pardesc`7Bptkveps`7D. This is a global`20 X** variable of type \pardesc`7BPfloat`7D which may be changed by the applica Vtion. X** The default value of \pardesc`7Bptkveps`7D is 1.0e-7.`7D X*/ X`7B X Pfloat x, y; X X x = (Pfloat)one; X y = (Pfloat)two; X return (fabs(x - y) <= ptkveps); X`7D /* ptk_equal */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Ppoint ptk_point(C(Pfloat) x, C(Pfloat) y) XPreANSI(Pfloat x) XPreANSI(Pfloat y) X/* X** \parambegin X** \param`7BPfloat`7D`7Bx`7D`7Bx coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7By`7D`7By coordinate`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns a structure representing the`20 X** 2D point \pardesc`7B(x,y)`7D.`7D X*/ X`7B X Ppoint temp; X X temp.x = x; X temp.y = y; X return temp; X`7D /* ptk_point */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Ppoint3 ptk_point3(C(Pfloat) x, C(Pfloat) y, C(Pfloat) z) XPreANSI(Pfloat x) XPreANSI(Pfloat y) XPreANSI(Pfloat z) X/* X** \parambegin X** \param`7BPfloat`7D`7Bx`7D`7Bx coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7By`7D`7By coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7Bz`7D`7Bz coordinate`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns a structure representing X** the 3D point \pardesc`7B(x,y,z)`7D.`7D X*/ X`7B X Ppoint3 temp; X X temp.x = x; X temp.y = y; X temp.z = z; X return temp; X`7D /* ptk_point3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Pvector ptk_vector(C(Pfloat) x, C(Pfloat) y) XPreANSI(Pfloat x) XPreANSI(Pfloat y) X/* X** \parambegin X** \param`7BPfloat`7D`7Bx`7D`7Bx coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7By`7D`7By coordinate`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns a structure representing X** the 2D vector \pardesc`7B(x,y)`7D.`7D X*/ X`7B X Pvector temp; X X temp.x = x; X temp.y = y; X return temp; X`7D /* ptk_vector */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Pvector3 ptk_vector3(C(Pfloat) x, C(Pfloat) y, C(Pfloat) z) XPreANSI(Pfloat x) XPreANSI(Pfloat y) XPreANSI(Pfloat z) X/* X** \parambegin X** \param`7BPfloat`7D`7Bx`7D`7Bx coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7By`7D`7By coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7Bz`7D`7Bz coordinate`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns a structure representing X** the 3D vector \pardesc`7B(x,y,z)`7D.`7D X*/ X`7B X Pvector3 temp; X X temp.x = x; X temp.y = y; X temp.z = z; X return temp; X`7D /* ptk_vector3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Plimit ptk_limit(C(Pfloat) xmin, C(Pfloat) xmax, C(Pfloat) ymin, X C(Pfloat) ymax) XPreANSI(Pfloat xmin) XPreANSI(Pfloat xmax) XPreANSI(Pfloat ymin) XPreANSI(Pfloat ymax) X/* X** \parambegin X** \param`7BPfloat`7D`7Bxmin`7D`7Bminimum x coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7Bxmax`7D`7Bmaximum x coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7Bymin`7D`7Bminimum y coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7Bymax`7D`7Bmaximum y coordinate`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns a structure representing the 2D X** rectangle whose corners are defined by \pardesc`7Bxmin, xmax, ymin, ymax` V7D.`7D X*/ X`7B X Plimit temp; X X temp.xmin = xmin; X temp.xmax = xmax; X temp.ymin = ymin; X temp.ymax = ymax; X return temp; X`7D /* ptk_limit */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Plimit3 ptk_limit3(C(Pfloat) xmin, C(Pfloat) xmax, C(Pfloat) ymin, X C(Pfloat) ymax, C(Pfloat) zmin, C(Pfloat) zmax) XPreANSI(Pfloat xmin) XPreANSI(Pfloat xmax) XPreANSI(Pfloat ymin) XPreANSI(Pfloat ymax) XPreANSI(Pfloat zmin) XPreANSI(Pfloat zmax) X/* X** \parambegin X** \param`7BPfloat`7D`7Bxmin`7D`7Bminimum x coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7Bxmax`7D`7Bmaximum x coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7Bymin`7D`7Bminimum y coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7Bymax`7D`7Bmaximum y coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7Bzmin`7D`7Bminimum z coordinate`7D`7BIN`7D X** \param`7BPfloat`7D`7Bzmax`7D`7Bmaximum z coordinate`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns a structure representing the`20 X** 3D volume defined by \pardesc`7Bxmin, xmax, ymin, ymax, zmin, zmax`7D.`7D X*/ X`7B X Plimit3 temp; X X temp.xmin = xmin; X temp.xmax = xmax; X temp.ymin = ymin; X temp.ymax = ymax; X temp.zmin = zmin; X temp.zmax = zmax; X return temp; X`7D /* ptk_limit3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Ppoint3 ptk_vec3topt3(C(Pvector3 *) vec) XPreANSI(Pvector3 *vec) X/* X** \parambegin X** \param`7BPvector3 *`7D`7Bvec`7D`7B3D vector`7D`7BIN`7D X** \paramend X** \blurb`7BThis function convert the 3D vector \pardesc`7Bvec`7D to a 3D po Vint.`7D X*/ X`7B X Ppoint3 temp; X X temp = ptk_point3(vec->x, vec->y, vec->z); X return temp; X`7D /* ptk_vec3topt3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Pvector3 ptk_pt3tovec3(C(Ppoint3 *) pt) XPreANSI(Ppoint3 *pt) X/* X** \parambegin X** \param`7BPpoint3 *`7D`7Bpt`7D`7B3D point`7D`7BIN`7D X** \paramend X** \blurb`7BThis function converts the 3D point \pardesc`7Bpt`7D to a 3D vec Vtor.`7D X*/ X`7B X Pvector3 temp; X X temp = ptk_vector3(pt->x, pt->y, pt->z); X return temp; X`7D /* ptk_pt3tovec3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Pfloat ptk_dotv3(C(Ppoint3 *) v1, C(Ppoint3 *) v2) XPreANSI(Ppoint3 *v1) XPreANSI(Ppoint3 *v2) X/* X** \parambegin X** \param`7BPpoint3 *`7D`7Bv1`7D`7B3D vector`7D`7BIN`7D X** \param`7BPpoint3 *`7D`7Bv2`7D`7B3D vector`7D`7BIN`7D X** \paramend X** \blurb`7BThis function evaluates the dot product of the X** two 3D vectors \pardesc`7Bv1`7D and`20 X** \pardesc`7Bv2`7D, returning it as the value of the function.`7D X*/ X`7B X return (v1->x * v2->x + v1->y * v2->y + v1->z * v2->z); X`7D /* ptk_dotv3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Pfloat ptk_dotv(C(Ppoint *) v1, C(Ppoint *) v2) XPreANSI(Ppoint *v1) XPreANSI(Ppoint *v2) X/* X** \parambegin X** \param`7BPpoint *`7D`7Bv1`7D`7B2D vector`7D`7BIN`7D X** \param`7BPpoint *`7D`7Bv2`7D`7B2D vector`7D`7BIN`7D X** \paramend X** \blurb`7BEvaluates the dot product of the two 2D vectors \pardesc`7Bv1`7D V and X** \pardesc`7Bv2`7D, returning it as the value of the function.`7D X*/ X`7B X return (v1->x * v2->x + v1->y * v2->y); X`7D /* ptk_dotv */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Ppoint3 ptk_crossv3(C(Ppoint3 *) v1, C(Ppoint3 *) v2) XPreANSI(Ppoint3 *v1) XPreANSI(Ppoint3 *v2) X/* X** \parambegin X** \param`7BPpoint3 *`7D`7Bv1`7D`7B3D vector`7D`7BIN`7D X** \param`7BPpoint3 *`7D`7Bv2`7D`7B3D vector`7D`7BIN`7D X** \paramend X** \blurb`7BThis function evaluates the cross product of X** the two 3D vectors \pardesc`7Bv1`7D and X** \pardesc`7Bv2`7D, returning the new vector as X** the function result. Since a local copy is made statements such as X** `7B\tt v2 == ptk\_crossv(v1, v2)`7D X** will produce the correct answer.`7D X*/ X`7B X Ppoint3 temp; X X temp.x = v1->y * v2->z - v1->z * v2->y; X temp.y = v1->z * v2->x - v1->x * v2->z; X temp.z = v1->x * v2->y - v1->y * v2->x; X return temp; X`7D /* ptk_crossv3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern ptkboolean ptk_nullv3(C(Ppoint3 *) vec) XPreANSI(Ppoint3 *vec) X/* X** \parambegin X** \param`7BPpoint3 *`7D`7Bvec`7D`7B3D vector`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns \pardesc`7BTRUE`7D if the modulus X** of the 3D vector\pardesc`7Bvec`7D`20 X** is less than the global tolerance \pardesc`7Bptkpceps`7D, otherwise`20 X** \pardesc`7BFALSE`7D.`7D X*/ X`7B X return (ptk_equal(vec->x, 0.0) && ptk_equal(vec->y, 0.0) && X`09 ptk_equal(vec->z, 0.0)); X`7D /* ptk_nullv3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern ptkboolean ptk_nullv(C(Ppoint *) vec) XPreANSI(Ppoint *vec) X/* X** \parambegin X** \param`7BPpoint *`7D`7Bvec`7D`7B2D vector`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns \pardesc`7BTRUE`7D if the X** modulus of the 2D vector \pardesc`7Bvec`7D`20 X** is less than the global tolerance \pardesc`7Bptkpceps`7D, otherwise`20 X** \pardesc`7BFALSE`7D.`7D X*/ X`7B X return (ptk_equal(vec->x, 0.0) && ptk_equal(vec->y, 0.0)); X`7D /* ptk_nullv */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Pfloat ptk_modv3(C(Ppoint3 *) vec) XPreANSI(Ppoint3 *vec) X/* X** \parambegin X** \param`7BPpoint3 *`7D`7Bvec`7D`7B3D vector`7D`7BIN`7D X** \paramend X** \blurb`7BReturns the modulus of the vector \pardesc`7Bvec`7D.`7D X*/ X`7B X return sqrt(vec->x * vec->x + vec->y * vec->y + vec->z * vec->z); X`7D /* ptk_modv3 */ X X/*-------------------------------------------------------------------------* V/ X X/*function:external*/ Xextern Pfloat ptk_modv(C(Ppoint *) vec) XPreANSI(Ppoint *vec) X/* X** \parambegin X** \param`7BPpoint *`7D`7Bvec`7D`7B2D vector`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns the modulus of the 2D vector \pardesc`7Bve Vc`7D.`7D X*/ X`7B X return sqrt(vec->x * vec->x + vec->y * vec->y); X`7D /* ptk_modv */ X X/*-------------------------------------------------------------------------* V/ X X/*function:external*/ Xextern Ppoint3 ptk_unitv3(C(Ppoint3 *) vec) XPreANSI(Ppoint3 *vec) X/* X** \parambegin X** \param`7BPpoint3 *`7D`7Bvec`7D`7B3D vector`7D`7BIN`7D X** \paramend X** \blurb`7BThis function generates and returns a unit X** vector from the supplied 3D vector`20 X** \pardesc`7Bvec`7D.`7D X*/ X`7B X Pfloat modu; X Ppoint3 temp; X X modu = ptk_modv3(vec); X if (!ptk_equal(modu, 0.0))`20 X `7B X temp = ptk_point3(vec->x / modu, vec->y / modu, vec->z / modu); X return temp; X `7D`20 X else`20 X `7B X temp = ptk_point3(0.0, 0.0, 0.0); X return temp; X `7D X`7D /* ptk_unitv3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern Ppoint ptk_unitv(C(Ppoint *) vec) XPreANSI(Ppoint *vec) X/* +-+-+-+-+-+-+-+- END OF PART 261 +-+-+-+-+-+-+-+-