Changeset 8cbb97 for src/unittests


Ignore:
Timestamp:
Apr 29, 2010, 1:55:21 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
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, Candidate_v1.7.0, Candidate_v1.7.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:
d79639
Parents:
632bc3 (diff), 753f02 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'VectorRefactoring' into StructureRefactoring

Conflicts:

molecuilder/src/Legacy/oldmenu.cpp
molecuilder/src/Makefile.am
molecuilder/src/analysis_correlation.cpp
molecuilder/src/boundary.cpp
molecuilder/src/builder.cpp
molecuilder/src/config.cpp
molecuilder/src/ellipsoid.cpp
molecuilder/src/linkedcell.cpp
molecuilder/src/molecule.cpp
molecuilder/src/molecule_fragmentation.cpp
molecuilder/src/molecule_geometry.cpp
molecuilder/src/molecule_graph.cpp
molecuilder/src/moleculelist.cpp
molecuilder/src/tesselation.cpp
molecuilder/src/tesselationhelpers.cpp
molecuilder/src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
molecuilder/src/unittests/bondgraphunittest.cpp
molecuilder/src/vector.cpp
molecuilder/src/vector.hpp

Location:
src/unittests
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/ActOnAllUnitTest.cpp

    r632bc3 r8cbb97  
    5656
    5757  // adding, subtracting
    58   VL.ActOnAll( &Vector::AddVector, &test );
     58  VL.ActOnAll( &Vector::AddVector, test );
    5959  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    60   VL.ActOnAll( &Vector::SubtractVector, &test );
     60  VL.ActOnAll( &Vector::SubtractVector, test );
    6161  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    6262};
     
    7070
    7171  // scaling by value
    72   VL.ActOnAll( (void (Vector::*)(const double)) &Vector::Scale, 2. );
     72  VL.ActOnAll( (void (Vector::*)(const double)) &Vector::Scale, factor );
    7373  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    7474
    75   VL.ActOnAll( (void (Vector::*)(const double)) &Vector::Scale, 0.5 );
    76   CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    77 
    78   // scaling by ref
    79   VL.ActOnAll( (void (Vector::*)(const double * const)) &Vector::Scale, (const double * const)&factor );
    80   CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    81 
    82   VL.ActOnAll( (void (Vector::*)(const double * const)) &Vector::Scale, (const double * const)&inverse );
     75  VL.ActOnAll( (void (Vector::*)(const double)) &Vector::Scale, inverse );
    8376  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    8477
     
    9083    inverses[i] = 1./factors[i];
    9184  }
    92   VL.ActOnAll( (void (Vector::*)(const double ** const)) &Vector::Scale, (const double ** const)&factors );
     85  VL.ActOnAll<Vector,void,const double*>(&Vector::ScaleAll, factors );
    9386  CPPUNIT_ASSERT_EQUAL( VL == Ref , false );
    9487
    95   VL.ActOnAll( (void (Vector::*)(const double ** const)) &Vector::Scale, (const double ** const)&inverses );
     88  VL.ActOnAll<Vector,void,const double*>(&Vector::ScaleAll, inverses );
    9689  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    9790  Free(factors);
    9891  Free(inverses);
    9992};
     93
     94#if 0
     95
     96// Unitttest deactivated for now...
     97// Reasons:
     98//    Vector::MakeNormalVector has been removed and is now part of Plane class
     99//    VectorList::ActOnAll is in the test directory and seems to be used only for unittests
     100//    MakeNormal never depended on the input Vector except in the case of linear dependence (i.e. failure)
     101//
     102// TODO: Rethink what exactely is being tested at this point and introduce a new unittest for the
     103//       tested behaviour. Most likely this should result in a thourough unittest of the plane class
    100104
    101105/** UnitTest for VectorList::ActOnAll() and Vector::MakeNormalVector()
     
    113117  // check that x and y components are zero
    114118  for (ListOfVectors::iterator Runner = VL.Vectors.begin(); Runner != VL.Vectors.end(); Runner++) {
    115     CPPUNIT_ASSERT_EQUAL( (*Runner)->x[0] , 0. );
    116     CPPUNIT_ASSERT_EQUAL( (*Runner)->x[1] , 0. );
     119    CPPUNIT_ASSERT_EQUAL( (*Runner)->at(0) , 0. );
     120    CPPUNIT_ASSERT_EQUAL( (*Runner)->at(1) , 0. );
    117121  }
    118122};
     123
     124#endif
  • src/unittests/ActOnAllUnitTest.hpp

    r632bc3 r8cbb97  
    2020    CPPUNIT_TEST ( AddSubtractTest );
    2121    CPPUNIT_TEST ( ScaleTest );
     22#if 0
     23    // test deactivated. See .cpp for reasons and workarounds
    2224    CPPUNIT_TEST ( NormalizeTest );
     25#endif
    2326    CPPUNIT_TEST_SUITE_END();
    2427
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r632bc3 r8cbb97  
    6464  Walker = World::getInstance().createAtom();
    6565  Walker->type = hydrogen;
    66   Walker->node->Init(1., 0., 1. );
     66  *Walker->node = Vector(1., 0., 1. );
    6767  TestMolecule->AddAtom(Walker);
    6868  Walker = World::getInstance().createAtom();
    6969  Walker->type = hydrogen;
    70   Walker->node->Init(0., 1., 1. );
     70  *Walker->node = Vector(0., 1., 1. );
    7171  TestMolecule->AddAtom(Walker);
    7272  Walker = World::getInstance().createAtom();
    7373  Walker->type = hydrogen;
    74   Walker->node->Init(1., 1., 0. );
     74  *Walker->node = Vector(1., 1., 0. );
    7575  TestMolecule->AddAtom(Walker);
    7676  Walker = World::getInstance().createAtom();
    7777  Walker->type = hydrogen;
    78   Walker->node->Init(0., 0., 0. );
     78  *Walker->node = Vector(0., 0., 0. );
    7979  TestMolecule->AddAtom(Walker);
    8080
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r632bc3 r8cbb97  
    4040void AnalysisCorrelationToSurfaceUnitTest::setUp()
    4141{
    42   ASSERT_DO(Assert::Throw);
     42  //ASSERT_DO(Assert::Throw);
    4343
    4444  atom *Walker = NULL;
     
    4646  // init private all pointers to zero
    4747  TestList = NULL;
    48   TestMolecule = NULL;
     48  TestSurfaceMolecule = NULL;
    4949  hydrogen = NULL;
    5050  tafel = NULL;
     
    7373  Walker = World::getInstance().createAtom();
    7474  Walker->type = hydrogen;
    75   Walker->node->Init(1., 0., 1. );
    76   TestSurfaceMolecule->AddAtom(Walker);
    77   Walker = World::getInstance().createAtom();
    78   Walker->type = hydrogen;
    79   Walker->node->Init(0., 1., 1. );
    80   TestSurfaceMolecule->AddAtom(Walker);
    81   Walker = World::getInstance().createAtom();
    82   Walker->type = hydrogen;
    83   Walker->node->Init(1., 1., 0. );
    84   TestSurfaceMolecule->AddAtom(Walker);
    85   Walker = World::getInstance().createAtom();
    86   Walker->type = hydrogen;
    87   Walker->node->Init(0., 0., 0. );
     75  *Walker->node = Vector(1., 0., 1. );
     76
     77  TestSurfaceMolecule->AddAtom(Walker);
     78  Walker = World::getInstance().createAtom();
     79  Walker->type = hydrogen;
     80  *Walker->node = Vector(0., 1., 1. );
     81  TestSurfaceMolecule->AddAtom(Walker);
     82  Walker = World::getInstance().createAtom();
     83  Walker->type = hydrogen;
     84  *Walker->node = Vector(1., 1., 0. );
     85  TestSurfaceMolecule->AddAtom(Walker);
     86  Walker = World::getInstance().createAtom();
     87  Walker->type = hydrogen;
     88  *Walker->node = Vector(0., 0., 0. );
    8889  TestSurfaceMolecule->AddAtom(Walker);
    8990
     
    101102
    102103  // add outer atoms
    103   TestMolecule = World::getInstance().createMolecule();
    104   Walker = World::getInstance().createAtom();
    105   Walker->type = carbon;
    106   Walker->node->Init(4., 0., 4. );
    107   TestMolecule->AddAtom(Walker);
    108   Walker = World::getInstance().createAtom();
    109   Walker->type = carbon;
    110   Walker->node->Init(0., 4., 4. );
    111   TestMolecule->AddAtom(Walker);
    112   Walker = World::getInstance().createAtom();
    113   Walker->type = carbon;
    114   Walker->node->Init(4., 4., 0. );
    115   TestMolecule->AddAtom(Walker);
     104  TestSurfaceMolecule = World::getInstance().createMolecule();
     105  Walker = World::getInstance().createAtom();
     106  Walker->type = carbon;
     107  *Walker->node = Vector(4., 0., 4. );
     108  TestSurfaceMolecule->AddAtom(Walker);
     109  Walker = World::getInstance().createAtom();
     110  Walker->type = carbon;
     111  *Walker->node = Vector(0., 4., 4. );
     112  TestSurfaceMolecule->AddAtom(Walker);
     113  Walker = World::getInstance().createAtom();
     114  Walker->type = carbon;
     115  *Walker->node = Vector(4., 4., 0. );
     116  TestSurfaceMolecule->AddAtom(Walker);
    116117  // add inner atoms
    117118  Walker = World::getInstance().createAtom();
    118119  Walker->type = carbon;
    119   Walker->node->Init(0.5, 0.5, 0.5 );
    120   TestMolecule->AddAtom(Walker);
    121   TestMolecule->ActiveFlag = true;
    122   TestList->insert(TestMolecule);
     120  *Walker->node = Vector(0.5, 0.5, 0.5 );
     121  TestSurfaceMolecule->AddAtom(Walker);
     122  TestSurfaceMolecule->ActiveFlag = true;
     123  TestList->insert(TestSurfaceMolecule);
    123124
    124125  // init maps
     
    150151{
    151152  CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount );
    152   CPPUNIT_ASSERT_EQUAL( 4, TestMolecule->AtomCount );
    153153  CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
    154154  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    r632bc3 r8cbb97  
    4444
    4545      MoleculeListClass *TestList;
    46       molecule *TestMolecule;
    4746      molecule *TestSurfaceMolecule;
    4847      element *hydrogen;
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r632bc3 r8cbb97  
    6363  Walker = World::getInstance().createAtom();
    6464  Walker->type = hydrogen;
    65   Walker->node->Init(1., 0., 1. );
     65  *Walker->node = Vector(1., 0., 1. );
    6666  TestMolecule->AddAtom(Walker);
    6767  Walker = World::getInstance().createAtom();
    6868  Walker->type = hydrogen;
    69   Walker->node->Init(0., 1., 1. );
     69  *Walker->node = Vector(0., 1., 1. );
    7070  TestMolecule->AddAtom(Walker);
    7171  Walker = World::getInstance().createAtom();
    7272  Walker->type = hydrogen;
    73   Walker->node->Init(1., 1., 0. );
     73  *Walker->node = Vector(1., 1., 0. );
    7474  TestMolecule->AddAtom(Walker);
    7575  Walker = World::getInstance().createAtom();
    7676  Walker->type = hydrogen;
    77   Walker->node->Init(0., 0., 0. );
     77  *Walker->node = Vector(0., 0., 0. );
    7878  TestMolecule->AddAtom(Walker);
    7979
  • src/unittests/CountBondsUnitTest.cpp

    r632bc3 r8cbb97  
    7272  Walker = World::getInstance().createAtom();
    7373  Walker->type = hydrogen;
    74   Walker->node->Init(-0.2418, 0.9350, 0. );
     74  *Walker->node = Vector(-0.2418, 0.9350, 0. );
    7575  TestMolecule1->AddAtom(Walker);
    7676  Walker = World::getInstance().createAtom();
    7777  Walker->type = hydrogen;
    78   Walker->node->Init(0.9658, 0., 0. );
     78  *Walker->node = Vector(0.9658, 0., 0. );
    7979  TestMolecule1->AddAtom(Walker);
    8080  Walker = World::getInstance().createAtom();
    8181  Walker->type = oxygen;
    82   Walker->node->Init(0., 0., 0. );
     82  *Walker->node = Vector(0., 0., 0. );
    8383  TestMolecule1->AddAtom(Walker);
    8484
     
    8686  Walker = World::getInstance().createAtom();
    8787  Walker->type = hydrogen;
    88   Walker->node->Init(-0.2418, 0.9350, 0. );
     88  *Walker->node = Vector(-0.2418, 0.9350, 0. );
    8989  TestMolecule2->AddAtom(Walker);
    9090  Walker = World::getInstance().createAtom();
    9191  Walker->type = hydrogen;
    92   Walker->node->Init(0.9658, 0., 0. );
     92  *Walker->node = Vector(0.9658, 0., 0. );
    9393  TestMolecule2->AddAtom(Walker);
    9494  Walker = World::getInstance().createAtom();
    9595  Walker->type = oxygen;
    96   Walker->node->Init(0., 0., 0. );
     96  *Walker->node = Vector(0., 0., 0. );
    9797  TestMolecule2->AddAtom(Walker);
    9898
     
    165165
    166166  cout << "Case 1: offset of (3,0,0), hence angles are (104.5, 0, 75.5, 180) < 30." << endl;
    167   Translator.Init(3,0,0);
     167  Translator  = Vector(3,0,0);
    168168  TestMolecule2->Translate(&Translator);
    169169  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL) );
    170170  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, oxygen) );
    171171  //OutputTestMolecule(TestMolecule2, "testmolecule2-1.xyz");
    172   Translator.Init(-3,0,0);
     172  Translator = Vector(-3,0,0);
    173173  TestMolecule2->Translate(&Translator);
    174174
    175175  cout << "Case 2: offset of (0,3,0), hence angle are (14.5, 165.5, 90) < 30 (only three, because other 90 is missing due to first H01 only fulfilling H-bond criteria)." << endl;
    176   Translator.Init(0,3,0);
     176  Translator = Vector(0,3,0);
    177177  TestMolecule2->Translate(&Translator);
    178178  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL) );
    179179  //OutputTestMolecule(TestMolecule2, "testmolecule2-2.xyz");
    180   Translator.Init(0,-3,0);
     180  Translator = Vector(0,-3,0);
    181181  TestMolecule2->Translate(&Translator);
    182182
    183183  cout << "Case 3: offset of (0,-3,0) and mirror, hence angle are (165.5, 90, 165.5, 90) > 30." << endl;
    184   Translator.Init(0,-3,0);
     184  Translator = Vector(0,-3,0);
    185185  TestMolecule2->Scale((const double ** const)&mirror);
    186186  TestMolecule2->Translate(&Translator);
    187187  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL) );
    188188  //OutputTestMolecule(TestMolecule2, "testmolecule2-3.xyz");
    189   Translator.Init(0,3,0);
     189  Translator = Vector(0,3,0);
    190190  TestMolecule2->Translate(&Translator);
    191191  TestMolecule2->Scale((const double ** const)&mirror);
    192192
    193193  cout << "Case 4: offset of (2,1,0), hence angle are (78, 26.6, 102, 153.4) < 30." << endl;
    194   Translator.Init(2,1,0);
     194  Translator = Vector(2,1,0);
    195195  TestMolecule2->Translate(&Translator);
    196196  CPPUNIT_ASSERT_EQUAL( 1 , CountHydrogenBridgeBonds(molecules, NULL) );
    197197  //OutputTestMolecule(TestMolecule2, "testmolecule2-4.xyz");
    198   Translator.Init(-2,-1,0);
     198  Translator = Vector(-2,-1,0);
    199199  TestMolecule2->Translate(&Translator);
    200200
    201201  cout << "Case 5: offset of (0,0,3), hence angle are (90, 90, 90, 90) > 30." << endl;
    202   Translator.Init(0,0,3);
     202  Translator = Vector(0,0,3);
    203203  TestMolecule2->Translate(&Translator);
    204204  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL) );
    205205  //OutputTestMolecule(TestMolecule2, "testmolecule2-5.xyz");
    206   Translator.Init(0,0,-3);
     206  Translator = Vector(0,0,-3);
    207207  TestMolecule2->Translate(&Translator);
    208208
    209209  cout << "Case 6: offset of (-3,0,0) and mirror, hence angle are (75.5, 180, 104.5, 180) > 30." << endl;
    210   Translator.Init(-3,0,0);
     210  Translator = Vector(-3,0,0);
    211211  TestMolecule2->Scale((const double ** const)&mirror);
    212212  TestMolecule2->Translate(&Translator);
    213213  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL) );
    214214  //OutputTestMolecule(TestMolecule2, "testmolecule2-6.xyz");
    215   Translator.Init(3,0,0);
     215  Translator = Vector(3,0,0);
    216216  TestMolecule2->Translate(&Translator);
    217217  TestMolecule2->Scale((const double ** const)&mirror);
    218218
    219219  cout << "Case 7: offset of (3,0,0) and mirror, hence angles are (104.5, 0, 104.5, 0) < 30, but interfering hydrogens." << endl;
    220   Translator.Init(3,0,0);
     220  Translator = Vector(3,0,0);
    221221  TestMolecule2->Scale((const double ** const)&mirror);
    222222  TestMolecule2->Translate(&Translator);
    223223  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL) );
    224224  //OutputTestMolecule(TestMolecule2, "testmolecule2-7.xyz");
    225   Translator.Init(-3,0,0);
     225  Translator = Vector(-3,0,0);
    226226  TestMolecule2->Translate(&Translator);
    227227  TestMolecule2->Scale((const double ** const)&mirror);
    228228
    229229  cout << "Case 8: offset of (0,3,0), hence angle are (14.5, 90, 14.5, 90) < 30, but interfering hydrogens." << endl;
    230   Translator.Init(0,3,0);
     230  Translator = Vector(0,3,0);
    231231  TestMolecule2->Scale((const double ** const)&mirror);
    232232  TestMolecule2->Translate(&Translator);
    233233  //OutputTestMolecule(TestMolecule2, "testmolecule2-8.xyz");
    234234  CPPUNIT_ASSERT_EQUAL( 0 , CountHydrogenBridgeBonds(molecules, NULL) );
    235   Translator.Init(0,-3,0);
     235  Translator = Vector(0,-3,0);
    236236  TestMolecule2->Translate(&Translator);
    237237  TestMolecule2->Scale((const double ** const)&mirror);
  • src/unittests/LinkedCellUnitTest.cpp

    r632bc3 r8cbb97  
    6161        Walker = World::getInstance().createAtom();
    6262        Walker->type = hydrogen;
    63         Walker->node->Init(x, y, z );
     63        *Walker->node = Vector(x, y, z );
    6464        TestMolecule->AddAtom(Walker);
    6565      }
     
    207207  Walker->Name = Malloc<char>(6, "LinkedCellTest::SetIndexToNodeTest - Walker");
    208208  strcpy(Walker->Name, "test");
    209   Walker->x.Init(1,1,1);
     209  Walker->x= Vector(1,1,1);
    210210  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
    211211  World::getInstance().destroyAtom(Walker);
     
    215215  Walker->Name = Malloc<char>(6, "LinkedCellTest::SetIndexToNodeTest - Walker");
    216216  strcpy(Walker->Name, "test");
    217   Walker->x.Init(0,-1,0);
     217  Walker->x = Vector(0,-1,0);
    218218  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
    219219  World::getInstance().destroyAtom(Walker);
     
    231231    for (double y=0.5;y<3;y+=1.)
    232232      for (double z=0.5;z<3;z+=1.) {
    233         tester.Init(x,y,z);
     233        tester = Vector(x,y,z);
    234234        CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(&tester) );
    235235      }
     
    238238    for (double y=1.;y<4;y+=1.)
    239239      for (double z=1.;z<4;z+=1.) {
    240         tester.Init(x,y,z);
     240        tester= Vector(x,y,z);
    241241        cout << "Tester is at " << tester << "." << endl;
    242242        CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToVector(&tester) );
     
    246246    for (double y=0.5-1e-10;y<5;y+=3.1)
    247247      for (double z=0.5-1e-10;z<5;z+=3.1) {
    248         tester.Init(x,y,z);
     248        tester = Vector(x,y,z);
    249249        cout << "The following test is supposed to fail and produce an ERROR." << endl;
    250250        CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(&tester) );
    251251      }
    252252  // check nonsense vectors
    253   tester.Init(-423598,3245978,29349);
     253  tester= Vector(-423598,3245978,29349);
    254254  cout << "The following test is supposed to fail and produce an ERROR." << endl;
    255255  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToVector(&tester) );
     
    264264  int lower[NDIM], upper[NDIM];
    265265
    266   tester.Init(0.5,0.5,0.5);
     266  tester= Vector(0.5,0.5,0.5);
    267267  LC->SetIndexToVector(&tester);
    268268  LC->GetNeighbourBounds(lower, upper);
     
    284284
    285285  // get all atoms
    286   tester.Init(1.5,1.5,1.5);
     286  tester= Vector(1.5,1.5,1.5);
    287287  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
    288288  ListOfPoints = LC->GetallNeighbours();
     
    303303
    304304  // get all atoms in one corner
    305   tester.Init(0.5, 0.5, 0.5);
     305  tester= Vector(0.5, 0.5, 0.5);
    306306  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
    307307  ListOfPoints = LC->GetallNeighbours();
     
    311311  while (Walker->next != TestMolecule->end) {
    312312    Walker = Walker->next;
    313     if ((Walker->x.x[0] <2) && (Walker->x.x[1] <2) && (Walker->x.x[2] <2)) {
     313    if ((Walker->x[0] <2) && (Walker->x[1] <2) && (Walker->x[2] <2)) {
    314314      ListOfPoints->remove(Walker);
    315315      size--;
     
    323323
    324324  // get all atoms from one corner
    325   tester.Init(0.5, 0.5, 0.5);
     325  tester = Vector(0.5, 0.5, 0.5);
    326326  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
    327327  ListOfPoints = LC->GetallNeighbours(3);
     
    352352
    353353  // get all points around central arom with radius 1.
    354   tester.Init(1.5,1.5,1.5);
     354  tester= Vector(1.5,1.5,1.5);
    355355  CPPUNIT_ASSERT_EQUAL ( true, LC->SetIndexToVector(&tester) );
    356356  ListOfPoints = LC->GetPointsInsideSphere(1., &tester);
     
    360360  while (Walker->next != TestMolecule->end) {
    361361    Walker = Walker->next;
    362     if ((Walker->x.DistanceSquared(&tester) - 1.) < MYEPSILON ) {
     362    if ((Walker->x.DistanceSquared(tester) - 1.) < MYEPSILON ) {
    363363      ListOfPoints->remove(Walker);
    364364      size--;
  • src/unittests/analysisbondsunittest.cpp

    r632bc3 r8cbb97  
    6969  Walker = World::getInstance().createAtom();
    7070  Walker->type = hydrogen;
    71   Walker->node->Init(1.5, 0., 1.5 );
     71  *Walker->node = Vector(1.5, 0., 1.5 );
    7272  TestMolecule->AddAtom(Walker);
    7373  Walker = World::getInstance().createAtom();
    7474  Walker->type = hydrogen;
    75   Walker->node->Init(0., 1.5, 1.5 );
     75  *Walker->node = Vector(0., 1.5, 1.5 );
    7676  TestMolecule->AddAtom(Walker);
    7777  Walker = World::getInstance().createAtom();
    7878  Walker->type = hydrogen;
    79   Walker->node->Init(1.5, 1.5, 0. );
     79  *Walker->node = Vector(1.5, 1.5, 0. );
    8080  TestMolecule->AddAtom(Walker);
    8181  Walker = World::getInstance().createAtom();
    8282  Walker->type = hydrogen;
    83   Walker->node->Init(0., 0., 0. );
     83  *Walker->node = Vector(0., 0., 0. );
    8484  TestMolecule->AddAtom(Walker);
    8585  Walker = World::getInstance().createAtom();
    8686  Walker->type = carbon;
    87   Walker->node->Init(0.5, 0.5, 0.5 );
     87  *Walker->node = Vector(0.5, 0.5, 0.5 );
    8888  TestMolecule->AddAtom(Walker);
    8989
  • src/unittests/bondgraphunittest.cpp

    r632bc3 r8cbb97  
    7070  Walker = World::getInstance().createAtom();
    7171  Walker->type = carbon;
    72   Walker->node->Init(1., 0., 1. );
     72  *Walker->node = Vector(1., 0., 1. );
    7373  TestMolecule->AddAtom(Walker);
     74
    7475  Walker = World::getInstance().createAtom();
    7576  Walker->type = carbon;
    76   Walker->node->Init(0., 1., 1. );
     77  *Walker->node = Vector(0., 1., 1. );
    7778  TestMolecule->AddAtom(Walker);
     79
    7880  Walker = World::getInstance().createAtom();
    7981  Walker->type = carbon;
    80   Walker->node->Init(1., 1., 0. );
     82  *Walker->node = Vector(1., 1., 0. );
    8183  TestMolecule->AddAtom(Walker);
     84
    8285  Walker = World::getInstance().createAtom();
    8386  Walker->type = carbon;
    84   Walker->node->Init(0., 0., 0. );
     87  *Walker->node = Vector(0., 0., 0. );
    8588  TestMolecule->AddAtom(Walker);
    8689
  • src/unittests/listofbondsunittest.cpp

    r632bc3 r8cbb97  
    5858  Walker = World::getInstance().createAtom();
    5959  Walker->type = hydrogen;
    60   Walker->node->Init(1., 0., 1. );
    61   TestMolecule->AddAtom(Walker);
    62   Walker = World::getInstance().createAtom();
    63   Walker->type = hydrogen;
    64   Walker->node->Init(0., 1., 1. );
    65   TestMolecule->AddAtom(Walker);
    66   Walker = World::getInstance().createAtom();
    67   Walker->type = hydrogen;
    68   Walker->node->Init(1., 1., 0. );
    69   TestMolecule->AddAtom(Walker);
    70   Walker = World::getInstance().createAtom();
    71   Walker->type = hydrogen;
    72   Walker->node->Init(0., 0., 0. );
     60  *Walker->node = Vector(1., 0., 1. );
     61  TestMolecule->AddAtom(Walker);
     62  Walker = World::getInstance().createAtom();
     63  Walker->type = hydrogen;
     64  *Walker->node = Vector(0., 1., 1. );
     65  TestMolecule->AddAtom(Walker);
     66  Walker = World::getInstance().createAtom();
     67  Walker->type = hydrogen;
     68  *Walker->node = Vector(1., 1., 0. );
     69  TestMolecule->AddAtom(Walker);
     70  Walker = World::getInstance().createAtom();
     71  Walker->type = hydrogen;
     72  *Walker->node = Vector(0., 0., 0. );
    7373  TestMolecule->AddAtom(Walker);
    7474
  • src/unittests/tesselation_boundarytriangleunittest.cpp

    r632bc3 r8cbb97  
    8686
    8787  // simple test on y line
    88   Point.Init(-1.,0.5,0.);
    89   CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    90   Point.Init(0.,0.5,0.);
    91   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    92   Point.Init(-4.,0.5,0.);
     88  Point = Vector(-1.,0.5,0.);
     89  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
     90  Point = Vector(0.,0.5,0.);
     91  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
     92  Point = Vector(-4.,0.5,0.);
    9393  CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    94   Point.Init(0.,0.5,0.);
     94  Point = Vector(0.,0.5,0.);
    9595  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    9696
    9797  // simple test on x line
    98   Point.Init(0.5,-1.,0.);
    99   CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    100   Point.Init(0.5,0.,0.);
    101   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    102   Point.Init(0.5,-6.,0.);
     98  Point = Vector(0.5,-1.,0.);
     99  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
     100  Point = Vector(0.5,0.,0.);
     101  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
     102  Point = Vector(0.5,-6.,0.);
    103103  CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    104   Point.Init(0.5,0.,0.);
     104  Point = Vector(0.5,0.,0.);
    105105  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    106106
    107107  // simple test on slanted line
    108   Point.Init(1.,1.,0.);
     108  Point = Vector(1.,1.,0.);
    109109  CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    110   Point.Init(0.5,0.5,0.);
    111   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    112   Point.Init(5.,5.,0.);
     110  Point = Vector(0.5,0.5,0.);
     111  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
     112  Point = Vector(5.,5.,0.);
    113113  CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    114   Point.Init(0.5,0.5,0.);
     114  Point = Vector(0.5,0.5,0.);
    115115  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    116116
    117117  // simple test on first node
    118   Point.Init(-1.,-1.,0.);
     118  Point = Vector(-1.,-1.,0.);
    119119  CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    120   Point.Init(0.,0.,0.);
     120  Point = Vector(0.,0.,0.);
    121121  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    122122
    123123  // simple test on second node
    124   Point.Init(0.,2.,0.);
    125   CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    126   Point.Init(0.,1.,0.);
     124  Point = Vector(0.,2.,0.);
     125  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
     126  Point = Vector(0.,1.,0.);
    127127  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    128128
    129129  // simple test on third node
    130   Point.Init(2.,0.,0.);
    131   CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    132   Point.Init(1.,0.,0.);
     130  Point = Vector(2.,0.,0.);
     131  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
     132  Point = Vector(1.,0.,0.);
    133133  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    134134};
     
    142142
    143143  // straight down/up
    144   Point.Init(1./3.,1./3.,+5.);
     144  Point = Vector(1./3.,1./3.,+5.);
    145145  CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    146   Point.Init(1./3.,1./3.,0.);
    147   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    148   Point.Init(1./3.,1./3.,-5.);
     146  Point = Vector(1./3.,1./3.,0.);
     147  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
     148  Point = Vector(1./3.,1./3.,-5.);
    149149  CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    150   Point.Init(1./3.,1./3.,0.);
     150  Point = Vector(1./3.,1./3.,0.);
    151151  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    152152
    153153  // simple test on y line
    154   Point.Init(-1.,0.5,+2.);
     154  Point = Vector(-1.,0.5,+2.);
    155155  CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    156   Point.Init(0.,0.5,0.);
    157   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    158   Point.Init(-1.,0.5,-3.);
     156  Point = Vector(0.,0.5,0.);
     157  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
     158  Point = Vector(-1.,0.5,-3.);
    159159  CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    160   Point.Init(0.,0.5,0.);
     160  Point = Vector(0.,0.5,0.);
    161161  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    162162
    163163  // simple test on x line
    164   Point.Init(0.5,-1.,+1.);
     164  Point = Vector(0.5,-1.,+1.);
    165165  CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    166   Point.Init(0.5,0.,0.);
    167   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    168   Point.Init(0.5,-1.,-2.);
     166  Point = Vector(0.5,0.,0.);
     167  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
     168  Point = Vector(0.5,-1.,-2.);
    169169  CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    170   Point.Init(0.5,0.,0.);
     170  Point = Vector(0.5,0.,0.);
    171171  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    172172
    173173  // simple test on slanted line
    174   Point.Init(1.,1.,+3.);
     174  Point = Vector(1.,1.,+3.);
    175175  CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    176   Point.Init(0.5,0.5,0.);
    177   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    178   Point.Init(1.,1.,-4.);
     176  Point = Vector(0.5,0.5,0.);
     177  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
     178  Point = Vector(1.,1.,-4.);
    179179  CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    180   Point.Init(0.5,0.5,0.);
     180  Point = Vector(0.5,0.5,0.);
    181181  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    182182
    183183  // simple test on first node
    184   Point.Init(-1.,-1.,5.);
     184  Point = Vector(-1.,-1.,5.);
    185185  CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    186   Point.Init(0.,0.,0.);
     186  Point = Vector(0.,0.,0.);
    187187  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    188188
    189189  // simple test on second node
    190   Point.Init(0.,2.,5.);
     190  Point = Vector(0.,2.,5.);
    191191  CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    192   Point.Init(0.,1.,0.);
     192  Point = Vector(0.,1.,0.);
    193193  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    194194
    195195  // simple test on third node
    196   Point.Init(2.,0.,5.);
     196  Point = Vector(2.,0.,5.);
    197197  CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
    198   Point.Init(1.,0.,0.);
    199   CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
    200 };
     198  Point = Vector(1.,0.,0.);
     199  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
     200};
  • src/unittests/vectorunittest.cpp

    r632bc3 r8cbb97  
    1717#include "memoryusageobserver.hpp"
    1818#include "vector.hpp"
     19#include "vector_ops.hpp"
    1920#include "vectorunittest.hpp"
     21#include "Plane.hpp"
     22#include "Exceptions/LinearDependenceException.hpp"
    2023
    2124#ifdef HAVE_TESTRUNNER
     
    2326#endif /*HAVE_TESTRUNNER*/
    2427
     28#include <iostream>
     29
     30using namespace std;
     31
    2532/********************************************** Test classes **************************************/
    2633
     
    3138void VectorTest::setUp()
    3239{
    33   zero.Init(0.,0.,0.);
    34   unit.Init(1.,0.,0.);
    35   otherunit.Init(0.,1.,0.);
    36   notunit.Init(0.,1.,1.);
    37   two.Init(2.,1.,0.);
     40  zero  = Vector(0.,0.,0.);
     41  unit = Vector(1.,0.,0.);
     42  otherunit = Vector(0.,1.,0.);
     43  notunit = Vector(0.,1.,1.);
     44  two = Vector(2.,1.,0.);
    3845};
    3946
     
    6673  double factor;
    6774  // copy vector
    68   fixture.Init(2.,3.,4.);
     75  fixture = Vector(2.,3.,4.);
    6976  CPPUNIT_ASSERT_EQUAL( Vector(2.,3.,4.), fixture );
    7077  // summation and scaling
    71   fixture.CopyVector(&zero);
    72   fixture.AddVector(&unit);
    73   CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    74   fixture.CopyVector(&zero);
    75   fixture.SubtractVector(&unit);
     78  fixture = zero + unit;
     79  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
     80  fixture = zero - unit;
    7681  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    7782  CPPUNIT_ASSERT_EQUAL( false, fixture.IsZero() );
    78   fixture.CopyVector(&zero);
    79   fixture.AddVector(&zero);
     83  fixture = zero + zero;
    8084  CPPUNIT_ASSERT_EQUAL( true, fixture.IsZero() );
    81   fixture.CopyVector(&notunit);
    82   fixture.SubtractVector(&otherunit);
    83   CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    84   fixture.CopyVector(&unit);
    85   fixture.AddVector(&otherunit);
     85  fixture = notunit - otherunit;
     86  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
     87  fixture = unit - otherunit;
    8688  CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() );
    87   fixture.CopyVector(&notunit);
    88   fixture.SubtractVector(&unit);
    89   fixture.SubtractVector(&otherunit);
     89  fixture = notunit - unit - otherunit;
    9090  CPPUNIT_ASSERT_EQUAL( false, fixture.IsZero() );
    91   fixture.CopyVector(&unit);
    92   fixture.Scale(0.98);
     91  fixture = 0.98 * unit;
    9392  CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() );
    94   fixture.CopyVector(&unit);
    95   fixture.Scale(1.);
    96   CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    97   fixture.CopyVector(&unit);
     93  fixture = 1. * unit;
     94  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    9895  factor = 0.98;
    99   fixture.Scale(factor);
     96  fixture = factor * unit;
    10097  CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() );
    101   fixture.CopyVector(&unit);
    10298  factor = 1.;
    103   fixture.Scale(factor);
     99  fixture = factor * unit;
    104100  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    105101};
     
    131127void VectorTest::EuclidianScalarProductTest()
    132128{
    133   CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(&zero) );
    134   CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(&unit) );
    135   CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(&otherunit) );
    136   CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(&notunit) );
    137   CPPUNIT_ASSERT_EQUAL( 1., unit.ScalarProduct(&unit) );
    138   CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(&unit) );
    139   CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(&unit) );
    140   CPPUNIT_ASSERT_EQUAL( 1., otherunit.ScalarProduct(&notunit) );
    141   CPPUNIT_ASSERT_EQUAL( 2., two.ScalarProduct(&unit) );
    142   CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(&otherunit) );
    143   CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(&notunit) );
     129  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(zero) );
     130  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(unit) );
     131  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(otherunit) );
     132  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(notunit) );
     133  CPPUNIT_ASSERT_EQUAL( 1., unit.ScalarProduct(unit) );
     134  CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(unit) );
     135  CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(unit) );
     136  CPPUNIT_ASSERT_EQUAL( 1., otherunit.ScalarProduct(notunit) );
     137  CPPUNIT_ASSERT_EQUAL( 2., two.ScalarProduct(unit) );
     138  CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(otherunit) );
     139  CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(notunit) );
    144140}
    145141
     
    162158void VectorTest::EuclidianDistancesTest()
    163159{
    164   CPPUNIT_ASSERT_EQUAL( 1., zero.Distance(&unit) );
    165   CPPUNIT_ASSERT_EQUAL( sqrt(2.), otherunit.Distance(&unit) );
    166   CPPUNIT_ASSERT_EQUAL( sqrt(2.), zero.Distance(&notunit) );
    167   CPPUNIT_ASSERT_EQUAL( 1., otherunit.Distance(&notunit) );
    168   CPPUNIT_ASSERT_EQUAL( sqrt(5.), two.Distance(&notunit) );
     160  CPPUNIT_ASSERT_EQUAL( 1., zero.Distance(unit) );
     161  CPPUNIT_ASSERT_EQUAL( sqrt(2.), otherunit.Distance(unit) );
     162  CPPUNIT_ASSERT_EQUAL( sqrt(2.), zero.Distance(notunit) );
     163  CPPUNIT_ASSERT_EQUAL( 1., otherunit.Distance(notunit) );
     164  CPPUNIT_ASSERT_EQUAL( sqrt(5.), two.Distance(notunit) );
    169165}
    170166
     
    173169void VectorTest::EuclidianAnglesTest()
    174170{
    175   CPPUNIT_ASSERT_EQUAL( M_PI, zero.Angle(&unit) );
    176   CPPUNIT_ASSERT_EQUAL( 0., unit.Angle(&unit) );
    177   CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - otherunit.Angle(&unit)) < MYEPSILON );
    178   CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - unit.Angle(&notunit)) < MYEPSILON );
    179   CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/4. - otherunit.Angle(&notunit)) < MYEPSILON );
     171  CPPUNIT_ASSERT_EQUAL( M_PI, zero.Angle(unit) );
     172  CPPUNIT_ASSERT_EQUAL( 0., unit.Angle(unit) );
     173  CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - otherunit.Angle(unit)) < MYEPSILON );
     174  CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - unit.Angle(notunit)) < MYEPSILON );
     175  CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/4. - otherunit.Angle(notunit)) < MYEPSILON );
    180176};
    181177
     
    184180void VectorTest::ProjectionTest()
    185181{
    186   CPPUNIT_ASSERT_EQUAL( zero, zero.Projection(&unit) );
    187   CPPUNIT_ASSERT_EQUAL( zero, otherunit.Projection(&unit) );
    188   CPPUNIT_ASSERT_EQUAL( Vector(0.4,0.2,0.),  otherunit.Projection(&two) );
    189   CPPUNIT_ASSERT_EQUAL( Vector(0.,1.,0.),  two.Projection(&otherunit) );
     182  CPPUNIT_ASSERT_EQUAL( zero, zero.Projection(unit) );
     183  CPPUNIT_ASSERT_EQUAL( zero, otherunit.Projection(unit) );
     184  CPPUNIT_ASSERT_EQUAL( Vector(0.4,0.2,0.),  otherunit.Projection(two) );
     185  CPPUNIT_ASSERT_EQUAL( Vector(0.,1.,0.),  two.Projection(otherunit) );
    190186};
    191187
     
    195191{
    196192  // plane at (0,0,0) normal to (1,0,0) cuts line from (0,0,0) to (2,1,0) at ???
    197   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionWithPlane(&unit, &zero, &zero, &two) );
     193  CPPUNIT_ASSERT_NO_THROW(fixture = Plane(unit, zero).GetIntersection(zero, two) );
    198194  CPPUNIT_ASSERT_EQUAL( zero, fixture );
    199195
    200196  // plane at (2,1,0) normal to (0,1,0) cuts line from (1,0,0) to (0,1,1) at ???
    201   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionWithPlane(&otherunit, &two, &unit, &notunit) );
     197  CPPUNIT_ASSERT_NO_THROW(fixture = Plane(otherunit, two).GetIntersection( unit, notunit) );
    202198  CPPUNIT_ASSERT_EQUAL( Vector(0., 1., 1.), fixture );
    203199
    204200  // four vectors equal to zero
    205   CPPUNIT_ASSERT_EQUAL( false, fixture.GetIntersectionOfTwoLinesOnPlane(&zero, &zero, &zero, &zero, NULL) );
     201  CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(zero, zero, zero, zero), LinearDependenceException);
     202  //CPPUNIT_ASSERT_EQUAL( zero, fixture );
     203
     204  // four vectors equal to unit
     205  CPPUNIT_ASSERT_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, unit, unit, unit), LinearDependenceException);
     206  //CPPUNIT_ASSERT_EQUAL( zero, fixture );
     207
     208  // two equal lines
     209  CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, two));
     210  CPPUNIT_ASSERT_EQUAL( unit, fixture );
     211
     212  // line from (1,0,0) to (2,1,0) cuts line from (1,0,0) to (0,1,0) at ???
     213  CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, unit, otherunit) );
     214  CPPUNIT_ASSERT_EQUAL( unit, fixture );
     215
     216  // line from (1,0,0) to (0,0,0) cuts line from (0,0,0) to (2,1,0) at ???
     217  CPPUNIT_ASSERT_NO_THROW( fixture = GetIntersectionOfTwoLinesOnPlane(unit, zero, zero, two) );
    206218  CPPUNIT_ASSERT_EQUAL( zero, fixture );
    207219
    208   // four vectors equal to unit
    209   CPPUNIT_ASSERT_EQUAL( false, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &unit, &unit, &unit, NULL) );
     220  // line from (1,0,0) to (2,1,0) cuts line from (0,0,0) to (0,1,0) at ???
     221  CPPUNIT_ASSERT_NO_THROW(fixture = GetIntersectionOfTwoLinesOnPlane(unit, two, zero, otherunit) );
     222  CPPUNIT_ASSERT_EQUAL( Vector(0., -1., 0.), fixture );
     223};
     224
     225/** UnitTest for vector rotations.
     226 */
     227void VectorTest::VectorRotationTest()
     228{
     229  fixture = Vector(-1.,0.,0.);
     230
     231  // zero vector does not change
     232  fixture = RotateVector(zero,unit, 1.);
    210233  CPPUNIT_ASSERT_EQUAL( zero, fixture );
    211234
    212   // two equal lines
    213   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &unit, &two, NULL) );
     235  fixture = RotateVector(zero, two, 1.);
     236  CPPUNIT_ASSERT_EQUAL( zero,  fixture);
     237
     238  // vector on axis does not change
     239  fixture = RotateVector(unit,unit, 1.);
    214240  CPPUNIT_ASSERT_EQUAL( unit, fixture );
    215241
    216   // line from (1,0,0) to (2,1,0) cuts line from (1,0,0) to (0,1,0) at ???
    217   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &unit, &otherunit, NULL) );
    218   CPPUNIT_ASSERT_EQUAL( unit, fixture );
    219 
    220   // line from (1,0,0) to (0,0,0) cuts line from (0,0,0) to (2,1,0) at ???
    221   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &zero, &zero, &two, NULL) );
    222   CPPUNIT_ASSERT_EQUAL( zero, fixture );
    223 
    224   // line from (1,0,0) to (2,1,0) cuts line from (0,0,0) to (0,1,0) at ???
    225   CPPUNIT_ASSERT_EQUAL( true, fixture.GetIntersectionOfTwoLinesOnPlane(&unit, &two, &zero, &otherunit, NULL) );
    226   CPPUNIT_ASSERT_EQUAL( Vector(0., -1., 0.), fixture );
    227 };
    228 
    229 /** UnitTest for vector rotations.
    230  */
    231 void VectorTest::VectorRotationTest()
    232 {
    233   fixture.Init(-1.,0.,0.);
    234 
    235   // zero vector does not change
    236   fixture.CopyVector(&zero);
    237   fixture.RotateVector(&unit, 1.);
    238   CPPUNIT_ASSERT_EQUAL( zero, fixture );
    239 
    240   fixture.RotateVector(&two, 1.);
    241   CPPUNIT_ASSERT_EQUAL( zero,  fixture);
    242 
    243   // vector on axis does not change
    244   fixture.CopyVector(&unit);
    245   fixture.RotateVector(&unit, 1.);
    246   CPPUNIT_ASSERT_EQUAL( unit, fixture );
    247 
    248   fixture.RotateVector(&unit, 1.);
    249   CPPUNIT_ASSERT_EQUAL( unit, fixture );
    250 
    251242  // rotations
    252   fixture.CopyVector(&otherunit);
    253   fixture.RotateVector(&unit, M_PI);
     243  fixture = RotateVector(otherunit, unit, M_PI);
    254244  CPPUNIT_ASSERT_EQUAL( Vector(0.,-1.,0.), fixture );
    255245
    256   fixture.CopyVector(&otherunit);
    257   fixture.RotateVector(&unit, 2. * M_PI);
     246  fixture = RotateVector(otherunit, unit, 2. * M_PI);
    258247  CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    259248
    260   fixture.CopyVector(&otherunit);
    261   fixture.RotateVector(&unit, 0);
     249  fixture = RotateVector(otherunit,unit, 0);
    262250  CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    263251
    264   fixture.Init(0.,0.,1.);
    265   fixture.RotateVector(&notunit, M_PI);
     252  fixture = RotateVector(Vector(0.,0.,1.), notunit, M_PI);
    266253  CPPUNIT_ASSERT_EQUAL( otherunit, fixture );
    267254}
     
    283270  parallelepiped[8] = 1;
    284271
    285   fixture.CopyVector(zero);
    286   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    287   fixture.Init(2.5,2.5,2.5);
     272  fixture = zero;
     273  CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
     274  fixture = Vector(2.5,2.5,2.5);
    288275  CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    289   fixture.Init(1.,1.,1.);
    290   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    291   fixture.Init(3.5,3.5,3.5);
    292   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    293   fixture.Init(2.,2.,2.);
     276  fixture = Vector(1.,1.,1.);
     277  CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
     278  fixture = Vector(3.5,3.5,3.5);
     279  CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
     280  fixture = Vector(2.,2.,2.);
    294281  CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    295   fixture.Init(2.,3.,2.);
     282  fixture = Vector(2.,3.,2.);
    296283  CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    297   fixture.Init(-2.,2.,-1.);
    298   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    299 }
    300 
     284  fixture = Vector(-2.,2.,-1.);
     285  CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
     286}
     287
Note: See TracChangeset for help on using the changeset viewer.