-+-+-+-+-+-+-+-+ START OF PART 263 -+-+-+-+-+-+-+-+ Xextern void ptk_shift3(C(Ppoint3 *) shift, C(Pcomptype) operation,`20 X C(Pmatrix3) matrix) XPreANSI(Ppoint3 *shift) XPreANSI(Pcomptype operation) XPreANSI(Pmatrix3 matrix) X/* X** \parambegin X** \param`7BPpoint3 *`7D`7Bshift`7D`7Bshift factor`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 X** a matrix to perform the specified 3D shift and concatenates`20 X** this matrix with \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperatio Vn`7D.`7D X*/ X`7B X Pmatrix3 temp; X X ptk_unitmatrix3(temp); X temp`5B0`5D`5B3`5D = shift->x; X temp`5B1`5D`5B3`5D = shift->y; X temp`5B2`5D`5B3`5D = shift->z; X ptk_concatenatematrix3(operation, temp, matrix, matrix); X`7D /* ptk_shift3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_shift(C(Ppoint *) shift, C(Pcomptype) operation,`20 X C(Pmatrix) matrix) XPreANSI(Ppoint *shift) XPreANSI(Pcomptype operation) XPreANSI(Pmatrix matrix) X/* X** \parambegin X** \param`7BPpoint *`7D`7Bshift`7D`7Bshift factor`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** \paramend X** \blurb`7BThis function computes X** a matrix to perform the specified 2D shift and concatenates`20 X** this matrix with \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperatio Vn`7D.`7D X*/ X`7B X Pmatrix temp; X X ptk_unitmatrix(temp); X temp`5B0`5D`5B2`5D = shift->x; X temp`5B1`5D`5B2`5D = shift->y; X ptk_concatenatematrix(operation, temp, matrix, matrix); X`7D /* ptk_shift */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_scale3(C(Ppoint3 *) scale, C(Pcomptype) operation,`20 X C(Pmatrix3) matrix) XPreANSI(Ppoint3 *scale) XPreANSI(Pcomptype operation) XPreANSI(Pmatrix3 matrix) X/* X** \parambegin X** \param`7BPpoint3 *`7D`7Bshift`7D`7Bshift factor`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`20 X** computes a matrix to perform the specified 3D scale and concatenates`20 X** this with \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperation`7D.`7 VD X*/ X`7B X Pmatrix3 temp; X X ptk_unitmatrix3(temp); X temp`5B0`5D`5B0`5D = scale->x; `20 X temp`5B1`5D`5B1`5D = scale->y; X temp`5B2`5D`5B2`5D = scale->z; X ptk_concatenatematrix3(operation, temp, matrix, matrix); X`7D /* ptk_scale3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_scale(C(Ppoint *) scale, C(Pcomptype) operation,`20 X C(Pmatrix) matrix) XPreANSI(Ppoint *scale) XPreANSI(Pcomptype operation) XPreANSI(Pmatrix matrix) X/* X** \parambegin X** \param`7BPpoint *`7D`7Bshift`7D`7Bshift factor`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** \paramend X** \blurb`7BThis function computes X** a matrix to perform the specified 2D scale and concatenates`20 X** this matrix with \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperatio Vn`7D.`7D X*/ X`7B X Pmatrix temp; X X ptk_unitmatrix(temp); X temp`5B0`5D`5B0`5D = scale->x; `20 X temp`5B1`5D`5B1`5D = scale->y; X ptk_concatenatematrix(operation, temp, matrix, matrix); X`7D /* ptk_scale */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_rotatecs3(C(Pfloat) costheta, C(Pfloat) sinetheta,`20 X C(ptkeaxistype) axis, C(Pcomptype) operation,`20 X C(Pmatrix3) matrix) XPreANSI(Pfloat costheta) XPreANSI(Pfloat sinetheta) XPreANSI(ptkeaxistype axis) XPreANSI(Pcomptype operation) XPreANSI(Pmatrix3 matrix) X/* X** \parambegin X** \param`7BPfloat`7D`7Bcostheta`7D`7Bcosine of angle`7D`7BIN`7D X** \param`7BPfloat`7D`7Bsinetheta`7D`7Bsine of angle`7D`7BIN`7D X** \param`7Bptkeaxistype`7D`7Baxis`7D`7Bx, y or z axis`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 X** a matrix to perform the specified 3D rotation and concatenates`20 X** this matrix with`20 X** \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperation`7D. X** This form assumes that the rotation is specified X** using the $\cos(theta)$ and $\sin(theta)$ terms. X** Note that no check is made to ensure that the sum of the squares of these X** terms is 1.`7D X*/ X`7B X Pmatrix3 temp; X X ptk_unitmatrix3(temp); X switch (axis)`20 X `7B X case PTKEXAXIS: X temp`5B2`5D`5B2`5D = costheta; X temp`5B1`5D`5B1`5D = costheta; X temp`5B1`5D`5B2`5D = -sinetheta; X temp`5B2`5D`5B1`5D = sinetheta; X break; X X case PTKEYAXIS: X temp`5B0`5D`5B0`5D = costheta; X temp`5B2`5D`5B2`5D = costheta; X temp`5B0`5D`5B2`5D = sinetheta; X temp`5B2`5D`5B0`5D = -sinetheta; X break; X X case PTKEZAXIS: X temp`5B0`5D`5B0`5D = costheta; X temp`5B1`5D`5B1`5D = costheta; X temp`5B0`5D`5B1`5D = -sinetheta; X temp`5B1`5D`5B0`5D = sinetheta; X break; X `7D X ptk_concatenatematrix3(operation, temp, matrix, matrix); X`7D /* ptk_rotatecs3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_rotatecs(C(Pfloat) costheta, C(Pfloat) sinetheta,`20 X C(ptkeaxistype) axis, C(Pcomptype) operation,`20 X C(Pmatrix) matrix) XPreANSI(Pfloat costheta) XPreANSI(Pfloat sinetheta) XPreANSI(ptkeaxistype axis) XPreANSI(Pcomptype operation) XPreANSI(Pmatrix matrix) X/* X** \parambegin X** \param`7BPfloat`7D`7Bcostheta`7D`7Bcosine of angle`7D`7BIN`7D X** \param`7BPfloat`7D`7Bsinetheta`7D`7Bsine of angle`7D`7BIN`7D X** \param`7Bptkeaxistype`7D`7Baxis`7D`7Bx, y or z axis`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** \paramend X** \blurb`7BThis function computes X** a matrix to perform the specified 2D rotation and concatenates`20 X** this matrix with`20 X** \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperation`7D. X** This form assumes that the rotation is specified X** using the $\cos(theta)$ and $\sin(theta)$ terms. X** Note that no check is made to ensure that the sum of the squares of these X** terms is 1.`7D X*/ X`7B X Pmatrix temp; X X ptk_unitmatrix(temp); X switch (axis)`20 X `7B X case PTKEXAXIS: X temp`5B2`5D`5B2`5D = costheta; X temp`5B1`5D`5B1`5D = costheta; X temp`5B1`5D`5B2`5D = -sinetheta; X temp`5B2`5D`5B1`5D = sinetheta; X break; X X case PTKEYAXIS: X temp`5B0`5D`5B0`5D = costheta; X temp`5B2`5D`5B2`5D = costheta; X temp`5B0`5D`5B2`5D = sinetheta; X temp`5B2`5D`5B0`5D = -sinetheta; X break; X X case PTKEZAXIS: X temp`5B0`5D`5B0`5D = costheta; X temp`5B1`5D`5B1`5D = costheta; X temp`5B0`5D`5B1`5D = -sinetheta; X temp`5B1`5D`5B0`5D = sinetheta; X break; X `7D X ptk_concatenatematrix(operation, temp, matrix, matrix); X`7D /* ptk_rotatecs */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_rotate3(C(Pfloat) rotation, C(ptkeaxistype) axis,`20 X C(Pcomptype) operation, C(Pmatrix3) matrix) XPreANSI(Pfloat rotation) XPreANSI(ptkeaxistype axis) XPreANSI(Pcomptype operation)`20 XPreANSI(Pmatrix3 matrix) X/* X** \parambegin X** \param`7BPfloat`7D`7Brotation`7D`7Bangle in degrees`7D`7BIN`7D X** \param`7Bptkeaxistype`7D`7Baxis`7D`7Bx, y or z axis`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 X** a matrix to perform the specified 3D rotation and concatenates`20 X** this matrix with`20 X** \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperation`7D. X** \pardesc`7Brotation`7D is expressed in degrees.`7D X*/ X`7B X Pfloat costheta; X Pfloat sinetheta; X X costheta = cos((rotation * ptkcdtor)); X sinetheta = sin((rotation * ptkcdtor)); X ptk_rotatecs3(costheta, sinetheta, axis, operation, matrix); X`7D /* ptk_rotate3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_rotate(C(Pfloat) rotation, C(ptkeaxistype) axis,`20 X C(Pcomptype) operation, C(Pmatrix) matrix) XPreANSI(Pfloat rotation) XPreANSI(ptkeaxistype axis) XPreANSI(Pcomptype operation)`20 XPreANSI(Pmatrix matrix) X/* X** \parambegin X** \param`7BPfloat`7D`7Brotation`7D`7Bangle in degrees`7D`7BIN`7D X** \param`7Bptkeaxistype`7D`7Baxis`7D`7Bx, y or z axis`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** \paramend X** \blurb`7BThis function computes X** a matrix to perform the specified 2D rotation and concatenates`20 X** this matrix with`20 X** \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperation`7D. X** \pardesc`7Brotation`7D is expressed in degrees.`7D X*/ X`7B X Pfloat costheta; X Pfloat sinetheta; X X costheta = cos((rotation * ptkcdtor)); X sinetheta = sin((rotation * ptkcdtor)); X ptk_rotatecs(costheta, sinetheta, axis, operation, matrix); X`7D /* ptk_rotate */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_shear3(C(ptkeaxistype) shearaxis, C(ptkeaxistype) sheardir,` V20 X C(Pfloat) shearfactor, C(Pcomptype) operation,`20 X C(Pmatrix3) matrix) XPreANSI(ptkeaxistype shearaxis) XPreANSI(ptkeaxistype sheardir) XPreANSI(Pfloat shearfactor) XPreANSI(Pcomptype operation) XPreANSI(Pmatrix3 matrix) X/* X** \parambegin X** \param`7Bptkeaxistype`7D`7Bshearaxis`7D`7Bx, y or z axis`7D`7BIN`7D X** \param`7Bptkeaxistype`7D`7Bsheardir`7D`7Bx, y or z direction`7D`7BIN`7D X** \param`7BPfloat`7D`7Bshearfactor`7D`7Bshear factor`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 a matrix to perform the specified 3D X** shear and concatenates`20 X** this matrix with`20 X** \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperation`7D. X** The shear is specified as an amount \pardesc`7Bf`7D about axis \pardesc`7 VBi`7D X** in direction \pardesc`7Bj`7D.`7D X*/ X`7B X Pmatrix3 temp; X X ptk_unitmatrix3(temp); X temp`5B(Pint)shearaxis - 1`5D`5B(Pint)sheardir - 1`5D = shearfactor; X ptk_concatenatematrix3(operation, temp, matrix, matrix); X`7D /* ptk_shear3 */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_shear(C(ptkeaxistype) shearaxis, C(ptkeaxistype) sheardir,`2 V0 X C(Pfloat) shearfactor, C(Pcomptype) operation,`20 X C(Pmatrix) matrix) XPreANSI(ptkeaxistype shearaxis) XPreANSI(ptkeaxistype sheardir) XPreANSI(Pfloat shearfactor) XPreANSI(Pcomptype operation) XPreANSI(Pmatrix matrix) X/* X** \parambegin X** \param`7Bptkeaxistype`7D`7Bshearaxis`7D`7Bx or y axis`7D`7BIN`7D X** \param`7Bptkeaxistype`7D`7Bsheardir`7D`7Bx or y direction`7D`7BIN`7D X** \param`7BPfloat`7D`7Bshearfactor`7D`7Bshear factor`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** \paramend X** \blurb`7BThis function computes a matrix to perform the specified 2D X** shear and concatenates`20 X** this matrix with`20 X** \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperation`7D. X** The shear is specified as an amount \pardesc`7Bf`7D about axis \pardesc`7 VBi`7D X** in direction \pardesc`7Bj`7D.`7D X*/ X`7B X Pmatrix temp; X X ptk_unitmatrix(temp); X temp`5B(Pint)shearaxis - 1`5D`5B(Pint)sheardir - 1`5D = shearfactor; X ptk_concatenatematrix(operation, temp, matrix, matrix); X`7D /* ptk_shear */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_rotatevv3(C(Ppoint3 *) v1, C(Ppoint3 *) v2,`20 X C(Pcomptype) operation,`20 X C(Pmatrix3) matrix, C(Pint *)error) XPreANSI(Ppoint3 *v1) XPreANSI(Ppoint3 *v2) XPreANSI(Pcomptype operation)`20 XPreANSI(Pmatrix3 matrix) XPreANSI(Pint *error) 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** \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 computes X** a matrix to perform the rotation (about the origin) of the 3D vector X** \pardesc`7Bv1`7D to the 3D vector`20 X** \pardesc`7Bv2`7D, and concatenates this matrix with`20 X** \pardesc`7Bmatrix`7D on the basis of \pardesc`7Boperation`7D (\cite`7Brog V:mecg`7D,`20 X** pages 55--59). If the parameters are invalid, \pardesc`7Berror`7D is set V to`20 X** -1. Otherwise, its value is \pardesc`7Bptkcpcok`7D.`7D X*/ X`7B X Pmatrix3 temp; X Ppoint3 dv1, dv2, nvec; X Pfloat t1, costheta, sinetheta; X X /* Create a rotation matrix (about origin) to rotate from X ** vector dv1 to vector dv2 X ** Cf ROGERS and ADAMS page 55-59 X */ X X *error = ptkcpcok; /* Assume OK */ X dv1 = ptk_unitv3(v1); X dv2 = ptk_unitv3(v2); X X /* Get sine theta (cross product) and cos theta (dot product) */ X X costheta = dv1.x * dv2.x + dv1.y * dv2.y + dv1.z * dv2.z; X nvec = ptk_crossv3(&dv1, &dv2); X X /* How do I choose sign of sinetheta? X ** let A, B and K be unit vectors, then +-+-+-+-+-+-+-+- END OF PART 263 +-+-+-+-+-+-+-+-