Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/vector.cpp

    rb34306 ra67d19  
    253253  Direction.SubtractVector(Origin);
    254254  Direction.Normalize();
    255   Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl;
     255  DoLog(1) && (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     Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl;
     259    DoLog(1) && (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     Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl;
     266    DoLog(1) && (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   Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl;
     273  DoLog(1) && (Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl);
    274274  AddVector(&Direction);
    275275
     
    278278  helper.SubtractVector(PlaneOffset);
    279279  if (helper.ScalarProduct(PlaneNormal) < MYEPSILON) {
    280     Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl;
     280    DoLog(1) && (Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl);
    281281    return true;
    282282  } else {
    283     eLog() << Verbose(2) << "Intersection point " << *this << " is not on plane." << endl;
     283    DoeLog(2) && (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);
    354355  //for (int i=0;i<4;i++) {
    355356  //  for (int j=0;j<4;j++)
    356   //    cout << "\t" << M->Get(i,j);
    357   //  cout << endl;
     357  //    output << "\t" << M->Get(i,j);
     358  //  output << endl;
    358359  //}
    359360  if (fabs(M->Determinant()) > MYEPSILON) {
    360     Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl;
     361    DoLog(1) && (Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl);
    361362    return false;
    362363  }
    363   Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl;
     364  DoLog(1) && (Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl);
    364365
    365366
     
    377378  d.CopyVector(Line2b);
    378379  d.SubtractVector(Line1b);
    379   Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl;
     380  DoLog(1) && (Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl);
    380381  if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) {
    381382   Zero();
    382    Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl;
     383   DoLog(1) && (Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl);
    383384   return false;
    384385  }
     
    393394    if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    394395      CopyVector(Line2a);
    395       Log() << Verbose(1) << "Lines conincide." << endl;
     396      DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl);
    396397      return true;
    397398    } else {
     
    401402      if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    402403        CopyVector(Line2b);
    403         Log() << Verbose(1) << "Lines conincide." << endl;
     404        DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl);
    404405        return true;
    405406      }
    406407    }
    407     Log() << Verbose(1) << "Lines are parallel." << endl;
     408    DoLog(1) && (Log() << Verbose(1) << "Lines are parallel." << endl);
    408409    Zero();
    409410    return false;
     
    417418  temp2.CopyVector(&a);
    418419  temp2.VectorProduct(&b);
    419   Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl;
     420  DoLog(1) && (Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl);
    420421  if (fabs(temp2.NormSquared()) > MYEPSILON)
    421422    s = temp1.ScalarProduct(&temp2)/temp2.NormSquared();
    422423  else
    423424    s = 0.;
    424   Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;
     425  DoLog(1) && (Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl);
    425426
    426427  // construct intersection
     
    428429  Scale(s);
    429430  AddVector(Line1a);
    430   Log() << Verbose(1) << "Intersection is at " << *this << "." << endl;
     431  DoLog(1) && (Log() << Verbose(1) << "Intersection is at " << *this << "." << endl);
    431432
    432433  return true;
     
    701702void Vector::Output() const
    702703{
    703   Log() << Verbose(0) << "(";
     704  DoLog(0) && (Log() << Verbose(0) << "(");
    704705  for (int i=0;i<NDIM;i++) {
    705     Log() << Verbose(0) << x[i];
     706    DoLog(0) && (Log() << Verbose(0) << x[i]);
    706707    if (i != 2)
    707       Log() << Verbose(0) << ",";
    708   }
    709   Log() << Verbose(0) << ")";
     708      DoLog(0) && (Log() << Verbose(0) << ",");
     709  }
     710  DoLog(0) && (Log() << Verbose(0) << ")");
    710711};
    711712
     
    816817      x[i] = C.x[i];
    817818  } else {
    818     eLog() << Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl;
     819    DoeLog(1) && (eLog()<< Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl);
    819820  }
    820821};
     
    842843  projection = ScalarProduct(n)/n->ScalarProduct(n);    // remove constancy from n (keep as logical one)
    843844  // withdraw projected vector twice from original one
    844   Log() << Verbose(1) << "Vector: ";
     845  DoLog(1) && (Log() << Verbose(1) << "Vector: ");
    845846  Output();
    846   Log() << Verbose(0) << "\t";
     847  DoLog(0) && (Log() << Verbose(0) << "\t");
    847848  for (int i=NDIM;i--;)
    848849    x[i] -= 2.*projection*n->x[i];
    849   Log() << Verbose(0) << "Projected vector: ";
     850  DoLog(0) && (Log() << Verbose(0) << "Projected vector: ");
    850851  Output();
    851   Log() << Verbose(0) << endl;
     852  DoLog(0) && (Log() << Verbose(0) << endl);
    852853};
    853854
     
    868869  x2.SubtractVector(y2);
    869870  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
    870     eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;
     871    DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl);
    871872    return false;
    872873  }
     
    902903  Zero();
    903904  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
    904     eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;
     905    DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl);
    905906    return false;
    906907  }
     
    953954  double norm;
    954955
    955   Log() << Verbose(4);
     956  DoLog(4) && (Log() << Verbose(4));
    956957  GivenVector->Output();
    957   Log() << Verbose(0) << endl;
     958  DoLog(0) && (Log() << Verbose(0) << endl);
    958959  for (j=NDIM;j--;)
    959960    Components[j] = -1;
     
    962963    if (fabs(GivenVector->x[j]) > MYEPSILON)
    963964      Components[Last++] = j;
    964   Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl;
     965  DoLog(4) && (Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl);
    965966
    966967  switch(Last) {
     
    10121013
    10131014  for (j=0;j<num;j++) {
    1014     Log() << Verbose(1) << j << "th atom's vector: ";
     1015    DoLog(1) && (Log() << Verbose(1) << j << "th atom's vector: ");
    10151016    (vectors[j])->Output();
    1016     Log() << Verbose(0) << endl;
     1017    DoLog(0) && (Log() << Verbose(0) << endl);
    10171018  }
    10181019
     
    11341135    j += i+1;
    11351136    do {
    1136       Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ";
     1137      DoLog(0) && (Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ");
    11371138      cin >> x[i];
    11381139    } while (((x[i] < 0) || (x[i] >= cell_size[j])) && (check));
     
    11651166  B2 = cos(beta) * x2->Norm() * c;
    11661167  C = c * c;
    1167   Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl;
     1168  DoLog(2) && (Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl);
    11681169  int flag = 0;
    11691170  if (fabs(x1->x[0]) < MYEPSILON) { // check for zero components for the later flipping and back-flipping
     
    12041205  D2 = -y->x[0]/x1->x[0]*x1->x[2]+y->x[2];
    12051206  D3 = y->x[0]/x1->x[0]*A-B1;
    1206   Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n";
     1207  DoLog(2) && (Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n");
    12071208  if (fabs(D1) < MYEPSILON) {
    1208     Log() << Verbose(2) << "D1 == 0!\n";
     1209    DoLog(2) && (Log() << Verbose(2) << "D1 == 0!\n");
    12091210    if (fabs(D2) > MYEPSILON) {
    1210       Log() << Verbose(3) << "D2 != 0!\n";
     1211      DoLog(3) && (Log() << Verbose(3) << "D2 != 0!\n");
    12111212      x[2] = -D3/D2;
    12121213      E1 = A/x1->x[0] + x1->x[2]/x1->x[0]*D3/D2;
    12131214      E2 = -x1->x[1]/x1->x[0];
    1214       Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n";
     1215      DoLog(3) && (Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n");
    12151216      F1 = E1*E1 + 1.;
    12161217      F2 = -E1*E2;
    12171218      F3 = E1*E1 + D3*D3/(D2*D2) - C;
    1218       Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";
     1219      DoLog(3) && (Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n");
    12191220      if (fabs(F1) < MYEPSILON) {
    1220         Log() << Verbose(4) << "F1 == 0!\n";
    1221         Log() << Verbose(4) << "Gleichungssystem linear\n";
     1221        DoLog(4) && (Log() << Verbose(4) << "F1 == 0!\n");
     1222        DoLog(4) && (Log() << Verbose(4) << "Gleichungssystem linear\n");
    12221223        x[1] = F3/(2.*F2);
    12231224      } else {
    12241225        p = F2/F1;
    12251226        q = p*p - F3/F1;
    1226         Log() << Verbose(4) << "p " << p << "\tq " << q << endl;
     1227        DoLog(4) && (Log() << Verbose(4) << "p " << p << "\tq " << q << endl);
    12271228        if (q < 0) {
    1228           Log() << Verbose(4) << "q < 0" << endl;
     1229          DoLog(4) && (Log() << Verbose(4) << "q < 0" << endl);
    12291230          return false;
    12301231        }
     
    12331234      x[0] =  A/x1->x[0] - x1->x[1]/x1->x[0]*x[1] + x1->x[2]/x1->x[0]*x[2];
    12341235    } else {
    1235       Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n";
     1236      DoLog(2) && (Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n");
    12361237      return false;
    12371238    }
     
    12391240    E1 = A/x1->x[0]+x1->x[1]/x1->x[0]*D3/D1;
    12401241    E2 = x1->x[1]/x1->x[0]*D2/D1 - x1->x[2];
    1241     Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n";
     1242    DoLog(2) && (Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n");
    12421243    F1 = E2*E2 + D2*D2/(D1*D1) + 1.;
    12431244    F2 = -(E1*E2 + D2*D3/(D1*D1));
    12441245    F3 = E1*E1 + D3*D3/(D1*D1) - C;
    1245     Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";
     1246    DoLog(2) && (Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n");
    12461247    if (fabs(F1) < MYEPSILON) {
    1247       Log() << Verbose(3) << "F1 == 0!\n";
    1248       Log() << Verbose(3) << "Gleichungssystem linear\n";
     1248      DoLog(3) && (Log() << Verbose(3) << "F1 == 0!\n");
     1249      DoLog(3) && (Log() << Verbose(3) << "Gleichungssystem linear\n");
    12491250      x[2] = F3/(2.*F2);
    12501251    } else {
    12511252      p = F2/F1;
    12521253      q = p*p - F3/F1;
    1253       Log() << Verbose(3) << "p " << p << "\tq " << q << endl;
     1254      DoLog(3) && (Log() << Verbose(3) << "p " << p << "\tq " << q << endl);
    12541255      if (q < 0) {
    1255         Log() << Verbose(3) << "q < 0" << endl;
     1256        DoLog(3) && (Log() << Verbose(3) << "q < 0" << endl);
    12561257        return false;
    12571258      }
     
    12911292    for (j=2;j>=0;j--) {
    12921293      k = (i & pot(2,j)) << j;
    1293       Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl;
     1294      DoLog(2) && (Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl);
    12941295      sign[j] = (k == 0) ? 1. : -1.;
    12951296    }
    1296     Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n";
     1297    DoLog(2) && (Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n");
    12971298    // apply sign matrix
    12981299    for (j=NDIM;j--;)
     
    13001301    // calculate angle and check
    13011302    ang = x2->Angle (this);
    1302     Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t";
     1303    DoLog(1) && (Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t");
    13031304    if (fabs(ang - cos(beta)) < MYEPSILON) {
    13041305      break;
Note: See TracChangeset for help on using the changeset viewer.