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/vector.cpp

    r23f6ec rd403a1  
    319319    M->Set(3, i, Line2b->x[i]);
    320320  }
    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;
    322329    return false;
     330  }
     331  Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl;
     332
    323333
    324334  // constuct a,b,c
     
    329339  c.CopyVector(Line2a);
    330340  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  }
    331351
    332352  // obtain s
     
    337357  temp2.CopyVector(&a);
    338358  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;
    341365
    342366  // construct intersection
     
    346370  Log() << Verbose(1) << "Intersection is at " << *this << "." << endl;
    347371
    348   return true;
     372  if ((s >=0 ) && (s<=1))
     373    return true;
     374  else
     375    return false;
    349376};
    350377
Note: See TracChangeset for help on using the changeset viewer.