Ignore:
Timestamp:
Jan 11, 2010, 3:06:30 AM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
91b1e79
Parents:
23f6ec
Message:

InsideOutside unit test of tesselation is working correctly.

  • FIX: BoundaryTriangleSet::GetIntersectionInsideTriangle() - don't need helper, just check whether CrossPoint is returned (and true) for all of the three sides.
  • FIX: Tesselation::IsInnerPoint() - projection onto plane and stuff was nonsense, just take the Point ans Intersection which is on the plane anyway.
  • FIX: Vector::GetIntersectionOfTwoLinesOnPlane() - coefficient MUST be zero (then vectors are coplanar), but parallelity check was missing. Also, we have to check whether s is in [0,1] in order to see whether we are inside the triangle side or outside.

Signed-off-by: Frederik Heber <heber@tabletINS.(none)>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/tesselation.cpp

    r23f6ec rd403a1  
    420420    if (CrossPoint.GetIntersectionOfTwoLinesOnPlane(endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node, endpoints[(i+2)%3]->node->node, Intersection, &NormalVector)) {
    421421      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
    424424      break;
    425     } else
    426       i++;
    427425  } while (i<3);
    428426  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;
    435428    return true;
    436   } else { // outside!
    437     Intersection->Zero();
     429  } else {
     430    Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " outside of triangle." << endl;
    438431    return false;
    439432  }
     
    32413234bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC, const double epsilon) const
    32423235{
    3243         Info FunctionInfo(__func__);
     3236  Info FunctionInfo(__func__);
    32443237  class BoundaryTriangleSet *result = FindClosestTriangleToVector(&Point, LC);
    32453238  Vector Center;
     
    32523245    return false;
    32533246  } 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;
    32553248  }
    32563249
     
    32593252  DistanceToCenter.CopyVector(&Center);
    32603253  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;
    32623255
    32633256  // check whether we are on boundary
    32643257  if (fabs(DistanceToCenter.ScalarProduct(&result->NormalVector)) < MYEPSILON) {
    32653258    // 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);
    32693261    Center.SubtractVector(&result->NormalVector); // points towards MolCenter
    32703262    DistanceToCenter.AddVector(&result->NormalVector); // points outside
Note: See TracChangeset for help on using the changeset viewer.