Changeset d403a1 for molecuilder/src
- Timestamp:
- Jan 11, 2010, 3:06:30 AM (16 years ago)
- Children:
- 91b1e79
- Parents:
- 23f6ec
- Location:
- molecuilder/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/tesselation.cpp
r23f6ec rd403a1 420 420 if (CrossPoint.GetIntersectionOfTwoLinesOnPlane(endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node, endpoints[(i+2)%3]->node->node, Intersection, &NormalVector)) { 421 421 CrossPoint.SubtractVector(endpoints[i%3]->node->node); // cross point was returned as absolute vector 422 helper.CopyVector(endpoints[(i+1)%3]->node->node);423 helper.SubtractVector(endpoints[i%3]->node->node);422 i++; 423 } else 424 424 break; 425 } else426 i++;427 425 } while (i<3); 428 426 if (i==3) { 429 eLog() << Verbose(0) << "Could not find any cross points, something's utterly wrong here!" << endl; 430 } 431 Log() << Verbose(1) << "INFO: Crosspoint is " << CrossPoint << "." << endl; 432 433 // check whether intersection is inside or not by comparing length of intersection and length of cross point 434 if ((CrossPoint.NormSquared() - helper.NormSquared()) < MYEPSILON) { // inside 427 Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " inside of triangle." << endl; 435 428 return true; 436 } else { // outside!437 Intersection->Zero();429 } else { 430 Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " outside of triangle." << endl; 438 431 return false; 439 432 } … … 3241 3234 bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC, const double epsilon) const 3242 3235 { 3243 3236 Info FunctionInfo(__func__); 3244 3237 class BoundaryTriangleSet *result = FindClosestTriangleToVector(&Point, LC); 3245 3238 Vector Center; … … 3252 3245 return false; 3253 3246 } else { 3254 Log() << Verbose(1) << "INFO: Closest triangle found is " << *result << " ." << endl;3247 Log() << Verbose(1) << "INFO: Closest triangle found is " << *result << " with normal vector " << result->NormalVector << "." << endl; 3255 3248 } 3256 3249 … … 3259 3252 DistanceToCenter.CopyVector(&Center); 3260 3253 DistanceToCenter.SubtractVector(&Point); 3261 Log() << Verbose(2) << "INFO: Vector from point to test to center is " << Center << "." << endl;3254 Log() << Verbose(2) << "INFO: Vector from point to test to center is " << DistanceToCenter << "." << endl; 3262 3255 3263 3256 // check whether we are on boundary 3264 3257 if (fabs(DistanceToCenter.ScalarProduct(&result->NormalVector)) < MYEPSILON) { 3265 3258 // calculate whether inside of triangle 3266 DistanceToCenter.ProjectOntoPlane(&result->NormalVector); 3267 DistanceToCenter.AddVector(&Center); 3268 Center.CopyVector(&DistanceToCenter); 3259 DistanceToCenter.CopyVector(&Point); 3260 Center.CopyVector(&Point); 3269 3261 Center.SubtractVector(&result->NormalVector); // points towards MolCenter 3270 3262 DistanceToCenter.AddVector(&result->NormalVector); // points outside -
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.