-+-+-+-+-+-+-+-+ START OF PART 267 -+-+-+-+-+-+-+-+
X** \param`7BPpoint3 *`7D`7Bq3`7D`7B3D point`7D`7BIN`7D
X** \param`7BPcomptype`7D`7Boperation`7D`7Bconcatenation operation`7D`7BIN`7D
X** \param`7BPmatrix3`7D`7Bmatrix`7D`7B4x4 matrix`7D`7BOUT`7D
X** \param`7BPint *`7D`7Berror`7D`7Berror code`7D`7BOUT`7D
X** \paramend
X** \blurb`7BThis function returns the 3 point to 3 point transformation as
X** described in \cite`7Bmort:geom`7D, pages 353--355.
X** The transformation has the following properties:
X** \pardesc`7Bp1`7D is transformed onto \pardesc`7Bq1`7D;
X** the vector \pardesc`7B(p2-p1)`7D is transformed to be parallel to the vec
Vtor`20
X** \pardesc`7B(q2-q1)`7D;
X** the plane containing the three points \pardesc`7Bp1, p2, p3`7D is
X** transformed into  the plane containing \pardesc`7Bq1, q2, q3`7D.
X** The transformation is concatenated with the $4 \times 4$ matrix
X** \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperation`7D.
X** If the parameters are invalid, \pardesc`7Berror`7D is set to`20
X** -1. Otherwise, its value is \pardesc`7Bptkcpcok`7D.`7D
X*/
X`7B
X  Pmatrix3 tempmat, invvmatrix, wmatrix;
X  Ppoint3 v1, v2, v3, w1, w2, w3, temp;
X
X  /* form 2 right-hand orthogonal systems from the given points */
X  *error = ptkcpcok;
X  v1 = ptk_subv3(p2, p1);
X  v1 = ptk_unitv3(&v1);
X  v3 = ptk_subv3(p3, p1);
X  v3 = ptk_crossv3(&v1, &v3);
X  v3 = ptk_unitv3(&v3);
X  v2 = ptk_crossv3(&v3, &v1);
X  v2 = ptk_unitv3(&v2);
X  temp = ptk_subv3(q2, q1);
X  w1 = ptk_unitv3(&temp);
X  temp = ptk_subv3(q3, q1);
X  temp = ptk_crossv3(&w1, &temp);
X  w3 = ptk_unitv3(&temp);
X  temp = ptk_crossv3(&w3, &w1);
X  w2 = ptk_unitv3(&temp);
X
X  /* if any of v1..v3, w1..w3 are null vectors then the parameters are`20
X  ** invalid.
X  */
X  if (ptk_nullv3(&v1) `7C`7C ptk_nullv3(&v2) `7C`7C ptk_nullv3(&v3) `7C`7C`2
V0
X      ptk_nullv3(&w1) `7C`7C ptk_nullv3(&w2) `7C`7C ptk_nullv3(&w3))`20
X  `7B
X    *error = -1;
X    return;
X  `7D
X  *error = ptkcpcok;
X  ptk_unitmatrix3(invvmatrix);
X  invvmatrix`5B0`5D`5B0`5D = v1.x;
X  invvmatrix`5B0`5D`5B1`5D = v1.y;
X  invvmatrix`5B0`5D`5B2`5D = v1.z;
X  invvmatrix`5B1`5D`5B0`5D = v2.x;
X  invvmatrix`5B1`5D`5B1`5D = v2.y;
X  invvmatrix`5B1`5D`5B2`5D = v2.z;
X  invvmatrix`5B2`5D`5B0`5D = v3.x;
X  invvmatrix`5B2`5D`5B1`5D = v3.y;
X  invvmatrix`5B2`5D`5B2`5D = v3.z;
X  ptk_unitmatrix3(wmatrix);
X  wmatrix`5B0`5D`5B0`5D = w1.x;
X  wmatrix`5B1`5D`5B0`5D = w1.y;
X  wmatrix`5B2`5D`5B0`5D = w1.z;
X  wmatrix`5B0`5D`5B1`5D = w2.x;
X  wmatrix`5B1`5D`5B1`5D = w2.y;
X  wmatrix`5B2`5D`5B1`5D = w2.z;
X  wmatrix`5B0`5D`5B2`5D = w3.x;
X  wmatrix`5B1`5D`5B2`5D = w3.y;
X  wmatrix`5B2`5D`5B2`5D = w3.z;
X
X  /* shift points at origin onto q1 */
X
X  ptk_shift3(q1, PREPLACE, tempmat);
X  ptk_concatenatematrix3(PPRECONCATENATE, wmatrix, wmatrix, tempmat);
X  ptk_concatenatematrix3(PPRECONCATENATE, invvmatrix, tempmat, tempmat);
X
X  /* shift p1 to origin */
X  temp = ptk_scalev3(p1, -1.0);
X  ptk_shift3(&temp, PPRECONCATENATE, tempmat);
X  ptk_concatenatematrix3(operation, tempmat, matrix, matrix);
X`7D  /* ptk_3ptto3pt */
X
X/*--------------------------------------------------------------------------
V*/
X
X/*function:external*/
Xextern void ptk_0to3pt(C(Ppoint3 *) origin, C(Ppoint3 *) xdirn,`20
X              C(Ppoint3 *) ydirn, C(Pcomptype) operation, C(Pmatrix3) matrix
V)
XPreANSI(Ppoint3 *origin)
XPreANSI(Ppoint3 *xdirn)
XPreANSI(Ppoint3 *ydirn)`20
XPreANSI(Pcomptype operation)
XPreANSI(Pmatrix3 matrix)
X/*
X** \parambegin
X** \param`7BPpoint3 *`7D`7Borigin`7D`7Borigin of axes`7D`7BIN`7D
X** \param`7BPpoint3 *`7D`7Bxdirn`7D`7Bx direction`7D`7BIN`7D
X** \param`7BPpoint3 *`7D`7By dirn`7D`7By direction`7D`7BIN`7D
X** \param`7BPcomptype`7D`7Boperation`7D`7Bconcatenation operation`7D`7BIN`7D
X** \param`7BPmatrix3`7D`7Bmatrix`7D`7B4x4 matrix`7D`7BOUT`7D
X** \paramend
X** \blurb`7BThis function computes an object transformation which
X** maps unit vectors`20
X** along the $x$, $y$ and $z$ axes onto unit vectors along the
X** corresponding axes`20
X** of the new coordinate system.`7D
X*/
X`7B
X  Ppoint3 xaxis, yaxis, zaxis;
X  Pmatrix3 objectxform;
X
X  /* A new coordinate system is defined, centred at origin, its x-axis
X  ** parallel to xdirn and the y-axis parallel to the component of ydirn
X  ** which is perpendicular to the x-axis. The transformation matrix returne
Vd
X  ** is an object transformation.
X  */
X
X  /* work out unit vectors along the axes of new coordinate system */
X
X  xaxis = ptk_unitv3(xdirn);
X  zaxis = ptk_crossv3(&xaxis, ydirn);
X  zaxis = ptk_unitv3(&zaxis);
X  yaxis = ptk_crossv3(&zaxis, &xaxis);
X  yaxis = ptk_unitv3(&yaxis);
X
X  /* form matrices - see "An Implementation of the GKS-3D/PHIGS Viewing
X  ** Pipeline" for the maths.`20
X  */
X
X  ptk_unitmatrix3(objectxform);
X  objectxform`5B0`5D`5B0`5D = xaxis.x;
X  objectxform`5B1`5D`5B0`5D = xaxis.y;
X  objectxform`5B2`5D`5B0`5D = xaxis.z;
X  objectxform`5B0`5D`5B1`5D = yaxis.x;
X  objectxform`5B1`5D`5B1`5D = yaxis.y;
X  objectxform`5B2`5D`5B1`5D = yaxis.z;
X  objectxform`5B0`5D`5B2`5D = zaxis.x;
X  objectxform`5B1`5D`5B2`5D = zaxis.y;
X  objectxform`5B2`5D`5B2`5D = zaxis.z;
X  objectxform`5B0`5D`5B3`5D = origin->x;
X  objectxform`5B1`5D`5B3`5D = origin->y;
X  objectxform`5B2`5D`5B3`5D = origin->z;
X  ptk_concatenatematrix3(operation, objectxform, matrix, matrix);
X
X  /* To output text, call above procedure to get the character plane`20
X  ** transformation:
X  **
X  **  ptk_0to3pt( text_point, text_direction_vector_1,
X  **             text_direction_vector_2, PVReplacematrix,char_plane_xform)
X  **
X  ** As each point of the text is output, transform it by:
X  **
X  **  output_pipeline . char_plane_xform`20
X  */
X`7D  /* ptk_0to3pt */
X
X/*--------------------------------------------------------------------------
V-*/
X
X/*function:external*/
Xextern void ptk_oto3pt(C(Ppoint3 *) origin, C(Ppoint3 *) xdirn,`20
X             C(Ppoint3 *) ydirn, C(Pcomptype) operation, C(Pmatrix3) matrix)
XPreANSI(Ppoint3 *origin)
XPreANSI(Ppoint3 *xdirn)
XPreANSI(Ppoint3 *ydirn)`20
XPreANSI(Pcomptype operation)
XPreANSI(Pmatrix3 matrix)
X/*
X** \parambegin
X** \param`7BPpoint3 *`7D`7Borigin`7D`7Borigin of axes`7D`7BIN`7D
X** \param`7BPpoint3 *`7D`7Bxdirn`7D`7Bx direction`7D`7BIN`7D
X** \param`7BPpoint3 *`7D`7By dirn`7D`7By direction`7D`7BIN`7D
X** \param`7BPcomptype`7D`7Boperation`7D`7Bconcatenation operation`7D`7BIN`7D
X** \param`7BPmatrix3`7D`7Bmatrix`7D`7B4x4 matrix`7D`7BOUT`7D
X** \paramend
X** \blurb`7BThis function performs the same operation as
X**  \pardesc`7Bptk\_0to3pt`7D, except the name has an \pardesc`7Bo`7D\`20
X** (oh) instead of \pardesc`7B0`7D\ (zero). This function is provided for me
Vmbers
X** of the Fumbly Fingers Club.`7D
X*/
X`7B
X  ptk_0to3pt(origin, xdirn, ydirn, operation, matrix);
X`7D  /* ptk_oto3pt */
X
X/*--------------------------------------------------------------------------
V*/
X
X/*function:external*/
Xextern void ptk_invertmatrix3(C(Pmatrix3) a, C(Pmatrix3) ainverse,`20
X                              C(Pint *)error)
XPreANSI(Pmatrix3 a)
XPreANSI(Pmatrix3 ainverse)
XPreANSI(Pint *error)
X/*
X** \parambegin
X** \param`7BPmatrix3`7D`7Ba`7D`7B4x4 matrix`7D`7BIN`7D
X** \param`7BPmatrix3`7D`7Bainverse`7D`7B4x4 matrix`7D`7BOUT`7D
X** \param`7BPint *`7D`7Berror`7D`7Berror code`7D`7BOUT`7D
X** \paramend
X** \blurb`7BThis function computes the inverse of the $4 \times 4$
X** matrix \pardesc`7Ba`7D,`20
X** returning the result in \pardesc`7Bainverse`7D.`20
X** If matrix \pardesc`7Ba`7D is singular, then`20
X** \pardesc`7Berror`7D is set to $-1$, and \pardesc`7Bainverse`7D is undefin
Ved,
X** otherwise \pardesc`7Berror`7D is set to \pardesc`7Bptkcpcok`7D.
X** This function uses Crout's method, a modification of Gaussian
X** elimination.`7D
X*/
X`7B
X  Pfloat b`5B4`5D, c`5B4`5D;
X  Pfloat w, y;
X  Pint z`5B4`5D;
X  Pint i, j, k, l, p;
X
X  *error = -1;
X  memcpy(ainverse, a, sizeof(Pmatrix3));
X  for (j = 1; j <= 4; j++)
X    z`5Bj - 1`5D = j;
X  for (i = 1; i <= 4; i++)`20
X  `7B
X    k = i;
X    y = ainverse`5Bi - 1`5D`5Bi - 1`5D;
X    l = i - 1;
X    p = i + 1;
X    for (j = p; j <= 4; j++)`20
X    `7B
X      w = ainverse`5Bi - 1`5D`5Bj - 1`5D;
X      if (fabs(w) > fabs(y))`20
X      `7B
X`09k = j;
X`09y = w;
X      `7D
X    `7D
X    if (ptk_equal(y, 0.0))   /* matrix has no inverse */
X      return;
X    y = 1.0 / y;
X    for (j = 0; j <= 3; j++)`20
X    `7B
X      c`5Bj`5D = ainverse`5Bj`5D`5Bk - 1`5D;
X      ainverse`5Bj`5D`5Bk - 1`5D = ainverse`5Bj`5D`5Bi - 1`5D;
X      ainverse`5Bj`5D`5Bi - 1`5D = -c`5Bj`5D * y;
X      ainverse`5Bi - 1`5D`5Bj`5D *= y;
X      b`5Bj`5D = ainverse`5Bi - 1`5D`5Bj`5D;
X    `7D
X    ainverse`5Bi - 1`5D`5Bi - 1`5D = y;
X    j = z`5Bi - 1`5D;
X    z`5Bi - 1`5D = z`5Bk - 1`5D;
X    z`5Bk - 1`5D = j;
X    for (k = 0; k < l; k++)`20
X    `7B
X      for (j = 0; j < l; j++)
X`09ainverse`5Bk`5D`5Bj`5D -= b`5Bj`5D * c`5Bk`5D;
X      for (j = p - 1; j <= 3; j++)
X`09ainverse`5Bk`5D`5Bj`5D -= b`5Bj`5D * c`5Bk`5D;
X    `7D
X    for (k = p - 1; k <= 3; k++)`20
X    `7B
X      for (j = 0; j < l; j++)
X`09ainverse`5Bk`5D`5Bj`5D -= b`5Bj`5D * c`5Bk`5D;
X      for (j = p - 1; j <= 3; j++)
X`09ainverse`5Bk`5D`5Bj`5D -= b`5Bj`5D * c`5Bk`5D;
X    `7D
X  `7D
X  for (i = 0; i <= 3; i++)`20
X  `7B
X    do`20
X    `7B
X      k = z`5Bi`5D;
X      if (k != i + 1)`20
X      `7B
X`09for (j = 0; j <= 3; j++)`20
X        `7B
X`09  w = ainverse`5Bi`5D`5Bj`5D;
X`09  ainverse`5Bi`5D`5Bj`5D = ainverse`5Bk - 1`5D`5Bj`5D;
X`09  ainverse`5Bk - 1`5D`5Bj`5D = w;
X`09`7D
X`09p = z`5Bi`5D;
X`09z`5Bi`5D = z`5Bk - 1`5D;
X`09z`5Bk - 1`5D = p;
X      `7D
X    `7D while (k != i + 1);
X  `7D
X  *error = ptkcpcok;
X`7D  /* ptk_invertmatrix3 */
X
X/*--------------------------------------------------------------------------
V*/
X
X/*function:external*/
Xextern void ptk_invertmatrix(C(Pmatrix) a, C(Pmatrix) ainverse,`20
X                              C(Pint *) error)
XPreANSI(Pmatrix a)
XPreANSI(Pmatrix ainverse)
XPreANSI(Pint *error)
X/*
X** \parambegin
X** \param`7BPmatrix`7D`7Ba`7D`7B3x3 matrix`7D`7BIN`7D
X** \param`7BPmatrix`7D`7Bainverse`7D`7B3x3 matrix`7D`7BOUT`7D
X** \param`7BPint *`7D`7Berror`7D`7Berror code`7D`7BOUT`7D
X** \paramend
X** \blurb`7BThis function computes the inverse of the $3 \times 3$
X** matrix \pardesc`7Ba`7D,`20
X** returning the result in \pardesc`7Bainverse`7D.`20
X** If matrix \pardesc`7Ba`7D is singular, then`20
X** \pardesc`7Berror`7D is set to $-1$, and \pardesc`7Bainverse`7D is undefin
Ved,
X** otherwise \pardesc`7Berror`7D is set to \pardesc`7Bptkcpcok`7D.
X** This function uses Crout's method, a modification of Gaussian
X** elimination.`7D
X*/
X`7B
X  Pfloat b`5B3`5D, c`5B3`5D;
X  Pfloat w, y;
X  Pint z`5B3`5D;
X  Pint i, j, k, l, p;
X
X  *error = -1;
X  memcpy(ainverse, a, sizeof(Pmatrix));
X  for (j = 1; j <= 3; j++)
X    z`5Bj - 1`5D = j;
X  for (i = 1; i <= 3; i++)`20
X  `7B
X    k = i;
X    y = ainverse`5Bi - 1`5D`5Bi - 1`5D;
X    l = i - 1;
X    p = i + 1;
X    for (j = p; j <= 3; j++)`20
X    `7B
X      w = ainverse`5Bi - 1`5D`5Bj - 1`5D;
X      if (fabs(w) > fabs(y))`20
X      `7B
X`09k = j;
X`09y = w;
X      `7D
X    `7D
X    if (ptk_equal(y, 0.0))   /* matrix has no inverse */
X      return;
X    y = 1.0 / y;
X    for (j = 0; j <= 2; j++)`20
X    `7B
X      c`5Bj`5D = ainverse`5Bj`5D`5Bk - 1`5D;
X      ainverse`5Bj`5D`5Bk - 1`5D = ainverse`5Bj`5D`5Bi - 1`5D;
X      ainverse`5Bj`5D`5Bi - 1`5D = -c`5Bj`5D * y;
X      ainverse`5Bi - 1`5D`5Bj`5D *= y;
X      b`5Bj`5D = ainverse`5Bi - 1`5D`5Bj`5D;
X    `7D
X    ainverse`5Bi - 1`5D`5Bi - 1`5D = y;
X    j = z`5Bi - 1`5D;
X    z`5Bi - 1`5D = z`5Bk - 1`5D;
X    z`5Bk - 1`5D = j;
X    for (k = 0; k < l; k++)`20
X    `7B
X      for (j = 0; j < l; j++)
X`09ainverse`5Bk`5D`5Bj`5D -= b`5Bj`5D * c`5Bk`5D;
X      for (j = p - 1; j <= 2; j++)
X`09ainverse`5Bk`5D`5Bj`5D -= b`5Bj`5D * c`5Bk`5D;
X    `7D
X    for (k = p - 1; k <= 2; k++)`20
X    `7B
X      for (j = 0; j < l; j++)
X`09ainverse`5Bk`5D`5Bj`5D -= b`5Bj`5D * c`5Bk`5D;
X      for (j = p - 1; j <= 2; j++)
X`09ainverse`5Bk`5D`5Bj`5D -= b`5Bj`5D * c`5Bk`5D;
X    `7D
X  `7D
X  for (i = 0; i <= 2; i++)`20
X  `7B
X    do`20
X    `7B
X      k = z`5Bi`5D;
X      if (k != i + 1)`20
X      `7B
X`09for (j = 0; j <= 2; j++)`20
X        `7B
X`09  w = ainverse`5Bi`5D`5Bj`5D;
X`09  ainverse`5Bi`5D`5Bj`5D = ainverse`5Bk - 1`5D`5Bj`5D;
X`09  ainverse`5Bk - 1`5D`5Bj`5D = w;
X`09`7D
X`09p = z`5Bi`5D;
X`09z`5Bi`5D = z`5Bk - 1`5D;
X`09z`5Bk - 1`5D = p;
X      `7D
X    `7D while (k != i + 1);
X  `7D
X  *error = ptkcpcok;
X`7D  /* ptk_invertmatrix */
X
X/*--------------------------------------------------------------------------
V*/
X
X/* end of tran.c */
$ CALL UNPACK [.SOURCE.LIBRARY]TRAN.C;3 1657603964
$ create 'f'
X/*--------------------------------------------------------------------------
V--
X
X  Module name: traversal state list module.
X
X  Author: Gareth Williams.
X
X  Function: This module contains functions for inquiring information
X            from the PHIGS Traversal State List.
X
X  Dependencies:`20
X
X  Internal function list: traversestruct, box
X
X  External function list: ptk_boundingbox
X
X  Hashtables used: none.
X
X  Modification history: (Version), (Date), (name), (Description).
X
X  1.0, 4th September 1991, G. Williams, First version.
X
X----------------------------------------------------------------------------
V*/
X
X#include <stdio.h>
X#include <math.h>
X#include <phigs.h>
X#include "ptk.h"
X
X/*--------------------------------------------------------------------------
V*/
X
Xtypedef struct ptkstsl
X`7B
X  Plnattr lnattr;
X  Pmkattr mkattr;
X  Pinterattr interattr;
X  Pedgeattr edgeattr;
X  Pasf edgetypeasf;
X  Ptxbundl txbundl;
X  Pint textindex;
X  Pasf textfontasf;
X  Pasf textprecasf;
X  Pasf charexpanasf;
X  Pasf charspaceasf;
X  Pasf textcolourasf;
X  Pfloat charheight;
X  Ppoint charup;
X  Ptxpath textpath;
X  Ptxalign textalign;
X  Pfloat annocharheight;
X  Ppoint annocharup;
X  Ptxpath annotextpath;
X  Ptxalign annotextalign;
X  Pint annostyle;
X  Ppoint patsize;
X  Ppoint3 patrefpt;
X  Ppoint3 patvec`5B2`5D;
X  Pint pickid;
X  Pint viewindex;
X  Pint hlhsrid;
X  Pintlst nameset;
X  Pint names`5B100`5D;
X  Pmatrix3 globaltran;
X  Pmatrix3 localtran;
X#ifdef SUN
X  Pint modelclipoperator;
+-+-+-+-+-+-+-+-  END  OF PART 267 +-+-+-+-+-+-+-+-