GLYLIB  0.3.0b
normalize_vec.c
Go to the documentation of this file.
00001 // Function written by B. Lachele Foley, 2007
00002 #include <mylib.h>
00003 #include <molecules.h>
00004 //#include "../inc/mylib.h"
00005 //#include "../inc/molecules.h"
00006 /* this normalizes a vector */
00007 vectormag_3D normalize_vec(vectormag_3D v){
00008 vectormag_3D nv;
00009 double temp=0;
00010 
00011 // don't trust entry in 'd' -- normalize now to be certain
00012 temp=sqrt(v.i*v.i+v.j*v.j+v.k*v.k);
00013 
00014 if(temp!=0){
00015         nv.i=v.i/temp;
00016         nv.j=v.j/temp;
00017         nv.k=v.k/temp;
00018         nv.d=1;
00019         }
00020 else{ nv.i=nv.j=nv.k=nv.d=0; }
00021 
00022 return nv;
00023 }
 All Classes Files Functions Variables Typedefs Defines