Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/vector.cpp

    r29812d rd09ff7  
    225225  Direction.CopyVector(LineVector);
    226226  Direction.SubtractVector(Origin);
     227  Direction.Normalize();
    227228  //*out << Verbose(4) << "INFO: Direction is " << Direction << "." << endl;
    228229  factor = Direction.ScalarProduct(PlaneNormal);
     
    234235  helper.SubtractVector(Origin);
    235236  factor = helper.ScalarProduct(PlaneNormal)/factor;
     237  if (factor < MYEPSILON) { // Origin is in-plane
     238    //*out << Verbose(2) << "Origin of line is in-plane, simple." << endl;
     239    CopyVector(Origin);
     240    return true;
     241  }
    236242  //factor = Origin->ScalarProduct(PlaneNormal)*(-PlaneOffset->ScalarProduct(PlaneNormal))/(Direction.ScalarProduct(PlaneNormal));
    237243  Direction.Scale(factor);
     
    655661};
    656662
     663/** Given a box by its matrix \a *M and its inverse *Minv the vector is made to point within that box.
     664 * \param *M matrix of box
     665 * \param *Minv inverse matrix
     666 */
     667void Vector::WrapPeriodically(const double *M, const double *Minv)
     668{
     669  MatrixMultiplication(Minv);
     670  // truncate to [0,1] for each axis
     671  for (int i=0;i<NDIM;i++) {
     672    x[i] += 0.5;  // set to center of box
     673    while (x[i] >= 1.)
     674      x[i] -= 1.;
     675    while (x[i] < 0.)
     676      x[i] += 1.;
     677  }
     678  MatrixMultiplication(M);
     679};
     680
    657681/** Do a matrix multiplication.
    658682 * \param *matrix NDIM_NDIM array
    659683 */
    660 void Vector::MatrixMultiplication(double *M)
     684void Vector::MatrixMultiplication(const double *M)
    661685{
    662686  Vector C;
     
    700724 * \param *matrix NDIM_NDIM array
    701725 */
    702 void Vector::InverseMatrixMultiplication(double *A)
     726void Vector::InverseMatrixMultiplication(const double *A)
    703727{
    704728  Vector C;
Note: See TracChangeset for help on using the changeset viewer.