-+-+-+-+-+-+-+-+ START OF PART 266 -+-+-+-+-+-+-+-+ X ** of orthogonal axes denoted by uaxis, vaxis, naxis`20 X */ X naxis = ptk_unitv3(viewplanenormal); X uaxis = ptk_unitv3(&vuvxvpn); X vaxis = ptk_crossv3(&naxis, &uaxis); X vaxis = ptk_unitv3(&vaxis); X /* form view orientation matrix */ X ptk_unitmatrix3(temp); X temp`5B0`5D`5B0`5D = uaxis.x; X temp`5B0`5D`5B1`5D = uaxis.y; X temp`5B0`5D`5B2`5D = uaxis.z; X temp`5B0`5D`5B3`5D = -(uaxis.x * viewrefpoint->x + uaxis.y *`20 X viewrefpoint->y + uaxis.z * viewrefpoint->z); X temp`5B1`5D`5B0`5D = vaxis.x; X temp`5B1`5D`5B1`5D = vaxis.y; X temp`5B1`5D`5B2`5D = vaxis.z; X temp`5B1`5D`5B3`5D = -(vaxis.x * viewrefpoint->x + vaxis.y *`20 X viewrefpoint->y + vaxis.z * viewrefpoint->z); X temp`5B2`5D`5B0`5D = naxis.x; X temp`5B2`5D`5B1`5D = naxis.y; X temp`5B2`5D`5B2`5D = naxis.z; X temp`5B2`5D`5B3`5D = -(naxis.x * viewrefpoint->x + naxis.y *`20 X viewrefpoint->y + naxis.z * viewrefpoint->z); X ptk_concatenatematrix3(operation, temp, matrix, matrix); X`7D /* ptk_evalvieworientation3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_evalvieworientation(C(Ppoint *) viewrefpoint,`20 X`09`09`09`09 C(Ppoint *) viewupvector,`20 X C(Pcomptype) operation,`20 X C(Pmatrix) matrix, C(Pint *)error) XPreANSI(Ppoint *viewrefpoint) XPreANSI(Ppoint *viewupvector) XPreANSI(Pcomptype operation)`20 XPreANSI(Pmatrix matrix) XPreANSI(Pint *error) X/* X** \parambegin X** \param`7BPpoint *`7D`7Bviewrefpoint`7D`7Bview reference point`7D`7BIN`7D X** \param`7BPpoint *`7D`7Bviewupvector`7D`7Bview up vector`7D`7BIN`7D X** \param`7BPcomptype`7D`7Boperation`7D`7Bconcatenation operation`7D`7BIN`7D X** \param`7BPmatrix`7D`7Bmatrix`7D`7B3x3 matrix`7D`7BOUT`7D X** \param`7BPint *`7D`7Berror`7D`7Berror code`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function computes`20 X** a 2D PHIGS view orientation matrix on the basis of X** a specified view reference point (\pardesc`7Bviewrefpoint`7D) X** and a view up vector X** (\pardesc`7Bviewupvector`7D). If the function succeeds, X** \pardesc`7Berror`7D is set to \pardesc`7Bptkcpcok`7D. Otherwise,`20 X** \pardesc`7Berror`7D is 63 if the view up vector is null.`7D X*/ X`7B X Ppoint3 uaxis, vaxis, naxis, vuvxvpn; X Pmatrix temp; X X *error = ptkcpcok; X if (ptk_nullv(viewupvector))`20 X `7B X *error = 63; X `7D`20 X if (*error != ptkcpcok)`20 X `7B X return; X `7D /* if error = 0 */ X /* generate from viewplanenormal and viewupvector a set X ** of orthogonal axes denoted by uaxis, vaxis, naxis`20 X */ X naxis = ptk_point3(0.0, 0.0, 1.0); X vaxis = ptk_point3(viewupvector->x, viewupvector->y, 0.0); X vaxis = ptk_unitv3(&vaxis); X/* uaxis = ptk_crossv3(naxis, vaxis); */ X uaxis = ptk_unitv3(&uaxis); X /* form view orientation matrix */ X ptk_unitmatrix(temp); X temp`5B0`5D`5B0`5D = uaxis.x; X temp`5B0`5D`5B1`5D = uaxis.y; X temp`5B0`5D`5B2`5D = uaxis.z; X/* temp`5B0`5D`5B3`5D = -(uaxis.x * viewrefpoint->x + uaxis.y * viewrefpoin Vt->y); */ X temp`5B1`5D`5B0`5D = vaxis.x; X temp`5B1`5D`5B1`5D = vaxis.y; X temp`5B1`5D`5B2`5D = 0.0; X/* temp`5B1`5D`5B3`5D = -(vaxis.x * viewrefpoint->x + vaxis.y * viewrefpoin Vt->y); */ X temp`5B2`5D`5B0`5D = naxis.x; X temp`5B2`5D`5B1`5D = naxis.y; X temp`5B2`5D`5B2`5D = naxis.z; X ptk_concatenatematrix(operation, temp, matrix, matrix); X`7D /* ptk_evalvieworientation */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_evalviewmapping3(C(Plimit3 *) wlimits, C(Plimit3 *) vlimits, V`20 X C(Pprojtype) viewtype,`20 X C(Ppoint3 *) refpoint, C(Pfloat) vplanedist, V`20 X C(Pcomptype) operation, C(Pmatrix3) matrix,` V20 X C(Pint *)error) XPreANSI(Plimit3 *wlimits) XPreANSI(Plimit3 *vlimits)`20 XPreANSI(Pprojtype viewtype)`20 XPreANSI(Ppoint3 *refpoint) XPreANSI(Pfloat vplanedist)`20 XPreANSI(Pcomptype operation) XPreANSI(Pmatrix3 matrix)`20 XPreANSI(Pint *error) X/* X** \parambegin X** \param`7BPlimit3 *`7D`7Bwlimits`7D`7Bwindow limits`7D`7BIN`7D X** \param`7BPlimit3 *`7D`7Bvlimits`7D`7Bviewport limits`7D`7BIN`7D X** \param`7BPprojtype`7D`7Bviewtype`7D`7Bprojection type`7D`7BIN`7D X** \param`7BPpoint3 *`7D`7Brefpoint`7D`7Bprojection reference point`7D`7BIN` V7D X** \param`7BPfloat`7D`7Bvplanedist`7D`7Bview plane distance`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 evaluates a 3D PHIGS view mapping matrix. X** If the function succeeds, X** \pardesc`7Berror`7D is set to \pardesc`7Bptkcpcok`7D. Otherwise,`20 X** \pardesc`7Berror`7D is`20 X** 329 if the window limits are not valid, X** 336 if the back plane is in front of front plane, X** 330 if the viewport limits are not valid, X** 335 if the projection reference point is on the view plane, X** and 340 if the projection reference point is between front and back plane Vs.`7D X*/ X`7B X Ppoint3 projectordirn, viewwindowcentre, vref; X Pmatrix3 temp; X Plimit3 templim; X Pint err; X X templim = *wlimits; X *error = ptkcpcok; X /* check for valid window limits */ X if (templim.xmin >= templim.xmax `7C`7C X templim.ymin >= templim.ymax)`20 X `7B X *error = 329; X return; X `7D X /* check that back plane is not in front of front plane */ X if (templim.zmin >= templim.zmax)`20 X `7B X *error = 336; X return; X `7D X /* check for valid viewport limits */ X if (!validbounds3(vlimits))`20 X `7B X *error = 330; X return; X `7D X /* check that PRP not positioned on the view plane */ X if (ptk_equal(refpoint->z, vplanedist))`20 X `7B X *error = 335; X return; X `7D X /* check that PRP not between the front and back planes */ X if (refpoint->z < templim.zmax && refpoint->z > templim.zmin)`20 X `7B X *error = 340; X return; X `7D X /* if everything is OK error is set to zero and a value computed for`20 X ** matrix. X */ X *error = ptkcpcok; X ptk_unitmatrix3(temp); X switch (viewtype)`20 X `7B X case PPERSPECTIVE: X temp`5B0`5D`5B0`5D = refpoint->z - vplanedist; X temp`5B0`5D`5B2`5D = -refpoint->x; X temp`5B0`5D`5B3`5D = refpoint->x * vplanedist; X temp`5B1`5D`5B0`5D = 0.0; X temp`5B1`5D`5B1`5D = refpoint->z - vplanedist; X temp`5B1`5D`5B2`5D = -refpoint->y; X temp`5B1`5D`5B3`5D = refpoint->y * vplanedist; X temp`5B2`5D`5B2`5D = 0.0; X temp`5B2`5D`5B3`5D = 1.0; X temp`5B3`5D`5B2`5D = -1.0; X temp`5B3`5D`5B3`5D = refpoint->z; X break; X X case PPARALLEL: X viewwindowcentre.x = (templim.xmin + templim.xmax) / 2; X viewwindowcentre.y = (templim.ymin + templim.ymax) / 2; X viewwindowcentre.z = vplanedist; X projectordirn = ptk_subv3(refpoint, &viewwindowcentre); X projectordirn = ptk_scalev3(&projectordirn,`20 X 1.0 / (refpoint->z - vplanedist)); X temp`5B0`5D`5B2`5D = -projectordirn.x; X temp`5B0`5D`5B3`5D = vplanedist * projectordirn.x; X temp`5B1`5D`5B2`5D = -projectordirn.y; X temp`5B1`5D`5B3`5D = vplanedist * projectordirn.y; X break; X `7D X /* The z coordinate is unchanged by the transformation matrix above for X ** parallel projection types and changed for perspective projection X ** types. Different action is therefore required in each case so that X ** points at the front and back planes are always mapped onto points at X ** the front and back of the projection viewport`20 X */ X if (viewtype == PPERSPECTIVE)`20 X `7B X templim.zmin = 1.0 / (refpoint->z - templim.zmin); X templim.zmax = 1.0 / (refpoint->z - templim.zmax); X `7D X ptk_box3tobox3(&templim, vlimits, FALSE, PPOSTCONCATENATE, temp, &err); X ptk_concatenatematrix3(operation, temp, matrix, matrix); X`7D /* ptk_evalviewmapping3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_evalviewmapping(C(Plimit *) wlimits, C(Plimit *) vlimits,`20 X C(Pcomptype) operation, C(Pmatrix) matrix,`2 V0 X C(Pint *)error) XPreANSI(Plimit *wlimits) XPreANSI(Plimit *vlimits)`20 XPreANSI(Pcomptype operation) XPreANSI(Pmatrix matrix)`20 XPreANSI(Pint *error) X/* X** \parambegin X** \param`7BPlimit *`7D`7Bwlimits`7D`7Bwindow limits`7D`7BIN`7D X** \param`7BPlimit *`7D`7Bvlimits`7D`7Bviewport limits`7D`7BIN`7D X** \param`7BPcomptype`7D`7Boperation`7D`7Bconcatenation operation`7D`7BIN`7D X** \param`7BPmatrix`7D`7Bmatrix`7D`7B3x3 matrix`7D`7BOUT`7D X** \param`7BPint *`7D`7Berror`7D`7Berror code`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function evaluates a 2d PHIGS view mapping matrix. X** If the function succeeds, X** \pardesc`7Berror`7D is set to \pardesc`7Bptkcpcok`7D. Otherwise,`20 X** \pardesc`7Berror`7D is X** 329 if the window limits are not valid, X** and 330 if the viewport limits are not valid.`7D X*/ X`7B X Pmatrix temp; X Pint err; X X *error = ptkcpcok; X /* check for valid window limits */ X if (wlimits->xmin >= wlimits->xmax `7C`7C X wlimits->ymin >= wlimits->ymax)`20 X `7B X *error = 329; X return; X `7D X /* check for valid viewport limits */ X if (!validbounds(vlimits))`20 X `7B X *error = 330; X return; X `7D X /* if everything is OK error is set to zero and a value computed for`20 X ** matrix. X */ X *error = ptkcpcok; X ptk_unitmatrix(temp); X ptk_boxtobox(wlimits, vlimits, FALSE, PPOSTCONCATENATE, temp, &err); X ptk_concatenatematrix(operation, temp, matrix, matrix); X`7D /* ptk_evalviewmapping */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_stackmatrix3(C(Pmatrix3) matrix) XPreANSI(Pmatrix3 matrix) X/* X** \parambegin X** \param`7BPmatrix3`7D`7Bmatrix`7D`7B4x4 matrix`7D`7BIN`7D X** \paramend X** \blurb`7BThis function pushes X** the $4 \times 4$ matrix \pardesc`7Bmatrix`7D onto the transformation stac Vk.`7D X*/ X`7B X newone3 = (ptksstack3 *)malloc(sizeof(ptksstack3)); X newone3->ptkpnext = listhead3; X memcpy(newone3->ptkamat, matrix, sizeof(Pmatrix3)); X listhead3 = newone3; X`7D /* ptk_stackmatrix3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_stackmatrix(C(Pmatrix) matrix) XPreANSI(Pmatrix matrix) X/* X** \parambegin X** \param`7BPmatrix`7D`7Bmatrix`7D`7B3x3 matrix`7D`7BIN`7D X** \paramend X** \blurb`7BThis function pushes the $3 \times 3$ matrix \pardesc`7Bmatrix`7 VD X** onto the transformation stack.`7D X*/ X`7B X newone = (ptksstack *)malloc(sizeof(ptksstack)); X newone->ptkpnext = listhead; X memcpy(newone->ptkamat, matrix, sizeof(Pmatrix)); X listhead = newone; X`7D /* ptk_stackmatrix */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_unstackmatrix3(C(Pmatrix3) matrix) XPreANSI(Pmatrix3 matrix) X/* X** \parambegin X** \param`7BPmatrix3`7D`7Bmatrix`7D`7B4x4 matrix`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function X** pops a $4 \times 4$ matrix`20 X** from the transformation stack and returns it in X** \pardesc`7Bmatrix`7D.`7D X*/ X`7B X if (listhead3 == NULL) X return; X memcpy(matrix, listhead3->ptkamat, sizeof(Pmatrix3)); X newone3 = listhead3->ptkpnext; X free(listhead3); X listhead3 = newone3; X`7D /* ptk_unstackmatrix3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_unstackmatrix(C(Pmatrix) matrix) XPreANSI(Pmatrix matrix) X/* X** \parambegin X** \param`7BPmatrix`7D`7Bmatrix`7D`7B3x3 matrix`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function pops a $3 \times 3$ matrix X** from the transformation stack and returns it in X** \pardesc`7Bmatrix`7D.`7D X*/ X`7B X if (listhead == NULL) X return; X memcpy(matrix, listhead->ptkamat, sizeof(Pmatrix)); X newone = listhead->ptkpnext; X free(listhead); X listhead = newone; X`7D /* ptk_unstackmatrix */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_examinestackmatrix3(C(Pmatrix3) matrix) XPreANSI(Pmatrix3 matrix) X/* X** \parambegin X** \param`7BPmatrix3`7D`7Bmatrix`7D`7B4x4 matrix`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns the top entry on the transformation stack. X** The stack is not disturbed.`7D X*/ X`7B X if (listhead3 != NULL) X memcpy(matrix, listhead3->ptkamat, sizeof(Pmatrix3)); X`7D /* ptk_examinestackmatrix3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_examinestackmatrix(C(Pmatrix) matrix) XPreANSI(Pmatrix matrix) X/* X** \parambegin X** \param`7BPmatrix`7D`7Bmatrix`7D`7B3x3 matrix`7D`7BIN`7D X** \paramend X** \blurb`7BThis function returns the top entry on the transformation stack V. X** The stack is not disturbed.`7D X*/ X`7B X if (listhead != NULL) X memcpy(matrix, listhead->ptkamat, sizeof(Pmatrix)); X`7D /* ptk_examinestackmatrix */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_3ptto3pt(C(Ppoint3 *) p1, C(Ppoint3 *) p2, C(Ppoint3 *) p3,` V20 X C(Ppoint3 *) q1, C(Ppoint3 *) q2, C(Ppoint3 *) q3,` V20 X C(Pcomptype) operation, C(Pmatrix3) matrix,`20 X C(Pint *)error) XPreANSI(Ppoint3 *p1) XPreANSI(Ppoint3 *p2) XPreANSI(Ppoint3 *p3) XPreANSI(Ppoint3 *q1)`20 XPreANSI(Ppoint3 *q2) XPreANSI(Ppoint3 *q3) XPreANSI(Pcomptype operation)`20 XPreANSI(Pmatrix3 matrix) XPreANSI(Pint *error) X/* X** \parambegin X** \param`7BPpoint3 *`7D`7Bp1`7D`7B3D point`7D`7BIN`7D X** \param`7BPpoint3 *`7D`7Bp2`7D`7B3D point`7D`7BIN`7D X** \param`7BPpoint3 *`7D`7Bp3`7D`7B3D point`7D`7BIN`7D X** \param`7BPpoint3 *`7D`7Bq1`7D`7B3D point`7D`7BIN`7D X** \param`7BPpoint3 *`7D`7Bq2`7D`7B3D point`7D`7BIN`7D +-+-+-+-+-+-+-+- END OF PART 266 +-+-+-+-+-+-+-+-