From: hackbard Date: Tue, 23 Mar 2010 16:32:19 +0000 (+0100) Subject: added acos to angle calc X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=40f91e7d7cb98fedd86bc4e3178021f687190550;p=physik%2Fposic.git added acos to angle calc --- diff --git a/vasp_tools/acos.c b/vasp_tools/acos.c new file mode 100644 index 0000000..609a6dc --- /dev/null +++ b/vasp_tools/acos.c @@ -0,0 +1,11 @@ +/* acos */ + +#include +#include +#include + +int main(int argc,char **argv) { + printf("%f\n",180.0/M_PI*acos(atof(argv[1]))); + return 0; +} + diff --git a/vasp_tools/angle_calc b/vasp_tools/angle_calc index da01dfb..b23d51d 100755 --- a/vasp_tools/angle_calc +++ b/vasp_tools/angle_calc @@ -41,7 +41,7 @@ yc=`echo $temp | awk '{ print $2 }'` zc=`echo $temp | awk '{ print $3 }'` echo -en "angle: " -echo "$xa $ya $za $xb $yb $zb $xc $yc $zc $scale" | \ +foo=`echo "$xa $ya $za $xb $yb $zb $xc $yc $zc $scale" | \ awk ' \ BEGIN { X1=ENVIRON["X1"]; X2=ENVIRON["X2"]; X3=ENVIRON["X3"] @@ -92,8 +92,10 @@ echo "$xa $ya $za $xb $yb $zb $xc $yc $zc $scale" | \ sp=dxt*Dxt+dyt*Dyt+dzt*Dzt d=sqrt(dxt^2+dyt^2+dzt^2) D=sqrt(Dxt^2+Dyt^2+Dzt^2) - print 180.0/pi*acos2(sp/(d*D)) - }' + print sp/(d*D) + }'` + +./acos $foo echo