Changeset 68fbb5
- Timestamp:
- Jun 10, 2008, 11:15:52 AM (17 years ago)
- Children:
- b9a995
- Parents:
- c4a0a2
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/vector.cpp
rc4a0a2 r68fbb5 13 13 */ 14 14 vector::vector() { x[0] = x[1] = x[2] = 0.; }; 15 16 /** Constructor of class vector.17 */18 vector::vector(double x1, double x2, double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };19 15 20 16 /** Desctructor of class vector. … … 115 111 }; 116 112 117 /** projects this vector onto plane defined by \a *y.118 * \param *y array to normal vector of plane119 * \return \f$\langle x, y \rangle\f$120 */121 void vector::ProjectOntoPlane(const vector *y)122 {123 vector tmp;124 tmp.CopyVector(y);125 tmp.Scale(Projection(y));126 this->SubtractVector(&tmp);127 };128 129 113 /** Calculates the projection of a vector onto another \a *y. 130 114 * \param *y array to second vector … … 133 117 double vector::Projection(const vector *y) const 134 118 { 135 return (ScalarProduct(y) );119 return (ScalarProduct(y)/Norm()/y->Norm()); 136 120 }; 137 121 … … 166 150 }; 167 151 168 /** Zeros all components of this vector.169 */170 void vector::One(double one)171 {172 for (int i=NDIM;i--;)173 this->x[i] = one;174 };175 176 /** Initialises all components of this vector.177 */178 void vector::Init(double x1, double x2, double x3)179 {180 x[0] = x1;181 x[1] = x2;182 x[2] = x3;183 };184 185 152 /** Calculates the angle between this and another vector. 186 153 * \param *y array to second vector 187 * \return \f$\ acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$154 * \return \f$\frac{\langle x, y \rangle}{|x||y|}\f$ 188 155 */ 189 156 double vector::Angle(vector *y) const 190 157 { 191 return acos(this->ScalarProduct(y)/Norm()/y->Norm());158 return (this->ScalarProduct(y)/(this->Norm()*y->Norm())); 192 159 }; 193 160 -
molecuilder/src/vector.hpp
rc4a0a2 r68fbb5 10 10 11 11 vector(); 12 vector(double x1, double x2, double x3);13 12 ~vector(); 14 13 … … 24 23 void CopyVector(const vector *y); 25 24 void RotateVector(const vector *y, const double alpha); 26 void Zero(); 27 void One(double one = 1.); 28 void Init(double x1, double x2, double x3); 25 void Zero(); 29 26 void Normalize(); 30 27 void Translate(const vector *x); 31 28 void Mirror(const vector *x); 32 void ProjectOntoPlane(const vector *y);33 29 void Scale(double **factor); 34 30 void Scale(double *factor);
Note:
See TracChangeset
for help on using the changeset viewer.