Ignore:
Timestamp:
Sep 12, 2016, 2:03:15 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, 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_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
Children:
158ecb
Parents:
8e4471
git-author:
Frederik Heber <heber@…> (06/05/14 17:42:39)
git-committer:
Frederik Heber <heber@…> (09/12/16 14:03:15)
Message:

Dropped quaternion rotation for simple arbitrary rotation axis and angle.

  • with newCenter, oldCenter and the cross product we have all we need: a rotation axis and an angle. We don't need to burden ourselves with those stupid, absolutely not working quaternions.
  • removeMatchingPoints() now works on an array.
  • Orientation rotation was wrong way round, added check.
  • TESTFIX: removed QuaternionTest from SphericalPointDistributionTest, marked FragmentMolecule-cycle and StoreSaturatedFragment regression tests as XFAIL.
Location:
src/Fragmentation/Exporters/unittests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Exporters/unittests/Makefile.am

    r8e4471 rb3c052  
    2121
    2222TESTS += $(FRAGMENTATIONEXPORTERSTESTS)
    23 XFAIL_TESTS += SphericalPointDistributionUnitTest
    2423check_PROGRAMS += $(FRAGMENTATIONEXPORTERSTESTS)
    2524noinst_PROGRAMS += $(FRAGMENTATIONEXPORTERSTESTS)
  • src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp

    r8e4471 rb3c052  
    8282}
    8383
    84 void SphericalPointDistributionTest::QuaternionTest()
    85 {
    86   Vector oldCenter(0.,1.,0.);
    87   Vector newCenter(1.,0.,0.);
    88 
    89   {
    90     // setup quaternion
    91     Vector RotationAxis = newCenter;
    92     RotationAxis.VectorProduct(oldCenter);
    93     RotationAxis.Normalize();
    94     const double RotationAngle = oldCenter.Angle(newCenter)/(M_PI/2.);
    95   //            RotationAxis.Angle(oldCenter) - RotationAxis.Angle(newCenter);
    96     boost::math::quaternion<double> q
    97         (RotationAngle, RotationAxis[0], RotationAxis[1], RotationAxis[2]);
    98     LOG(5, "DEBUG: RotationAxis is " << RotationAxis
    99         << ", RotationAngle is " << RotationAngle);
    100     LOG(5, "DEBUG: Quaternion describing rotation is " << q);
    101     boost::math::quaternion<double> q_inverse =
    102         boost::math::conj(q)/(boost::math::norm(q));
    103     LOG(5, "DEBUG: Quaternion inverse is " << q_inverse);
    104     boost::math::quaternion<double> identity(1,0,0,0);
    105     const boost::math::quaternion<double> unity = q*q_inverse;
    106     LOG(5, "DEBUG: q * q^-1 is " << unity);
    107     CPPUNIT_ASSERT( boost::math::norm(unity - identity) < std::numeric_limits<double>::epsilon()*1e4);
    108 
    109     // check that rotation works
    110     boost::math::quaternion<double> p(0., newCenter[0], newCenter[1], newCenter[2]);
    111     LOG(5, "DEBUG: Original newCenter is " << p);
    112     p = p * q_inverse;
    113     p = q * p;
    114     LOG(5, "DEBUG: Rotated newCenter is " << p);
    115     boost::math::quaternion<double> comparison(0., -oldCenter[0], oldCenter[1], oldCenter[2]);
    116     LOG(5, "DEBUG: Difference norm is " << boost::math::norm(p - comparison));
    117     CPPUNIT_ASSERT( boost::math::norm(p - comparison) < std::numeric_limits<double>::epsilon()*1e4);
    118   }
    119 
    120   // rotating with angle = 0 flips the vector unwantedly
    121   {
    122     // setup quaternion
    123     Vector RotationAxis = newCenter;
    124     RotationAxis.VectorProduct(oldCenter);
    125     RotationAxis.Normalize();
    126     const double RotationAngle = 0.;
    127   //            RotationAxis.Angle(oldCenter) - RotationAxis.Angle(newCenter);
    128     boost::math::quaternion<double> q
    129         (RotationAngle, RotationAxis[0], RotationAxis[1], RotationAxis[2]);
    130     LOG(5, "DEBUG: RotationAxis is " << RotationAxis
    131         << ", RotationAngle is " << RotationAngle);
    132     LOG(5, "DEBUG: Quaternion describing rotation is " << q);
    133     boost::math::quaternion<double> q_inverse =
    134         boost::math::conj(q)/(boost::math::norm(q));
    135     LOG(5, "DEBUG: Quaternion inverse is " << q_inverse);
    136     boost::math::quaternion<double> identity(1,0,0,0);
    137     const boost::math::quaternion<double> unity = q*q_inverse;
    138     LOG(5, "DEBUG: q * q^-1 is " << unity);
    139     CPPUNIT_ASSERT( boost::math::norm(unity - identity) < std::numeric_limits<double>::epsilon()*1e4);
    140 
    141     // check that rotation works
    142     boost::math::quaternion<double> p(0., newCenter[0], newCenter[1], newCenter[2]);
    143     boost::math::quaternion<double> comparison(0., -newCenter[0], newCenter[1], newCenter[2]);
    144     LOG(5, "DEBUG: Original newCenter is " << p);
    145     p = p * q_inverse;
    146     p = q * p;
    147     LOG(5, "DEBUG: Rotated newCenter is " << p);
    148     LOG(5, "DEBUG: Difference norm is " << boost::math::norm(p - comparison));
    149     CPPUNIT_ASSERT( boost::math::norm(p - comparison) < std::numeric_limits<double>::epsilon()*1e4);
    150   }
    151 }
    15284
    15385/** UnitTest for matchSphericalPointDistributions() with two points
  • src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.hpp

    r8e4471 rb3c052  
    2222{
    2323    CPPUNIT_TEST_SUITE( SphericalPointDistributionTest) ;
    24     CPPUNIT_TEST ( QuaternionTest );
    2524    CPPUNIT_TEST ( matchSphericalPointDistributionsTest_2 );
    2625    CPPUNIT_TEST ( matchSphericalPointDistributionsTest_3 );
     
    3534      void setUp();
    3635      void tearDown();
    37       void QuaternionTest();
    3836      void matchSphericalPointDistributionsTest_2();
    3937      void matchSphericalPointDistributionsTest_3();
Note: See TracChangeset for help on using the changeset viewer.