![]()
|
localdef.h00001 // 00002 // localdef.h 00003 // 00004 // Copyright (C) 1996 Limit Point Systems, Inc. 00005 // 00006 // Author: Edward Seidl <seidl@janed.com> 00007 // Maintainer: LPS 00008 // 00009 // This file is part of the SC Toolkit. 00010 // 00011 // The SC Toolkit is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Library General Public License as published by 00013 // the Free Software Foundation; either version 2, or (at your option) 00014 // any later version. 00015 // 00016 // The SC Toolkit is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU Library General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Library General Public License 00022 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to 00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 00024 // 00025 // The U.S. Government is granted a limited license as per AL 91-7. 00026 // 00027 00028 // some inline functions for dealing with 3 dimensional vectors 00029 00030 #ifndef _localdef_h 00031 #define _localdef_h 00032 00033 #include <math.h> 00034 00035 namespace sc { 00036 00037 static const double pi=3.14159265358979323846; 00038 static const double pih=1.57079632679489661923; 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 // returns the distance between two points 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 // given sin(x) returns cos(x) 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 // returns the dot product for two vectors 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 // given vectors a and b, returns a unit vector directed along the difference 00089 // of the two vectors 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 // given two vectors, returns the normalized cross product of those vectors 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 // Local Variables: 00116 // mode: c++ 00117 // c-file-style: "ETS" 00118 // End: Generated at Fri Jan 10 08:14:09 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14. |