Changeset d11f22
- Timestamp:
- Jun 10, 2008, 11:11:22 AM (17 years ago)
- Children:
- c4a0a2
- Parents:
- 32b6dc
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/vector.cpp
r32b6dc rd11f22 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; }; 15 19 16 20 /** Desctructor of class vector. … … 111 115 }; 112 116 117 /** projects this vector onto plane defined by \a *y. 118 * \param *y array to normal vector of plane 119 * \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 113 129 /** Calculates the projection of a vector onto another \a *y. 114 130 * \param *y array to second vector … … 117 133 double vector::Projection(const vector *y) const 118 134 { 119 return (ScalarProduct(y) /Norm()/y->Norm());135 return (ScalarProduct(y)); 120 136 }; 121 137 … … 150 166 }; 151 167 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 152 185 /** Calculates the angle between this and another vector. 153 186 * \param *y array to second vector 154 * \return \f$\ frac{\langle x, y \rangle}{|x||y|}\f$187 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$ 155 188 */ 156 189 double vector::Angle(vector *y) const 157 190 { 158 return (this->ScalarProduct(y)/(this->Norm()*y->Norm()));191 return acos(this->ScalarProduct(y)/Norm()/y->Norm()); 159 192 }; 160 193 -
molecuilder/src/vector.hpp
r32b6dc rd11f22 10 10 11 11 vector(); 12 vector(double x1, double x2, double x3); 12 13 ~vector(); 13 14 … … 23 24 void CopyVector(const vector *y); 24 25 void RotateVector(const vector *y, const double alpha); 25 void Zero(); 26 void Zero(); 27 void One(double one = 1.); 28 void Init(double x1, double x2, double x3); 26 29 void Normalize(); 27 30 void Translate(const vector *x); 28 31 void Mirror(const vector *x); 32 void ProjectOntoPlane(const vector *y); 29 33 void Scale(double **factor); 30 34 void Scale(double *factor);
Note:
See TracChangeset
for help on using the changeset viewer.