00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _localdef_h
00031 #define _localdef_h
00032
00033 #include <math.h>
00034
00035 namespace sc {
00036
00037 static const double pi=M_PI;
00038 static const double pih=M_PI_2;
00039 static const double tpi=2.0*pi;
00040
00041 static const double bohr = 0.52917706;
00042
00043
00044
00045 static inline void
00046 delta(double u[], const double a[], const double b[])
00047 {
00048 u[0]=a[0]-b[0];
00049 u[1]=a[1]-b[1];
00050 u[2]=a[2]-b[2];
00051 }
00052
00053
00054
00055
00056 static inline double
00057 dist(const double a[], const double b[])
00058 {
00059 double x,y,z;
00060 return (sqrt((x=a[0]-b[0])*x + (y=a[1]-b[1])*y + (z=a[2]-b[2])*z));
00061 }
00062
00063
00064
00065
00066 static inline double
00067 s2(double x)
00068 {
00069 double tmp = 1.0 - x*x;
00070 if (tmp < 0.0) tmp = 0.0;
00071 return sqrt(tmp);
00072 }
00073
00074
00075
00076
00077 static inline double
00078 scalar(const double a[], const double b[])
00079 {
00080 double x = a[0]*b[0];
00081 double x1 = a[1]*b[1];
00082 x += a[2]*b[2];
00083 return x+x1;
00084 }
00085
00086
00087
00088
00089
00090 static inline void
00091 norm(double u[], const double a[], const double b[])
00092 {
00093 delta(u,a,b);
00094 double x = 1.0/sqrt(scalar(u,u));
00095 u[0] *= x; u[1] *= x; u[2] *= x;
00096 }
00097
00098
00099
00100
00101 static inline void
00102 normal(const double a[], const double b[], double w[])
00103 {
00104 w[0] = a[1]*b[2]-a[2]*b[1];
00105 w[1] = a[2]*b[0]-a[0]*b[2];
00106 w[2] = a[0]*b[1]-a[1]*b[0];
00107 double x = 1.0/sqrt(scalar(w,w));
00108 w[0] *= x; w[1] *= x; w[2] *= x;
00109 }
00110
00111 }
00112
00113 #endif
00114
00115
00116
00117
00118