AVector Class Reference

#include <FreeEnergyVector.h>

List of all members.

Public Member Functions

 AVector (Vector_t Type=kRegular)
 AVector (double x, double y, double z)
 AVector (const AVector &Vector)
Bool_t Set (double x, double y, double z)
AVector operator+ (const AVector &Vector)
AVector operator- (const AVector &Vector)
AVector operator/ (double divisor)
AVectoroperator/= (double divisor)
AVectoroperator *= (double scalar)
AVector operator * (double scalar)
AVectoroperator= (const AVector &Vector)
AVectoroperator+= (const AVector &Vector)
AVector cross (const AVector &Vector)
double dot (const AVector &Vector)
double & operator[] (int index)
double Dist ()
double DistSqr ()
double Dist (const AVector &Vector)
double DistSqr (const AVector &Vector)
void Out ()
void Output ()
AVectorScale (AVector &SmallVec, AVector &BigVec)
AVectorRandom ()

Protected Attributes

double m_x
double m_y
double m_z

Friends

void SetEqual (AVector &Vec1, const Vector &Vec2)
void SetEqual (Vector &Vec1, const AVector &Vec2)


Detailed Description

Definition at line 14 of file FreeEnergyVector.h.


Constructor & Destructor Documentation

AVector::AVector ( Vector_t  Type = kRegular  ) 

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 18 of file FreeEnergyVector.C.

References ASSERT, kRandom, kRegular, m_x, m_y, m_z, and Random().

00018                               {
00019 //------------------------------------------------
00020 // init this vector to (0,0,0) for kRegular Type
00021 // init this vector to (x,y,z) for kRandom Type
00022 // where x, y, and z are in the range (0:1)
00023 //
00024 // Note:  The assumption is made that srand() has
00025 //        already been called.
00026 //------------------------------------------------
00027   if (Type == kRegular) {
00028     m_x = 0.0;
00029     m_y = 0.0;
00030     m_z = 0.0;
00031   }
00032   else {
00033     ASSERT(Type == kRandom);
00034     Random();
00035   }
00036 }

AVector::AVector ( double  x,
double  y,
double  z 
)

Definition at line 39 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00039                                              {
00040 //-------------------------------------------
00041 // init this vector to (x,y,z)
00042 //-------------------------------------------
00043   m_x = x;
00044   m_y = y;
00045   m_z = z;
00046 }

AVector::AVector ( const AVector Vector  ) 

Definition at line 49 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00049                                       {
00050 //-------------------------------------------
00051 // init this vector to Vector
00052 //-------------------------------------------
00053   m_x = Vector.m_x;
00054   m_y = Vector.m_y;
00055   m_z = Vector.m_z;
00056 }


Member Function Documentation

AVector AVector::cross ( const AVector Vector  ) 

Definition at line 243 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

Referenced by ARestraint::GetDihe(), and ADiheRestraint::GetGrad().

00243                                             {
00244 //-------------------------------------------------------------------
00245 // calculate this vector crossed with Vector (this x Vector).
00246 // see Mathematical Handbook, p.118.
00247 //-------------------------------------------------------------------
00248   AVector CrossProduct;
00249 
00250   CrossProduct.m_x = (m_y * Vector.m_z) - (m_z * Vector.m_y);
00251   CrossProduct.m_y = (m_z * Vector.m_x) - (m_x * Vector.m_z);
00252   CrossProduct.m_z = (m_x * Vector.m_y) - (m_y * Vector.m_x);
00253   return(CrossProduct);
00254 }

double AVector::Dist ( const AVector Vector  ) 

Definition at line 221 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00221                                           {
00222 //-------------------------------------------------------------------
00223 // calculate distance between this point and Vector
00224 //-------------------------------------------------------------------
00225   double d1 = (m_x - Vector.m_x);
00226   double d2 = (m_y - Vector.m_y);
00227   double d3 = (m_z - Vector.m_z);
00228   return( sqrt(d1*d1 + d2*d2 + d3*d3) );
00229 }

double AVector::Dist (  ) 

Definition at line 205 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

Referenced by AForcingDistRestraint::Get_dU_dLambda(), ARestraint::GetDihe(), AForcingPosRestraint::GetDistance(), ABoundPosRestraint::GetDistance(), AFixedPosRestraint::GetDistance(), ADistRestraint::GetE(), ABoundDistRestraint::GetEnergy(), ABoundPosRestraint::GetEnergy(), ADiheRestraint::GetGrad(), ABoundDistRestraint::GetGradient(), ABoundPosRestraint::GetGradient(), ADiheRestraint::gradU(), and ADistRestraint::PrintInfo().

00205                      {
00206 //-------------------------------------------------------------------
00207 // calculate distance from this point to (0, 0, 0)
00208 //-------------------------------------------------------------------
00209   return( sqrt(m_x*m_x + m_y*m_y + m_z*m_z) );
00210 }

double AVector::DistSqr ( const AVector Vector  ) 

Definition at line 232 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00232                                              {
00233 //-------------------------------------------------------------------
00234 // calculate distance-squared between this point and Vector
00235 //-------------------------------------------------------------------
00236   double d1 = (m_x - Vector.m_x);
00237   double d2 = (m_y - Vector.m_y);
00238   double d3 = (m_z - Vector.m_z);
00239   return(d1*d1 + d2*d2 + d3*d3);
00240 }

double AVector::DistSqr (  ) 

Definition at line 213 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00213                         {
00214 //-------------------------------------------------------------------
00215 // calculate distance-squared from this point to (0, 0, 0)
00216 //-------------------------------------------------------------------
00217   return(m_x*m_x + m_y*m_y + m_z*m_z);
00218 }

double AVector::dot ( const AVector Vector  ) 

Definition at line 257 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

Referenced by ARestraint::GetDihe(), ADiheRestraint::GetGrad(), and ADiheRestraint::gradU().

00257                                          {
00258 //-------------------------------------------------------------------
00259 // calculate dot product of this vector and Vector
00260 // see Mathematical Handbook, p.118.
00261 //-------------------------------------------------------------------
00262   return(m_x*Vector.m_x + m_y*Vector.m_y + m_z*Vector.m_z);
00263 }

AVector AVector::operator * ( double  scalar  ) 

Definition at line 137 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00137                                          {
00138 //---------------------------------------------------
00139 // create a new vector: this one divided by divisor
00140 //---------------------------------------------------
00141   AVector Point(m_x*scalar, m_y*scalar, m_z*scalar);
00142   return(Point);
00143 }

AVector & AVector::operator *= ( double  scalar  ) 

Definition at line 126 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00126                                            {
00127 //------------------------------------------------------
00128 // multiply this vector by scalar and return a ref to it
00129 //------------------------------------------------------
00130   m_x *= scalar;
00131   m_y *= scalar;
00132   m_z *= scalar;
00133   return(*this);
00134 }

AVector AVector::operator+ ( const AVector Vector  ) 

Definition at line 88 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00088                                                  {
00089 //----------------------------------------------------------
00090 // create a new vector: the sum of this one and passed one
00091 //----------------------------------------------------------
00092   AVector Point(vector.m_x+m_x, vector.m_y+m_y, vector.m_z+m_z);
00093   return(Point);
00094 }

AVector & AVector::operator+= ( const AVector Vector  ) 

Definition at line 177 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00177                                                    {
00178 //--------------------------------------------------
00179 // set this vector to this one plus the passed one
00180 //--------------------------------------------------
00181   m_x += vector.m_x;
00182   m_y += vector.m_y;
00183   m_z += vector.m_z;
00184   return(*this);
00185 }

AVector AVector::operator- ( const AVector Vector  ) 

Definition at line 97 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00097                                                  {
00098 //----------------------------------------------------------
00099 // create a new vector: this one minus the passed one
00100 //----------------------------------------------------------
00101   AVector Point(m_x-vector.m_x, m_y-vector.m_y, m_z-vector.m_z);
00102   return(Point);
00103 }

AVector AVector::operator/ ( double  divisor  ) 

Definition at line 106 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00106                                           {
00107 //---------------------------------------------------
00108 // create a new vector: this one divided by divisor
00109 //---------------------------------------------------
00110   AVector Point(m_x/divisor, m_y/divisor, m_z/divisor);
00111   return(Point);
00112 }

AVector & AVector::operator/= ( double  divisor  ) 

Definition at line 115 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00115                                             {
00116 //------------------------------------------------------
00117 // divide this vector by divisor and return a ref to it
00118 //------------------------------------------------------
00119   m_x /= divisor;
00120   m_y /= divisor;
00121   m_z /= divisor;
00122   return(*this);
00123 }

AVector & AVector::operator= ( const AVector Vector  ) 

Definition at line 166 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00166                                                   {
00167 //-------------------------------------------
00168 // set this vector to the passed one
00169 //-------------------------------------------
00170   m_x = vector.m_x;
00171   m_y = vector.m_y;
00172   m_z = vector.m_z;
00173   return(*this);
00174 }

double & AVector::operator[] ( int  index  ) 

Definition at line 188 of file FreeEnergyVector.C.

References ASSERT, m_x, m_y, and m_z.

00188                                       {
00189 //-------------------------------------------------------------------
00190 // return one element of this vector
00191 // note: this op is used to get AND set an element
00192 //       (since it returns double&)
00193 //-------------------------------------------------------------------
00194   ASSERT( (index>=0) && (index<3) );
00195 
00196   switch(index) {
00197     case 0:  return(m_x);
00198     case 1:  return(m_y);
00199     case 2:  return(m_z);
00200     default: return(m_x);   // should never get here
00201   }
00202 }

void AVector::Out (  ) 

Definition at line 266 of file FreeEnergyVector.C.

References iout, m_x, m_y, and m_z.

Referenced by APosRestraint::PrintInfo().

00266                   {
00267 //-------------------------------------------------------------------
00268 // write it
00269 //-------------------------------------------------------------------
00270   char  Str1[20], Str2[20], Str3[20];
00271 
00272   sprintf(Str1, "%8.3f", m_x);
00273   sprintf(Str2, "%8.3f", m_y);
00274   sprintf(Str3, "%8.3f", m_z);
00275   iout << "(" << Str1 << "," << Str2 << "," << Str3 << ")";
00276 }

void AVector::Output (  ) 

Definition at line 279 of file FreeEnergyVector.C.

References iout, m_x, m_y, and m_z.

00279                      {
00280 //-------------------------------------------------------------------
00281 // write it to standard output
00282 //-------------------------------------------------------------------
00283   char  Word1[20], Word2[20], Word3[20];
00284 
00285   if ( (fabs(m_x)<99999) && (fabs(m_y)<99999) && (fabs(m_z)<99999) ) {
00286     sprintf(Word1, "%10.3f", m_x);
00287     sprintf(Word2, "%10.3f", m_y);
00288     sprintf(Word3, "%10.3f", m_z);
00289   }
00290   else {
00291     sprintf(Word1, "%10.2e", m_x);
00292     sprintf(Word2, "%10.2e", m_y);
00293     sprintf(Word3, "%10.2e", m_z);
00294   }
00295   iout << "( " << Word1 << " " << Word2 << " " << Word3 << " )";
00296 }

AVector & AVector::Random (  ) 

Definition at line 59 of file FreeEnergyVector.C.

References ASSERT, m_x, m_y, and m_z.

Referenced by AVector().

00059                          {
00060 //------------------------------------------------
00061 // replace this vector with a new random vector
00062 // where x, y, and z are in the range (0:1)
00063 //------------------------------------------------
00064   double RandMax;
00065    
00066   RandMax = RAND_MAX;
00067   m_x = (double)rand() / RandMax;
00068   m_y = (double)rand() / RandMax;
00069   m_z = (double)rand() / RandMax;
00070   ASSERT(m_x <= 1.0);
00071   ASSERT(m_y <= 1.0);
00072   ASSERT(m_z <= 1.0);
00073   return(*this);
00074 }

AVector & AVector::Scale ( AVector SmallVec,
AVector BigVec 
)

Definition at line 299 of file FreeEnergyVector.C.

References m_x, m_y, and m_z.

00299                                                           {
00300 //-------------------------------------------------------------------
00301 // scale this vector, whose (x,y,z) are in the range (0:1),
00302 // to be in the range (SmallVec:BigVec)
00303 //-------------------------------------------------------------------
00304   m_x = SmallVec.m_x + (BigVec.m_x - SmallVec.m_x) * m_x;
00305   m_y = SmallVec.m_y + (BigVec.m_y - SmallVec.m_y) * m_y;
00306   m_z = SmallVec.m_z + (BigVec.m_z - SmallVec.m_z) * m_z;
00307   return(*this);
00308 }

Bool_t AVector::Set ( double  x,
double  y,
double  z 
)

Definition at line 77 of file FreeEnergyVector.C.

References kTrue, m_x, m_y, and m_z.

Referenced by ADiheRestraint::GetGrad(), ADistRestraint::GetGrad(), ABoundPosRestraint::GetGradient(), and ARestraint::UpdateCOMs().

00077                                                 {
00078 //-------------------------------------------
00079 // int this vector to (x,y,z)
00080 //-------------------------------------------
00081   m_x = x;
00082   m_y = y;
00083   m_z = z;
00084   return(kTrue);
00085 }


Friends And Related Function Documentation

void SetEqual ( Vector Vec1,
const AVector Vec2 
) [friend]

Definition at line 156 of file FreeEnergyVector.C.

00156                                                   {
00157 //------------------------------------------------------------------------
00158 // used for casting AVector -> Vector
00159 //------------------------------------------------------------------------
00160   Vec1.x = Vec2.m_x;
00161   Vec1.y = Vec2.m_y;
00162   Vec1.z = Vec2.m_z;
00163 }

void SetEqual ( AVector Vec1,
const Vector Vec2 
) [friend]

Definition at line 146 of file FreeEnergyVector.C.

00146                                                  {
00147 //------------------------------------------------------------------------
00148 // used for casting Vector -> AVector
00149 //------------------------------------------------------------------------
00150   Vec1.m_x = Vec2.x;
00151   Vec1.m_y = Vec2.y;
00152   Vec1.m_z = Vec2.z;
00153 }


Member Data Documentation

double AVector::m_x [protected]

Definition at line 17 of file FreeEnergyVector.h.

Referenced by AVector(), cross(), Dist(), DistSqr(), dot(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator/(), operator/=(), operator=(), operator[](), Out(), Output(), Random(), Scale(), Set(), and SetEqual().

double AVector::m_y [protected]

Definition at line 18 of file FreeEnergyVector.h.

Referenced by AVector(), cross(), Dist(), DistSqr(), dot(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator/(), operator/=(), operator=(), operator[](), Out(), Output(), Random(), Scale(), Set(), and SetEqual().

double AVector::m_z [protected]

Definition at line 19 of file FreeEnergyVector.h.

Referenced by AVector(), cross(), Dist(), DistSqr(), dot(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator/(), operator/=(), operator=(), operator[](), Out(), Output(), Random(), Scale(), Set(), and SetEqual().


The documentation for this class was generated from the following files:
Generated on Sun Sep 24 01:17:16 2017 for NAMD by  doxygen 1.4.7