GLYLIB  0.3.0b
add_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 adds one vector to another (and sets d, too) */
00007 vectormag_3D add_vec(vectormag_3D va,vectormag_3D vb){
00008 vectormag_3D nv;
00009 
00010 nv.i=va.i+vb.i;
00011 nv.j=va.j+vb.j;
00012 nv.k=va.k+vb.k;
00013 
00014 // don't trust the d in nv
00015 nv.d=sqrt(nv.i*nv.i+nv.j*nv.j+nv.k*nv.k);
00016 
00017 return nv;
00018 }
00019 
00020 /* this subtracts vector vb from vector va (and sets d, too) */
00021 vectormag_3D subtract_vec(vectormag_3D va,vectormag_3D vb){
00022 vectormag_3D nv;
00023 
00024 nv.i=va.i-vb.i;
00025 nv.j=va.j-vb.j;
00026 nv.k=va.k-vb.k;
00027 
00028 // don't trust the d in nv
00029 nv.d=sqrt(nv.i*nv.i+nv.j*nv.j+nv.k*nv.k);
00030 
00031 return nv;
00032 }
 All Classes Files Functions Variables Typedefs Defines