Changeset fcad4b for src/vector.cpp


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)>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.