Changeset a9b2a0a for molecuilder/src/vector.cpp
- Timestamp:
- Oct 27, 2009, 4:11:22 PM (16 years ago)
- Children:
- 069034
- Parents:
- 55a71b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/vector.cpp
r55a71b ra9b2a0a 21 21 /** Constructor of class vector. 22 22 */ 23 Vector::Vector( double x1, double x2,double x3) { x[0] = x1; x[1] = x2; x[2] = x3; };23 Vector::Vector(const double x1, const double x2, const double x3) { x[0] = x1; x[1] = x2; x[2] = x3; }; 24 24 25 25 /** Desctructor of class vector. … … 31 31 * \return \f$| x - y |^2\f$ 32 32 */ 33 double Vector::DistanceSquared(const Vector * y) const33 double Vector::DistanceSquared(const Vector * const y) const 34 34 { 35 35 double res = 0.; … … 43 43 * \return \f$| x - y |\f$ 44 44 */ 45 double Vector::Distance(const Vector * y) const45 double Vector::Distance(const Vector * const y) const 46 46 { 47 47 double res = 0.; … … 56 56 * \return \f$| x - y |\f$ 57 57 */ 58 double Vector::PeriodicDistance(const Vector * y, const double *cell_size) const58 double Vector::PeriodicDistance(const Vector * const y, const double * const cell_size) const 59 59 { 60 60 double res = Distance(y), tmp, matrix[NDIM*NDIM]; … … 94 94 * \return \f$| x - y |^2\f$ 95 95 */ 96 double Vector::PeriodicDistanceSquared(const Vector * y, const double *cell_size) const96 double Vector::PeriodicDistanceSquared(const Vector * const y, const double * const cell_size) const 97 97 { 98 98 double res = DistanceSquared(y), tmp, matrix[NDIM*NDIM]; … … 131 131 * Tries to translate a vector into each adjacent neighbouring cell. 132 132 */ 133 void Vector::KeepPeriodic(ofstream *out, double *matrix)133 void Vector::KeepPeriodic(ofstream *out, const double * const matrix) 134 134 { 135 135 // int N[NDIM]; … … 162 162 * \return \f$\langle x, y \rangle\f$ 163 163 */ 164 double Vector::ScalarProduct(const Vector * y) const164 double Vector::ScalarProduct(const Vector * const y) const 165 165 { 166 166 double res = 0.; … … 177 177 * \return \f$ x \times y \f& 178 178 */ 179 void Vector::VectorProduct(const Vector * y)179 void Vector::VectorProduct(const Vector * const y) 180 180 { 181 181 Vector tmp; … … 184 184 tmp.x[2] = x[0]* (y->x[1]) - x[1]* (y->x[0]); 185 185 this->CopyVector(&tmp); 186 187 186 }; 188 187 … … 192 191 * \return \f$\langle x, y \rangle\f$ 193 192 */ 194 void Vector::ProjectOntoPlane(const Vector * y)193 void Vector::ProjectOntoPlane(const Vector * const y) 195 194 { 196 195 Vector tmp; … … 217 216 * \return true - \a this contains intersection point on return, false - line is parallel to plane 218 217 */ 219 bool Vector::GetIntersectionWithPlane(ofstream *out, Vector *PlaneNormal, Vector *PlaneOffset, Vector *Origin, Vector *LineVector)218 bool Vector::GetIntersectionWithPlane(ofstream *out, const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector) 220 219 { 221 220 double factor; … … 264 263 * \return distance to plane 265 264 */ 266 double Vector::DistanceToPlane(ofstream *out, Vector *PlaneNormal, Vector *PlaneOffset)265 double Vector::DistanceToPlane(ofstream *out, const Vector * const PlaneNormal, const Vector * const PlaneOffset) const 267 266 { 268 267 Vector temp; … … 292 291 * \return true - \a this will contain the intersection on return, false - lines are parallel 293 292 */ 294 bool Vector::GetIntersectionOfTwoLinesOnPlane(ofstream *out, Vector *Line1a, Vector *Line1b, Vector *Line2a, Vector *Line2b, const Vector *PlaneNormal)293 bool Vector::GetIntersectionOfTwoLinesOnPlane(ofstream *out, const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *PlaneNormal) 295 294 { 296 295 bool result = true; … … 375 374 * \param *y array to second vector 376 375 */ 377 void Vector::ProjectIt(const Vector * y)376 void Vector::ProjectIt(const Vector * const y) 378 377 { 379 378 Vector helper(*y); … … 386 385 * \return Vector 387 386 */ 388 Vector Vector::Projection(const Vector * y) const387 Vector Vector::Projection(const Vector * const y) const 389 388 { 390 389 Vector helper(*y); … … 435 434 /** Zeros all components of this vector. 436 435 */ 437 void Vector::One( double one)436 void Vector::One(const double one) 438 437 { 439 438 for (int i=NDIM;i--;) … … 443 442 /** Initialises all components of this vector. 444 443 */ 445 void Vector::Init( double x1, double x2,double x3)444 void Vector::Init(const double x1, const double x2, const double x3) 446 445 { 447 446 x[0] = x1; … … 469 468 * @return true - vector is normalized, false - vector is not 470 469 */ 471 bool Vector::IsNormalTo(const Vector * normal) const470 bool Vector::IsNormalTo(const Vector * const normal) const 472 471 { 473 472 if (ScalarProduct(normal) < MYEPSILON) … … 481 480 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$ 482 481 */ 483 double Vector::Angle(const Vector * y) const482 double Vector::Angle(const Vector * const y) const 484 483 { 485 484 double norm1 = Norm(), norm2 = y->Norm(); … … 500 499 * \param alpha rotation angle in radian 501 500 */ 502 void Vector::RotateVector(const Vector * axis, const double alpha)501 void Vector::RotateVector(const Vector * const axis, const double alpha) 503 502 { 504 503 Vector a,y; … … 656 655 * \param *factor pointer to scaling factor 657 656 */ 658 void Vector::Scale( double **factor)657 void Vector::Scale(const double ** const factor) 659 658 { 660 659 for (int i=NDIM;i--;) … … 662 661 }; 663 662 664 void Vector::Scale( double *factor)663 void Vector::Scale(const double * const factor) 665 664 { 666 665 for (int i=NDIM;i--;) … … 668 667 }; 669 668 670 void Vector::Scale( double factor)669 void Vector::Scale(const double factor) 671 670 { 672 671 for (int i=NDIM;i--;) … … 677 676 * \param trans[] translation vector. 678 677 */ 679 void Vector::Translate(const Vector * trans)678 void Vector::Translate(const Vector * const trans) 680 679 { 681 680 for (int i=NDIM;i--;) … … 687 686 * \param *Minv inverse matrix 688 687 */ 689 void Vector::WrapPeriodically(const double * M, const double *Minv)688 void Vector::WrapPeriodically(const double * const M, const double * const Minv) 690 689 { 691 690 MatrixMultiplication(Minv); … … 704 703 * \param *matrix NDIM_NDIM array 705 704 */ 706 void Vector::MatrixMultiplication(const double * M)705 void Vector::MatrixMultiplication(const double * const M) 707 706 { 708 707 Vector C; … … 719 718 * \param *matrix NDIM_NDIM array 720 719 */ 721 double * Vector::InverseMatrix( double *A)720 double * Vector::InverseMatrix( const double * const A) 722 721 { 723 722 double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B"); … … 746 745 * \param *matrix NDIM_NDIM array 747 746 */ 748 void Vector::InverseMatrixMultiplication(const double * A)747 void Vector::InverseMatrixMultiplication(const double * const A) 749 748 { 750 749 Vector C; … … 786 785 * \param *factors three-component vector with the factor for each given vector 787 786 */ 788 void Vector::LinearCombinationOfVectors(const Vector * x1, const Vector *x2, const Vector *x3, double *factors)787 void Vector::LinearCombinationOfVectors(const Vector * const x1, const Vector * const x2, const Vector * const x3, const double * const factors) 789 788 { 790 789 for(int i=NDIM;i--;) … … 795 794 * \param n[] normal vector of mirror plane. 796 795 */ 797 void Vector::Mirror(const Vector * n)796 void Vector::Mirror(const Vector * const n) 798 797 { 799 798 double projection; … … 817 816 * \return true - success, vectors are linear independent, false - failure due to linear dependency 818 817 */ 819 bool Vector::MakeNormalVector(const Vector * y1, const Vector *y2, const Vector *y3)818 bool Vector::MakeNormalVector(const Vector * const y1, const Vector * const y2, const Vector * const y3) 820 819 { 821 820 Vector x1, x2; … … 853 852 * \return true - success, vectors are linear independent, false - failure due to linear dependency 854 853 */ 855 bool Vector::MakeNormalVector(const Vector * y1, const Vector *y2)854 bool Vector::MakeNormalVector(const Vector * const y1, const Vector * const y2) 856 855 { 857 856 Vector x1,x2; … … 884 883 * \return true - success, false - vector is zero 885 884 */ 886 bool Vector::MakeNormalVector(const Vector * y1)885 bool Vector::MakeNormalVector(const Vector * const y1) 887 886 { 888 887 bool result = false; … … 904 903 * \return true - success, false - failure (null vector given) 905 904 */ 906 bool Vector::GetOneNormalVector(const Vector * GivenVector)905 bool Vector::GetOneNormalVector(const Vector * const GivenVector) 907 906 { 908 907 int Components[NDIM]; // contains indices of non-zero components … … 950 949 * \return scaling parameter for this vector 951 950 */ 952 double Vector::CutsPlaneAt( Vector *A, Vector *B, Vector *C)951 double Vector::CutsPlaneAt(const Vector * const A, const Vector * const B, const Vector * const C) const 953 952 { 954 953 // cout << Verbose(3) << "For comparison: "; … … 965 964 * \return true if success, false if failed due to linear dependency 966 965 */ 967 bool Vector::LSQdistance( Vector **vectors, int num)966 bool Vector::LSQdistance(const Vector **vectors, int num) 968 967 { 969 968 int j; … … 1047 1046 * \param *y vector 1048 1047 */ 1049 void Vector::AddVector(const Vector * y)1048 void Vector::AddVector(const Vector * const y) 1050 1049 { 1051 1050 for (int i=NDIM;i--;) … … 1056 1055 * \param *y vector 1057 1056 */ 1058 void Vector::SubtractVector(const Vector * y)1057 void Vector::SubtractVector(const Vector * const y) 1059 1058 { 1060 1059 for (int i=NDIM;i--;) … … 1065 1064 * \param *y vector 1066 1065 */ 1067 void Vector::CopyVector(const Vector * y)1066 void Vector::CopyVector(const Vector * const y) 1068 1067 { 1069 1068 for (int i=NDIM;i--;) … … 1074 1073 * \param y vector 1075 1074 */ 1076 void Vector::CopyVector(const Vector y)1075 void Vector::CopyVector(const Vector &y) 1077 1076 { 1078 1077 for (int i=NDIM;i--;) … … 1085 1084 * \param check whether bounds shall be checked (true) or not (false) 1086 1085 */ 1087 void Vector::AskPosition( double *cell_size,bool check)1086 void Vector::AskPosition(const double * const cell_size, const bool check) 1088 1087 { 1089 1088 char coords[3] = {'x','y','z'}; … … 1113 1112 * \bug this is not yet working properly 1114 1113 */ 1115 bool Vector::SolveSystem(Vector * x1, Vector *x2, Vector *y, double alpha, double beta,double c)1114 bool Vector::SolveSystem(Vector * x1, Vector * x2, Vector * y, const double alpha, const double beta, const double c) 1116 1115 { 1117 1116 double D1,D2,D3,E1,E2,F1,F2,F3,p,q=0., A, B1, B2, C; … … 1276 1275 * @param three vectors forming the matrix that defines the shape of the parallelpiped 1277 1276 */ 1278 bool Vector::IsInParallelepiped(const Vector offset, const double *parallelepiped) const1277 bool Vector::IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const 1279 1278 { 1280 1279 Vector a;
Note:
See TracChangeset
for help on using the changeset viewer.