Changeset fee69b


Ignore:
Timestamp:
Jan 11, 2010, 9:16:36 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:
241485
Parents:
fcad4b
git-author:
Frederik Heber <heber@…> (01/11/10 09:13:49)
git-committer:
Frederik Heber <heber@…> (01/11/10 09:16:36)
Message:

Fixed Tesselation::IsInnerPoint()

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

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/tesselation.cpp

    rfcad4b rfee69b  
    402402bool BoundaryTriangleSet::GetIntersectionInsideTriangle(Vector *MolCenter, Vector *x, Vector *Intersection)
    403403{
    404         Info FunctionInfo(__func__);
     404  Info FunctionInfo(__func__);
    405405  Vector CrossPoint;
    406406  Vector helper;
     
    415415  Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl;
    416416
     417  if (Intersection->DistanceSquared(endpoints[0]->node->node) < MYEPSILON) {
     418    Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl;
     419    return true;
     420  }   else if (Intersection->DistanceSquared(endpoints[1]->node->node) < MYEPSILON) {
     421    Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl;
     422    return true;
     423  }   else if (Intersection->DistanceSquared(endpoints[2]->node->node) < MYEPSILON) {
     424    Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl;
     425    return true;
     426  }
    417427  // Calculate cross point between one baseline and the line from the third endpoint to intersection
    418428  int i=0;
    419429  do {
    420430    if (CrossPoint.GetIntersectionOfTwoLinesOnPlane(endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node, endpoints[(i+2)%3]->node->node, Intersection, &NormalVector)) {
     431      helper.CopyVector(endpoints[(i+1)%3]->node->node);
     432      helper.SubtractVector(endpoints[i%3]->node->node);
    421433      CrossPoint.SubtractVector(endpoints[i%3]->node->node);  // cross point was returned as absolute vector
     434      const double s = CrossPoint.ScalarProduct(&helper)/helper.NormSquared();
     435      Log() << Verbose(1) << "INFO: Factor s is " << s << "." << endl;
     436      if ((s < -MYEPSILON) || ((s-1.) > MYEPSILON)) {
     437        Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl;
     438        i=4;
     439        break;
     440      }
    422441      i++;
    423442    } else
  • src/vector.cpp

    rfcad4b rfee69b  
    306306{
    307307  Info FunctionInfo(__func__);
    308   Vector a;
    309   Vector b;
    310   Vector c;
    311308
    312309  GSLMatrix *M = new GSLMatrix(4,4);
     
    319316    M->Set(3, i, Line2b->x[i]);
    320317  }
    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   }
     318 
     319  //Log() << Verbose(1) << "Coefficent matrix is:" << endl;
     320  //for (int i=0;i<4;i++) {
     321  //  for (int j=0;j<4;j++)
     322  //    cout << "\t" << M->Get(i,j);
     323  //  cout << endl;
     324  //}
    327325  if (fabs(M->Determinant()) > MYEPSILON) {
    328326    Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl;
     
    333331
    334332  // constuct a,b,c
     333  Vector a;
     334  Vector b;
     335  Vector c;
     336  Vector d;
    335337  a.CopyVector(Line1b);
    336338  a.SubtractVector(Line1a);
     
    339341  c.CopyVector(Line2a);
    340342  c.SubtractVector(Line1a);
     343  d.CopyVector(Line2b);
     344  d.SubtractVector(Line1b);
    341345  Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl;
     346  if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) {
     347   Zero();
     348   Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl;
     349   return false;
     350  }
    342351
    343352  // check for parallelity
    344353  Vector parallel;
    345   parallel.CopyVector(&a);
    346   parallel.SubtractVector(&b);
    347   if (parallel.NormSquared() < MYEPSILON) {
     354  double factor = 0.;
     355  double pfactor = 0.;
     356  if (fabs(a.ScalarProduct(&b)*a.ScalarProduct(&b)/a.NormSquared()/b.NormSquared() - 1.) < MYEPSILON) {
     357    parallel.CopyVector(Line1a);
     358    parallel.SubtractVector(Line2a);
     359    factor = parallel.ScalarProduct(&a)/a.Norm();
     360    if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
     361      CopyVector(Line2a);
     362      Log() << Verbose(1) << "Lines conincide." << endl;
     363      return true;
     364    } else {
     365      parallel.CopyVector(Line1a);
     366      parallel.SubtractVector(Line2b);
     367      factor = parallel.ScalarProduct(&a)/a.Norm();
     368      if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
     369        CopyVector(Line2b);
     370        Log() << Verbose(1) << "Lines conincide." << endl;
     371        return true;
     372      }
     373    }
    348374    Log() << Verbose(1) << "Lines are parallel." << endl;
     375    Zero();
    349376    return false;
    350377  }
     
    370397  Log() << Verbose(1) << "Intersection is at " << *this << "." << endl;
    371398
    372   if ((s >=0 ) && (s<=1))
    373     return true;
    374   else
    375     return false;
     399  return true;
    376400};
    377401
Note: See TracChangeset for help on using the changeset viewer.