Changeset fcad4b


Ignore:
Timestamp:
Jan 11, 2010, 3:06:30 AM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
fee69b
Parents:
68a53b
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)>

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/tesselation.cpp

    r68a53b rfcad4b  
    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
  • src/vector.cpp

    r68a53b rfcad4b  
    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.