CCL Home Page
Up Directory CCL mat_transform
#include "utility.h"

void mat_transform(vector1,rotation_matrix,translation_vector,vector2)
/*============================================================================*/
/* PURPOSE:  APPLY THE SPECIFIED ROTATION AND TRANSLATION TO THE SUPPLIED
/*	VECTOR.
/* INPUTS:
/*	VECTOR1			(X,Y,Z) TRIPLET.
/*	ROTATION_MATRIX		THREE BY THREE ROTATION MATRIX.
/*	TRANSLATION_VECTOR	(X,Y,Z) TRANSLATION TRIPLET.
/* OUTPUTS:
/*	VECTOR2			VECTOR1*ROTATION_MATRIX+TRANSLATION_VECTOR.
/* WRITTEN: M.V.GRIESHABER
/* LAST MODIFICATION: 11 JUNE 1991 MVG
*/
   double vector1[3];
   double rotation_matrix[3][3];
   double translation_vector[3];
   double vector2[3];
   {
   int i;
   int j;
   double nvector[3];

   /* APPLY BOTH THE ROTATION AND TRANSLATION TO THE ORIGINAL VECTOR1. */
   /* NOTE THAT WE ACCUMULATE THE RESULT IN NVECTOR SO AS NOT TO PREMATURELY */
   /* CORRUPT VECTOR1 (IF SAME VECTOR WAS SUPPLIED AS BOTH VECTOR1 AND */
   /* VECTOR2 ON CALL) BEFORE WE COMPLETE THE CALCULATIONS. */
   for (i=0; i<3; i++)
      {
      nvector[i]=translation_vector[i];
      for (j=0; j<3; j++)
         {
         nvector[i]+=vector1[j]*rotation_matrix[j][i];
         }
      }

   for (i=0; i<3; i++)
      {
      vector2[i]=nvector[i];	/* RETURN COMPLETED VECTOR IN CALLING PARAMETER. */
      }

   return;
   }
Modified: Fri Feb 11 17:00:00 1994 GMT
Page accessed 5054 times since Sat Apr 17 21:58:58 1999 GMT