-\f
-//////////////////////////////////////////////////////////////////
-// Norman's Optimized matrix rotators! //
-//////////////////////////////////////////////////////////////////
-
-
-// Since these are pure rotation matrices we can save some bookwork
-// by considering them to be 3x3 until the very end -- NHV
-static void MakeVIEW_OFFSET( sgMat4 dst,
- const float angle1, const sgVec3 axis1,
- const float angle2, const sgVec3 axis2 )
-{
- // make rotmatrix1 from angle and axis
- float s = (float) sin ( angle1 ) ;
- float c = (float) cos ( angle1 ) ;
- float t = SG_ONE - c ;
-
- sgMat3 mat1;
- float tmp = t * axis1[0];
- mat1[0][0] = tmp * axis1[0] + c ;
- mat1[0][1] = tmp * axis1[1] + s * axis1[2] ;
- mat1[0][2] = tmp * axis1[2] - s * axis1[1] ;
-
- tmp = t * axis1[1];
- mat1[1][0] = tmp * axis1[0] - s * axis1[2] ;
- mat1[1][1] = tmp * axis1[1] + c ;
- mat1[1][2] = tmp * axis1[2] + s * axis1[0] ;
-
- tmp = t * axis1[2];
- mat1[2][0] = tmp * axis1[0] + s * axis1[1] ;
- mat1[2][1] = tmp * axis1[1] - s * axis1[0] ;
- mat1[2][2] = tmp * axis1[2] + c ;
-
- // make rotmatrix2 from angle and axis
- s = (float) sin ( angle2 ) ;
- c = (float) cos ( angle2 ) ;
- t = SG_ONE - c ;
-
- sgMat3 mat2;
- tmp = t * axis2[0];
- mat2[0][0] = tmp * axis2[0] + c ;
- mat2[0][1] = tmp * axis2[1] + s * axis2[2] ;
- mat2[0][2] = tmp * axis2[2] - s * axis2[1] ;
-
- tmp = t * axis2[1];
- mat2[1][0] = tmp * axis2[0] - s * axis2[2] ;
- mat2[1][1] = tmp * axis2[1] + c ;
- mat2[1][2] = tmp * axis2[2] + s * axis2[0] ;
-
- tmp = t * axis2[2];
- mat2[2][0] = tmp * axis2[0] + s * axis2[1] ;
- mat2[2][1] = tmp * axis2[1] - s * axis2[0] ;
- mat2[2][2] = tmp * axis2[2] + c ;
-
- // multiply matrices
- for ( int j = 0 ; j < 3 ; j++ ) {
- dst[0][j] = mat2[0][0] * mat1[0][j] +
- mat2[0][1] * mat1[1][j] +
- mat2[0][2] * mat1[2][j];
-
- dst[1][j] = mat2[1][0] * mat1[0][j] +
- mat2[1][1] * mat1[1][j] +
- mat2[1][2] * mat1[2][j];
-
- dst[2][j] = mat2[2][0] * mat1[0][j] +
- mat2[2][1] * mat1[1][j] +
- mat2[2][2] * mat1[2][j];
- }
- // fill in 4x4 matrix elements
- dst[0][3] = SG_ZERO;
- dst[1][3] = SG_ZERO;
- dst[2][3] = SG_ZERO;
- dst[3][0] = SG_ZERO;
- dst[3][1] = SG_ZERO;
- dst[3][2] = SG_ZERO;
- dst[3][3] = SG_ONE;
-}
-