Changeset 725869
- Timestamp:
- May 21, 2008, 9:24:54 AM (17 years ago)
- Children:
- 33c05d
- Parents:
- e9c14d
- Location:
- molecuilder/src
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/molecules.hpp
re9c14d r725869 22 22 #include "helpers.hpp" 23 23 #include "stackclass.hpp" 24 #include "vector.hpp" 24 25 25 26 class atom; … … 119 120 #define RDET2(a0,a1,a2,a3) ((a0)*(a3)-(a1)*(a2)) //!< hard-coded determinant of a 2x2 matrix 120 121 121 /** Single vector.122 * basically, just a x[3] but with helpful functions123 */124 class vector {125 public:126 double x[NDIM];127 128 vector();129 ~vector();130 131 double Distance(const vector *y) const;132 double PeriodicDistance(const vector *y, const double *cell_size) const;133 double ScalarProduct(const vector *y) const;134 double Projection(const vector *y) const;135 double Norm() const ;136 double Angle(vector *y) const;137 138 void AddVector(const vector *y);139 void SubtractVector(const vector *y);140 void CopyVector(const vector *y);141 void RotateVector(const vector *y, const double alpha);142 void Zero();143 void Normalize();144 void Translate(const vector *x);145 void Mirror(const vector *x);146 void Scale(double **factor);147 void Scale(double *factor);148 void Scale(double factor);149 void MatrixMultiplication(double *M);150 void InverseMatrixMultiplication(double *M);151 void KeepPeriodic(ofstream *out, double *matrix);152 void LinearCombinationOfVectors(const vector *x1, const vector *x2, const vector *x3, double *factors);153 154 bool GetOneNormalVector(const vector *x1);155 bool MakeNormalVector(const vector *y1);156 bool MakeNormalVector(const vector *y1, const vector *y2);157 bool MakeNormalVector(const vector *x1, const vector *x2, const vector *x3);158 bool SolveSystem(vector *x1, vector *x2, vector *y, double alpha, double beta, double c);159 bool LSQdistance(vector **vectors, int dim);160 161 void AskPosition(double *cell_size, bool check);162 bool Output(ofstream *out) const;163 };164 165 ofstream& operator<<(ofstream& ost, vector& m);166 122 167 123 /** Parameter structure for least square minimsation. … … 300 256 /// Find atoms. 301 257 atom * FindAtom(int Nr) const; 302 atom * AskAtom( char *text);258 atom * AskAtom(string text); 303 259 304 260 /// Count and change present atoms' coordination. … … 306 262 void CountElements(); 307 263 void CalculateOrbitals(class config &configuration); 264 bool CenterInBox(ofstream *out, vector *BoxLengths); 308 265 void CenterEdge(ofstream *out, vector *max); 309 266 void CenterOrigin(ofstream *out, vector *max); … … 335 292 void ResetAllAtomNumbers(); 336 293 int CountCyclicBonds(ofstream *out); 337 char *GetColor(enum Shading color);294 string GetColor(enum Shading color); 338 295 339 296 molecule *CopyMolecule(); … … 500 457 void Load(char *filename, periodentafel *periode, molecule *mol); 501 458 void LoadOld(char *filename, periodentafel *periode, molecule *mol); 502 void RetrieveConfigPathAndName(char * filename);459 void RetrieveConfigPathAndName(char * filename); 503 460 bool Save(ofstream *file, periodentafel *periode, molecule *mol) const; 504 461 void Edit(molecule *mol); 505 462 bool GetIsAngstroem() const; 506 463 char *GetDefaultPath() const; 507 void config::SetDefaultPath(const char *path);464 void SetDefaultPath(const char *path); 508 465 }; 509 466 -
molecuilder/src/vector.cpp
re9c14d r725869 182 182 }; 183 183 184 /** Sums vector \a to this lhs component-wise. 185 * \param a base vector 186 * \param b vector components to add 187 * \return lhs + a 188 */ 189 vector& operator+=(vector& a, const vector& b) 190 { 191 a.AddVector(&b); 192 return a; 193 }; 194 /** factor each component of \a a times a double \a m. 195 * \param a base vector 196 * \param m factor 197 * \return lhs.x[i] * m 198 */ 199 vector& operator*=(vector& a, const double m) 200 { 201 a.Scale(m); 202 return a; 203 }; 204 205 /** Sums two vectors \a and \b component-wise. 206 * \param a first vector 207 * \param b second vector 208 * \return a + b 209 */ 210 vector& operator+(const vector& a, const vector& b) 211 { 212 vector *x = new vector; 213 x->CopyVector(&a); 214 x->AddVector(&b); 215 return *x; 216 }; 217 218 /** Factors given vector \a a times \a m. 219 * \param a vector 220 * \param m factor 221 * \return a + b 222 */ 223 vector& operator*(const vector& a, const double m) 224 { 225 vector *x = new vector; 226 x->CopyVector(&a); 227 x->Scale(m); 228 return *x; 229 }; 230 184 231 /** Prints a 3dim vector. 185 232 * prints no end of line. … … 213 260 { 214 261 for (int i=0;i<NDIM;i++) 215 this->x[i] *= (*factor)[i];262 x[i] *= (*factor)[i]; 216 263 }; 217 264 … … 219 266 { 220 267 for (int i=0;i<NDIM;i++) 221 this->x[i] *= *factor;268 x[i] *= *factor; 222 269 }; 223 270 … … 225 272 { 226 273 for (int i=0;i<NDIM;i++) 227 this->x[i] *= factor;274 x[i] *= factor; 228 275 }; 229 276
Note:
See TracChangeset
for help on using the changeset viewer.