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

double vec_norm(vector1,vector2)
/*============================================================================*/
/* PURPOSE: NORMALIZE A VECTOR.
/* INPUTS:
/*	VECTOR1		(X,Y,Z) TRIPLET.
/* OUTPUTS:
/*	VECTOR2		(X,Y,Z) TRIPLET EQUAL TO NORMALIZED VECTOR.
/*	FUNCTION VALUE	VECTOR LENGTH USED IN NORMALIZATION (FAILURE IF ZERO).
/* WRITTEN: M.V.GRIESHABER
/* LAST MODIFICATION: 11 JUNE 1991 MVG
*/
   double vector1[3];
   double vector2[3];
   {
   double length;
   int i;

   /* DETERMINE THE LENGTH OF THE VECTOR.  IF ZERO, CAN'T NORMALIZE.*/
   if ((length=vec_length(vector1)) > 0.0)
      {
      for(i=0 ; i<3 ; i++)
         {
         vector2[i]=vector1[i]/length;
         }
      }

   return(length);
   }
Modified: Fri Feb 11 17:00:00 1994 GMT
Page accessed 5111 times since Sat Apr 17 21:59:04 1999 GMT