Changeset d403a1 for molecuilder/src/vector.cpp
- Timestamp:
- Jan 11, 2010, 3:06:30 AM (16 years ago)
- Children:
- 91b1e79
- Parents:
- 23f6ec
- File:
-
- 1 edited
-
molecuilder/src/vector.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/vector.cpp
r23f6ec rd403a1 319 319 M->Set(3, i, Line2b->x[i]); 320 320 } 321 if (fabs(M->Determinant()) < MYEPSILON) 321 Log() << Verbose(1) << "Coefficent matrix is:" << endl; 322 for (int i=0;i<4;i++) { 323 for (int j=0;j<4;j++) 324 cout << "\t" << M->Get(i,j); 325 cout << endl; 326 } 327 if (fabs(M->Determinant()) > MYEPSILON) { 328 Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl; 322 329 return false; 330 } 331 Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl; 332 323 333 324 334 // constuct a,b,c … … 329 339 c.CopyVector(Line2a); 330 340 c.SubtractVector(Line1a); 341 Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl; 342 343 // check for parallelity 344 Vector parallel; 345 parallel.CopyVector(&a); 346 parallel.SubtractVector(&b); 347 if (parallel.NormSquared() < MYEPSILON) { 348 Log() << Verbose(1) << "Lines are parallel." << endl; 349 return false; 350 } 331 351 332 352 // obtain s … … 337 357 temp2.CopyVector(&a); 338 358 temp2.VectorProduct(&b); 339 s = temp1.ScalarProduct(&temp2)/temp2.NormSquared(); 340 Log() << Verbose(1) << "Factor s is " << s << "." << endl; 359 Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl; 360 if (fabs(temp2.NormSquared()) > MYEPSILON) 361 s = temp1.ScalarProduct(&temp2)/temp2.NormSquared(); 362 else 363 s = 0.; 364 Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl; 341 365 342 366 // construct intersection … … 346 370 Log() << Verbose(1) << "Intersection is at " << *this << "." << endl; 347 371 348 return true; 372 if ((s >=0 ) && (s<=1)) 373 return true; 374 else 375 return false; 349 376 }; 350 377
Note:
See TracChangeset
for help on using the changeset viewer.
