Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/vector.cpp

    ra67d19 rb34306  
    253253  Direction.SubtractVector(Origin);
    254254  Direction.Normalize();
    255   DoLog(1) && (Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl);
     255  Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl;
    256256  //Log() << Verbose(1) << "INFO: PlaneNormal is " << *PlaneNormal << " and PlaneOffset is " << *PlaneOffset << "." << endl;
    257257  factor = Direction.ScalarProduct(PlaneNormal);
    258258  if (fabs(factor) < MYEPSILON) { // Uniqueness: line parallel to plane?
    259     DoLog(1) && (Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl);
     259    Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl;
    260260    return false;
    261261  }
     
    264264  factor = helper.ScalarProduct(PlaneNormal)/factor;
    265265  if (fabs(factor) < MYEPSILON) { // Origin is in-plane
    266     DoLog(1) && (Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl);
     266    Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl;
    267267    CopyVector(Origin);
    268268    return true;
     
    271271  Direction.Scale(factor);
    272272  CopyVector(Origin);
    273   DoLog(1) && (Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl);
     273  Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl;
    274274  AddVector(&Direction);
    275275
     
    278278  helper.SubtractVector(PlaneOffset);
    279279  if (helper.ScalarProduct(PlaneNormal) < MYEPSILON) {
    280     DoLog(1) && (Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl);
     280    Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl;
    281281    return true;
    282282  } else {
    283     DoeLog(2) && (eLog()<< Verbose(2) << "Intersection point " << *this << " is not on plane." << endl);
     283    eLog() << Verbose(2) << "Intersection point " << *this << " is not on plane." << endl;
    284284    return false;
    285285  }
     
    352352 
    353353  //Log() << Verbose(1) << "Coefficent matrix is:" << endl;
    354   //ostream &output = Log() << Verbose(1);
    355354  //for (int i=0;i<4;i++) {
    356355  //  for (int j=0;j<4;j++)
    357   //    output << "\t" << M->Get(i,j);
    358   //  output << endl;
     356  //    cout << "\t" << M->Get(i,j);
     357  //  cout << endl;
    359358  //}
    360359  if (fabs(M->Determinant()) > MYEPSILON) {
    361     DoLog(1) && (Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl);
     360    Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl;
    362361    return false;
    363362  }
    364   DoLog(1) && (Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl);
     363  Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl;
    365364
    366365
     
    378377  d.CopyVector(Line2b);
    379378  d.SubtractVector(Line1b);
    380   DoLog(1) && (Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl);
     379  Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl;
    381380  if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) {
    382381   Zero();
    383    DoLog(1) && (Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl);
     382   Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl;
    384383   return false;
    385384  }
     
    394393    if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    395394      CopyVector(Line2a);
    396       DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl);
     395      Log() << Verbose(1) << "Lines conincide." << endl;
    397396      return true;
    398397    } else {
     
    402401      if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    403402        CopyVector(Line2b);
    404         DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl);
     403        Log() << Verbose(1) << "Lines conincide." << endl;
    405404        return true;
    406405      }
    407406    }
    408     DoLog(1) && (Log() << Verbose(1) << "Lines are parallel." << endl);
     407    Log() << Verbose(1) << "Lines are parallel." << endl;
    409408    Zero();
    410409    return false;
     
    418417  temp2.CopyVector(&a);
    419418  temp2.VectorProduct(&b);
    420   DoLog(1) && (Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl);
     419  Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl;
    421420  if (fabs(temp2.NormSquared()) > MYEPSILON)
    422421    s = temp1.ScalarProduct(&temp2)/temp2.NormSquared();
    423422  else
    424423    s = 0.;
    425   DoLog(1) && (Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl);
     424  Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;
    426425
    427426  // construct intersection
     
    429428  Scale(s);
    430429  AddVector(Line1a);
    431   DoLog(1) && (Log() << Verbose(1) << "Intersection is at " << *this << "." << endl);
     430  Log() << Verbose(1) << "Intersection is at " << *this << "." << endl;
    432431
    433432  return true;
     
    702701void Vector::Output() const
    703702{
    704   DoLog(0) && (Log() << Verbose(0) << "(");
     703  Log() << Verbose(0) << "(";
    705704  for (int i=0;i<NDIM;i++) {
    706     DoLog(0) && (Log() << Verbose(0) << x[i]);
     705    Log() << Verbose(0) << x[i];
    707706    if (i != 2)
    708       DoLog(0) && (Log() << Verbose(0) << ",");
    709   }
    710   DoLog(0) && (Log() << Verbose(0) << ")");
     707      Log() << Verbose(0) << ",";
     708  }
     709  Log() << Verbose(0) << ")";
    711710};
    712711
     
    817816      x[i] = C.x[i];
    818817  } else {
    819     DoeLog(1) && (eLog()<< Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl);
     818    eLog() << Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl;
    820819  }
    821820};
     
    843842  projection = ScalarProduct(n)/n->ScalarProduct(n);    // remove constancy from n (keep as logical one)
    844843  // withdraw projected vector twice from original one
    845   DoLog(1) && (Log() << Verbose(1) << "Vector: ");
     844  Log() << Verbose(1) << "Vector: ";
    846845  Output();
    847   DoLog(0) && (Log() << Verbose(0) << "\t");
     846  Log() << Verbose(0) << "\t";
    848847  for (int i=NDIM;i--;)
    849848    x[i] -= 2.*projection*n->x[i];
    850   DoLog(0) && (Log() << Verbose(0) << "Projected vector: ");
     849  Log() << Verbose(0) << "Projected vector: ";
    851850  Output();
    852   DoLog(0) && (Log() << Verbose(0) << endl);
     851  Log() << Verbose(0) << endl;
    853852};
    854853
     
    869868  x2.SubtractVector(y2);
    870869  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
    871     DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl);
     870    eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;
    872871    return false;
    873872  }
     
    903902  Zero();
    904903  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
    905     DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl);
     904    eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;
    906905    return false;
    907906  }
     
    954953  double norm;
    955954
    956   DoLog(4) && (Log() << Verbose(4));
     955  Log() << Verbose(4);
    957956  GivenVector->Output();
    958   DoLog(0) && (Log() << Verbose(0) << endl);
     957  Log() << Verbose(0) << endl;
    959958  for (j=NDIM;j--;)
    960959    Components[j] = -1;
     
    963962    if (fabs(GivenVector->x[j]) > MYEPSILON)
    964963      Components[Last++] = j;
    965   DoLog(4) && (Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl);
     964  Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl;
    966965
    967966  switch(Last) {
     
    10131012
    10141013  for (j=0;j<num;j++) {
    1015     DoLog(1) && (Log() << Verbose(1) << j << "th atom's vector: ");
     1014    Log() << Verbose(1) << j << "th atom's vector: ";
    10161015    (vectors[j])->Output();
    1017     DoLog(0) && (Log() << Verbose(0) << endl);
     1016    Log() << Verbose(0) << endl;
    10181017  }
    10191018
     
    11351134    j += i+1;
    11361135    do {
    1137       DoLog(0) && (Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ");
     1136      Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ";
    11381137      cin >> x[i];
    11391138    } while (((x[i] < 0) || (x[i] >= cell_size[j])) && (check));
     
    11661165  B2 = cos(beta) * x2->Norm() * c;
    11671166  C = c * c;
    1168   DoLog(2) && (Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl);
     1167  Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl;
    11691168  int flag = 0;
    11701169  if (fabs(x1->x[0]) < MYEPSILON) { // check for zero components for the later flipping and back-flipping
     
    12051204  D2 = -y->x[0]/x1->x[0]*x1->x[2]+y->x[2];
    12061205  D3 = y->x[0]/x1->x[0]*A-B1;
    1207   DoLog(2) && (Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n");
     1206  Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n";
    12081207  if (fabs(D1) < MYEPSILON) {
    1209     DoLog(2) && (Log() << Verbose(2) << "D1 == 0!\n");
     1208    Log() << Verbose(2) << "D1 == 0!\n";
    12101209    if (fabs(D2) > MYEPSILON) {
    1211       DoLog(3) && (Log() << Verbose(3) << "D2 != 0!\n");
     1210      Log() << Verbose(3) << "D2 != 0!\n";
    12121211      x[2] = -D3/D2;
    12131212      E1 = A/x1->x[0] + x1->x[2]/x1->x[0]*D3/D2;
    12141213      E2 = -x1->x[1]/x1->x[0];
    1215       DoLog(3) && (Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n");
     1214      Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n";
    12161215      F1 = E1*E1 + 1.;
    12171216      F2 = -E1*E2;
    12181217      F3 = E1*E1 + D3*D3/(D2*D2) - C;
    1219       DoLog(3) && (Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n");
     1218      Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";
    12201219      if (fabs(F1) < MYEPSILON) {
    1221         DoLog(4) && (Log() << Verbose(4) << "F1 == 0!\n");
    1222         DoLog(4) && (Log() << Verbose(4) << "Gleichungssystem linear\n");
     1220        Log() << Verbose(4) << "F1 == 0!\n";
     1221        Log() << Verbose(4) << "Gleichungssystem linear\n";
    12231222        x[1] = F3/(2.*F2);
    12241223      } else {
    12251224        p = F2/F1;
    12261225        q = p*p - F3/F1;
    1227         DoLog(4) && (Log() << Verbose(4) << "p " << p << "\tq " << q << endl);
     1226        Log() << Verbose(4) << "p " << p << "\tq " << q << endl;
    12281227        if (q < 0) {
    1229           DoLog(4) && (Log() << Verbose(4) << "q < 0" << endl);
     1228          Log() << Verbose(4) << "q < 0" << endl;
    12301229          return false;
    12311230        }
     
    12341233      x[0] =  A/x1->x[0] - x1->x[1]/x1->x[0]*x[1] + x1->x[2]/x1->x[0]*x[2];
    12351234    } else {
    1236       DoLog(2) && (Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n");
     1235      Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n";
    12371236      return false;
    12381237    }
     
    12401239    E1 = A/x1->x[0]+x1->x[1]/x1->x[0]*D3/D1;
    12411240    E2 = x1->x[1]/x1->x[0]*D2/D1 - x1->x[2];
    1242     DoLog(2) && (Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n");
     1241    Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n";
    12431242    F1 = E2*E2 + D2*D2/(D1*D1) + 1.;
    12441243    F2 = -(E1*E2 + D2*D3/(D1*D1));
    12451244    F3 = E1*E1 + D3*D3/(D1*D1) - C;
    1246     DoLog(2) && (Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n");
     1245    Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";
    12471246    if (fabs(F1) < MYEPSILON) {
    1248       DoLog(3) && (Log() << Verbose(3) << "F1 == 0!\n");
    1249       DoLog(3) && (Log() << Verbose(3) << "Gleichungssystem linear\n");
     1247      Log() << Verbose(3) << "F1 == 0!\n";
     1248      Log() << Verbose(3) << "Gleichungssystem linear\n";
    12501249      x[2] = F3/(2.*F2);
    12511250    } else {
    12521251      p = F2/F1;
    12531252      q = p*p - F3/F1;
    1254       DoLog(3) && (Log() << Verbose(3) << "p " << p << "\tq " << q << endl);
     1253      Log() << Verbose(3) << "p " << p << "\tq " << q << endl;
    12551254      if (q < 0) {
    1256         DoLog(3) && (Log() << Verbose(3) << "q < 0" << endl);
     1255        Log() << Verbose(3) << "q < 0" << endl;
    12571256        return false;
    12581257      }
     
    12921291    for (j=2;j>=0;j--) {
    12931292      k = (i & pot(2,j)) << j;
    1294       DoLog(2) && (Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl);
     1293      Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl;
    12951294      sign[j] = (k == 0) ? 1. : -1.;
    12961295    }
    1297     DoLog(2) && (Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n");
     1296    Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n";
    12981297    // apply sign matrix
    12991298    for (j=NDIM;j--;)
     
    13011300    // calculate angle and check
    13021301    ang = x2->Angle (this);
    1303     DoLog(1) && (Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t");
     1302    Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t";
    13041303    if (fabs(ang - cos(beta)) < MYEPSILON) {
    13051304      break;
Note: See TracChangeset for help on using the changeset viewer.