Changeset 91b1e79 for molecuilder/src/vector.cpp
- Timestamp:
- Jan 11, 2010, 9:16:36 AM (16 years ago)
- Children:
- afa056
- Parents:
- d403a1
- git-author:
- Frederik Heber <heber@…> (01/11/10 09:13:49)
- git-committer:
- Frederik Heber <heber@…> (01/11/10 09:16:36)
- File:
-
- 1 edited
-
molecuilder/src/vector.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/vector.cpp
rd403a1 r91b1e79 306 306 { 307 307 Info FunctionInfo(__func__); 308 Vector a;309 Vector b;310 Vector c;311 308 312 309 GSLMatrix *M = new GSLMatrix(4,4); … … 319 316 M->Set(3, i, Line2b->x[i]); 320 317 } 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 } 318 319 //Log() << Verbose(1) << "Coefficent matrix is:" << endl; 320 //for (int i=0;i<4;i++) { 321 // for (int j=0;j<4;j++) 322 // cout << "\t" << M->Get(i,j); 323 // cout << endl; 324 //} 327 325 if (fabs(M->Determinant()) > MYEPSILON) { 328 326 Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl; … … 333 331 334 332 // constuct a,b,c 333 Vector a; 334 Vector b; 335 Vector c; 336 Vector d; 335 337 a.CopyVector(Line1b); 336 338 a.SubtractVector(Line1a); … … 339 341 c.CopyVector(Line2a); 340 342 c.SubtractVector(Line1a); 343 d.CopyVector(Line2b); 344 d.SubtractVector(Line1b); 341 345 Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl; 346 if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) { 347 Zero(); 348 Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl; 349 return false; 350 } 342 351 343 352 // check for parallelity 344 353 Vector parallel; 345 parallel.CopyVector(&a); 346 parallel.SubtractVector(&b); 347 if (parallel.NormSquared() < MYEPSILON) { 354 double factor = 0.; 355 double pfactor = 0.; 356 if (fabs(a.ScalarProduct(&b)*a.ScalarProduct(&b)/a.NormSquared()/b.NormSquared() - 1.) < MYEPSILON) { 357 parallel.CopyVector(Line1a); 358 parallel.SubtractVector(Line2a); 359 factor = parallel.ScalarProduct(&a)/a.Norm(); 360 if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) { 361 CopyVector(Line2a); 362 Log() << Verbose(1) << "Lines conincide." << endl; 363 return true; 364 } else { 365 parallel.CopyVector(Line1a); 366 parallel.SubtractVector(Line2b); 367 factor = parallel.ScalarProduct(&a)/a.Norm(); 368 if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) { 369 CopyVector(Line2b); 370 Log() << Verbose(1) << "Lines conincide." << endl; 371 return true; 372 } 373 } 348 374 Log() << Verbose(1) << "Lines are parallel." << endl; 375 Zero(); 349 376 return false; 350 377 } … … 370 397 Log() << Verbose(1) << "Intersection is at " << *this << "." << endl; 371 398 372 if ((s >=0 ) && (s<=1)) 373 return true; 374 else 375 return false; 399 return true; 376 400 }; 377 401
Note:
See TracChangeset
for help on using the changeset viewer.
