Changeset 407782 for src


Ignore:
Timestamp:
Jul 14, 2010, 12:42:13 PM (15 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, 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:
41ea3c
Parents:
5d880e
Message:

Replaced the three single unitVectors with an array to the unitVectors

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/LineUnittest.cpp

    r5d880e r407782  
    2929void LineUnittest::setUp(){
    3030  // three lines along the axes
    31   la1 = new Line(zeroVec,e1);
    32   la2 = new Line(zeroVec,e2);
    33   la3 = new Line(zeroVec,e3);
     31  la1 = new Line(zeroVec,unitVec[0]);
     32  la2 = new Line(zeroVec,unitVec[1]);
     33  la3 = new Line(zeroVec,unitVec[2]);
    3434
    3535  // the lines along the planes defined by two coordinate axes
    36   lp1 = new Line(e1,e1-e2);
    37   lp2 = new Line(e2,e2-e3);
    38   lp3 = new Line(e3,e3-e1);
     36  lp1 = new Line(unitVec[0],unitVec[0]-unitVec[1]);
     37  lp2 = new Line(unitVec[1],unitVec[1]-unitVec[2]);
     38  lp3 = new Line(unitVec[2],unitVec[2]-unitVec[0]);
    3939}
    4040void LineUnittest::tearDown(){
     
    5252
    5353  // direction+origin should never fail
    54   CPPUNIT_ASSERT_NO_THROW(Line(zeroVec,e1));
    55   CPPUNIT_ASSERT_NO_THROW(Line(zeroVec,e2));
    56   CPPUNIT_ASSERT_NO_THROW(Line(zeroVec,e3));
     54  CPPUNIT_ASSERT_NO_THROW(Line(zeroVec,unitVec[0]));
     55  CPPUNIT_ASSERT_NO_THROW(Line(zeroVec,unitVec[1]));
     56  CPPUNIT_ASSERT_NO_THROW(Line(zeroVec,unitVec[2]));
    5757
    5858  // two points fails if both points are the same
    59   CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e1,e2));
    60   CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e2,e3));
    61   CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e3,e1));
     59  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(unitVec[0],unitVec[1]));
     60  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(unitVec[1],unitVec[2]));
     61  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(unitVec[2],unitVec[0]));
    6262  // for zerovectors
    63   CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e1,zeroVec));
    64   CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e2,zeroVec));
    65   CPPUNIT_ASSERT_NO_THROW(makeLineThrough(e3,zeroVec));
     63  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(unitVec[0],zeroVec));
     64  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(unitVec[1],zeroVec));
     65  CPPUNIT_ASSERT_NO_THROW(makeLineThrough(unitVec[2],zeroVec));
    6666  // now we pass two times the same point
    6767  CPPUNIT_ASSERT_THROW(makeLineThrough(zeroVec,zeroVec),LinearDependenceException);
    68   CPPUNIT_ASSERT_THROW(makeLineThrough(e1,e1),LinearDependenceException);
    69   CPPUNIT_ASSERT_THROW(makeLineThrough(e2,e2),LinearDependenceException);
    70   CPPUNIT_ASSERT_THROW(makeLineThrough(e3,e3),LinearDependenceException);
     68  CPPUNIT_ASSERT_THROW(makeLineThrough(unitVec[0],unitVec[0]),LinearDependenceException);
     69  CPPUNIT_ASSERT_THROW(makeLineThrough(unitVec[1],unitVec[1]),LinearDependenceException);
     70  CPPUNIT_ASSERT_THROW(makeLineThrough(unitVec[2],unitVec[2]),LinearDependenceException);
    7171
    7272}
     
    7878void LineUnittest::constructionResultTest(){
    7979  // test all directions
    80   CPPUNIT_ASSERT(testDirection(la1->getDirection(),e1));
    81   CPPUNIT_ASSERT(testDirection(la2->getDirection(),e2));
    82   CPPUNIT_ASSERT(testDirection(la3->getDirection(),e3));
     80  CPPUNIT_ASSERT(testDirection(la1->getDirection(),unitVec[0]));
     81  CPPUNIT_ASSERT(testDirection(la2->getDirection(),unitVec[1]));
     82  CPPUNIT_ASSERT(testDirection(la3->getDirection(),unitVec[2]));
    8383
    8484  // test origins
     
    9292  CPPUNIT_ASSERT(la3->isContained(zeroVec));
    9393
    94   CPPUNIT_ASSERT(la1->isContained(e1));
    95   CPPUNIT_ASSERT(la2->isContained(e2));
    96   CPPUNIT_ASSERT(la3->isContained(e3));
    97 
    98   CPPUNIT_ASSERT(lp1->isContained(e1));
    99   CPPUNIT_ASSERT(lp2->isContained(e2));
    100   CPPUNIT_ASSERT(lp3->isContained(e3));
    101 
    102   CPPUNIT_ASSERT(lp1->isContained(e2));
    103   CPPUNIT_ASSERT(lp2->isContained(e3));
    104   CPPUNIT_ASSERT(lp3->isContained(e1));
     94  CPPUNIT_ASSERT(la1->isContained(unitVec[0]));
     95  CPPUNIT_ASSERT(la2->isContained(unitVec[1]));
     96  CPPUNIT_ASSERT(la3->isContained(unitVec[2]));
     97
     98  CPPUNIT_ASSERT(lp1->isContained(unitVec[0]));
     99  CPPUNIT_ASSERT(lp2->isContained(unitVec[1]));
     100  CPPUNIT_ASSERT(lp3->isContained(unitVec[2]));
     101
     102  CPPUNIT_ASSERT(lp1->isContained(unitVec[1]));
     103  CPPUNIT_ASSERT(lp2->isContained(unitVec[2]));
     104  CPPUNIT_ASSERT(lp3->isContained(unitVec[0]));
    105105}
    106106
     
    112112
    113113  // multiples of the second support vector
    114   CPPUNIT_ASSERT(la1->isContained(e1));
    115   CPPUNIT_ASSERT(la2->isContained(e2));
    116   CPPUNIT_ASSERT(la3->isContained(e3));
    117 
    118   CPPUNIT_ASSERT(la1->isContained(2*e1));
    119   CPPUNIT_ASSERT(la2->isContained(2*e2));
    120   CPPUNIT_ASSERT(la3->isContained(2*e3));
    121 
    122   CPPUNIT_ASSERT(la1->isContained(3*e1));
    123   CPPUNIT_ASSERT(la2->isContained(3*e2));
    124   CPPUNIT_ASSERT(la3->isContained(3*e3));
     114  CPPUNIT_ASSERT(la1->isContained(unitVec[0]));
     115  CPPUNIT_ASSERT(la2->isContained(unitVec[1]));
     116  CPPUNIT_ASSERT(la3->isContained(unitVec[2]));
     117
     118  CPPUNIT_ASSERT(la1->isContained(2*unitVec[0]));
     119  CPPUNIT_ASSERT(la2->isContained(2*unitVec[1]));
     120  CPPUNIT_ASSERT(la3->isContained(2*unitVec[2]));
     121
     122  CPPUNIT_ASSERT(la1->isContained(3*unitVec[0]));
     123  CPPUNIT_ASSERT(la2->isContained(3*unitVec[1]));
     124  CPPUNIT_ASSERT(la3->isContained(3*unitVec[2]));
    125125
    126126  // negative multiples
    127   CPPUNIT_ASSERT(la1->isContained(-1*e1));
    128   CPPUNIT_ASSERT(la2->isContained(-1*e2));
    129   CPPUNIT_ASSERT(la3->isContained(-1*e3));
    130 
    131   CPPUNIT_ASSERT(la1->isContained(-2*e1));
    132   CPPUNIT_ASSERT(la2->isContained(-2*e2));
    133   CPPUNIT_ASSERT(la3->isContained(-2*e3));
     127  CPPUNIT_ASSERT(la1->isContained(-1*unitVec[0]));
     128  CPPUNIT_ASSERT(la2->isContained(-1*unitVec[1]));
     129  CPPUNIT_ASSERT(la3->isContained(-1*unitVec[2]));
     130
     131  CPPUNIT_ASSERT(la1->isContained(-2*unitVec[0]));
     132  CPPUNIT_ASSERT(la2->isContained(-2*unitVec[1]));
     133  CPPUNIT_ASSERT(la3->isContained(-2*unitVec[2]));
    134134
    135135  // points that should not be on the lines
    136   CPPUNIT_ASSERT(!la1->isContained(e2));
    137   CPPUNIT_ASSERT(!la2->isContained(e3));
    138   CPPUNIT_ASSERT(!la3->isContained(e1));
    139 
    140   CPPUNIT_ASSERT(!la1->isContained(2*e2));
    141   CPPUNIT_ASSERT(!la2->isContained(2*e3));
    142   CPPUNIT_ASSERT(!la3->isContained(2*e1));
    143 
    144   CPPUNIT_ASSERT(!la1->isContained(-1*e2));
    145   CPPUNIT_ASSERT(!la2->isContained(-1*e3));
    146   CPPUNIT_ASSERT(!la3->isContained(-1*e1));
     136  CPPUNIT_ASSERT(!la1->isContained(unitVec[1]));
     137  CPPUNIT_ASSERT(!la2->isContained(unitVec[2]));
     138  CPPUNIT_ASSERT(!la3->isContained(unitVec[0]));
     139
     140  CPPUNIT_ASSERT(!la1->isContained(2*unitVec[1]));
     141  CPPUNIT_ASSERT(!la2->isContained(2*unitVec[2]));
     142  CPPUNIT_ASSERT(!la3->isContained(2*unitVec[0]));
     143
     144  CPPUNIT_ASSERT(!la1->isContained(-1*unitVec[1]));
     145  CPPUNIT_ASSERT(!la2->isContained(-1*unitVec[2]));
     146  CPPUNIT_ASSERT(!la3->isContained(-1*unitVec[0]));
    147147
    148148  // For the plane lines
    149   CPPUNIT_ASSERT(lp1->isContained(e1));
    150   CPPUNIT_ASSERT(lp2->isContained(e2));
    151   CPPUNIT_ASSERT(lp3->isContained(e3));
    152 
    153   CPPUNIT_ASSERT(lp1->isContained(e2));
    154   CPPUNIT_ASSERT(lp2->isContained(e3));
    155   CPPUNIT_ASSERT(lp3->isContained(e1));
    156 
    157   CPPUNIT_ASSERT(lp1->isContained(e1+2*(e1-e2)));
    158   CPPUNIT_ASSERT(lp2->isContained(e2+2*(e2-e3)));
    159   CPPUNIT_ASSERT(lp3->isContained(e3+2*(e3-e1)));
    160 
    161   CPPUNIT_ASSERT(lp1->isContained(e1-2*(e1-e2)));
    162   CPPUNIT_ASSERT(lp2->isContained(e2-2*(e2-e3)));
    163   CPPUNIT_ASSERT(lp3->isContained(e3-2*(e3-e1)));
     149  CPPUNIT_ASSERT(lp1->isContained(unitVec[0]));
     150  CPPUNIT_ASSERT(lp2->isContained(unitVec[1]));
     151  CPPUNIT_ASSERT(lp3->isContained(unitVec[2]));
     152
     153  CPPUNIT_ASSERT(lp1->isContained(unitVec[1]));
     154  CPPUNIT_ASSERT(lp2->isContained(unitVec[2]));
     155  CPPUNIT_ASSERT(lp3->isContained(unitVec[0]));
     156
     157  CPPUNIT_ASSERT(lp1->isContained(unitVec[0]+2*(unitVec[0]-unitVec[1])));
     158  CPPUNIT_ASSERT(lp2->isContained(unitVec[1]+2*(unitVec[1]-unitVec[2])));
     159  CPPUNIT_ASSERT(lp3->isContained(unitVec[2]+2*(unitVec[2]-unitVec[0])));
     160
     161  CPPUNIT_ASSERT(lp1->isContained(unitVec[0]-2*(unitVec[0]-unitVec[1])));
     162  CPPUNIT_ASSERT(lp2->isContained(unitVec[1]-2*(unitVec[1]-unitVec[2])));
     163  CPPUNIT_ASSERT(lp3->isContained(unitVec[2]-2*(unitVec[2]-unitVec[0])));
    164164}
    165165
     
    177177  // axes and plane lines
    178178  fixture = la1->getIntersection(*lp1);
    179   CPPUNIT_ASSERT_EQUAL(fixture,e1);
     179  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
    180180  fixture = la2->getIntersection(*lp2);
    181   CPPUNIT_ASSERT_EQUAL(fixture,e2);
     181  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
    182182  fixture = la3->getIntersection(*lp3);
    183   CPPUNIT_ASSERT_EQUAL(fixture,e3);
     183  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
    184184
    185185  fixture = la1->getIntersection(*lp3);
    186   CPPUNIT_ASSERT_EQUAL(fixture,e1);
     186  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
    187187  fixture = la2->getIntersection(*lp1);
    188   CPPUNIT_ASSERT_EQUAL(fixture,e2);
     188  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
    189189  fixture = la3->getIntersection(*lp2);
    190   CPPUNIT_ASSERT_EQUAL(fixture,e3);
     190  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
    191191
    192192  // two plane lines
    193193  fixture = lp1->getIntersection(*lp2);
    194   CPPUNIT_ASSERT_EQUAL(fixture,e2);
     194  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
    195195  fixture = lp2->getIntersection(*lp3);
    196   CPPUNIT_ASSERT_EQUAL(fixture,e3);
     196  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
    197197  fixture = lp3->getIntersection(*lp1);
    198   CPPUNIT_ASSERT_EQUAL(fixture,e1);
     198  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
    199199
    200200  // When we have two times the same line, we check if the point is on the line
     
    242242
    243243  // rotate vectors on the axis around their lines
    244   fixture = la1->rotateVector(e1,1.);
    245   CPPUNIT_ASSERT_EQUAL(fixture,e1);
    246   fixture = la2->rotateVector(e2,1.);
    247   CPPUNIT_ASSERT_EQUAL(fixture,e2);
    248   fixture = la3->rotateVector(e3,1.);
    249   CPPUNIT_ASSERT_EQUAL(fixture,e3);
    250 
    251   fixture = la1->rotateVector(e1,2.);
    252   CPPUNIT_ASSERT_EQUAL(fixture,e1);
    253   fixture = la2->rotateVector(e2,2.);
    254   CPPUNIT_ASSERT_EQUAL(fixture,e2);
    255   fixture = la3->rotateVector(e3,2.);
    256   CPPUNIT_ASSERT_EQUAL(fixture,e3);
     244  fixture = la1->rotateVector(unitVec[0],1.);
     245  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
     246  fixture = la2->rotateVector(unitVec[1],1.);
     247  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
     248  fixture = la3->rotateVector(unitVec[2],1.);
     249  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
     250
     251  fixture = la1->rotateVector(unitVec[0],2.);
     252  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
     253  fixture = la2->rotateVector(unitVec[1],2.);
     254  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
     255  fixture = la3->rotateVector(unitVec[2],2.);
     256  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
    257257
    258258  // more vectors on the axis
    259   fixture = la1->rotateVector(2*e1,1.);
    260   CPPUNIT_ASSERT_EQUAL(fixture,2*e1);
    261   fixture = la2->rotateVector(2*e2,1.);
    262   CPPUNIT_ASSERT_EQUAL(fixture,2*e2);
    263   fixture = la3->rotateVector(2*e3,1.);
    264   CPPUNIT_ASSERT_EQUAL(fixture,2*e3);
    265 
    266   fixture = la1->rotateVector(2*e1,2.);
    267   CPPUNIT_ASSERT_EQUAL(fixture,2*e1);
    268   fixture = la2->rotateVector(2*e2,2.);
    269   CPPUNIT_ASSERT_EQUAL(fixture,2*e2);
    270   fixture = la3->rotateVector(2*e3,2.);
    271   CPPUNIT_ASSERT_EQUAL(fixture,2*e3);
     259  fixture = la1->rotateVector(2*unitVec[0],1.);
     260  CPPUNIT_ASSERT_EQUAL(fixture,2*unitVec[0]);
     261  fixture = la2->rotateVector(2*unitVec[1],1.);
     262  CPPUNIT_ASSERT_EQUAL(fixture,2*unitVec[1]);
     263  fixture = la3->rotateVector(2*unitVec[2],1.);
     264  CPPUNIT_ASSERT_EQUAL(fixture,2*unitVec[2]);
     265
     266  fixture = la1->rotateVector(2*unitVec[0],2.);
     267  CPPUNIT_ASSERT_EQUAL(fixture,2*unitVec[0]);
     268  fixture = la2->rotateVector(2*unitVec[1],2.);
     269  CPPUNIT_ASSERT_EQUAL(fixture,2*unitVec[1]);
     270  fixture = la3->rotateVector(2*unitVec[2],2.);
     271  CPPUNIT_ASSERT_EQUAL(fixture,2*unitVec[2]);
    272272
    273273  // negative factors
    274   fixture = la1->rotateVector(-1*e1,1.);
    275   CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
    276   fixture = la2->rotateVector(-1*e2,1.);
    277   CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
    278   fixture = la3->rotateVector(-1*e3,1.);
    279   CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
    280 
    281   fixture = la1->rotateVector(-1*e1,2.);
    282   CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
    283   fixture = la2->rotateVector(-1*e2,2.);
    284   CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
    285   fixture = la3->rotateVector(-1*e3,2.);
    286   CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
     274  fixture = la1->rotateVector(-1*unitVec[0],1.);
     275  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[0]);
     276  fixture = la2->rotateVector(-1*unitVec[1],1.);
     277  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[1]);
     278  fixture = la3->rotateVector(-1*unitVec[2],1.);
     279  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[2]);
     280
     281  fixture = la1->rotateVector(-1*unitVec[0],2.);
     282  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[0]);
     283  fixture = la2->rotateVector(-1*unitVec[1],2.);
     284  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[1]);
     285  fixture = la3->rotateVector(-1*unitVec[2],2.);
     286  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[2]);
    287287
    288288
    289289
    290290  // now the real rotations
    291   // e2 around e1
    292   fixture = la1->rotateVector(e2,0);
    293   CPPUNIT_ASSERT_EQUAL(fixture,e2);
    294   fixture = la1->rotateVector(e2,1./2.*M_PI);
    295   CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
    296   fixture = la1->rotateVector(e2,M_PI);
    297   CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
    298   fixture = la1->rotateVector(e2,2*M_PI);
    299   CPPUNIT_ASSERT_EQUAL(fixture,e2);
    300 
    301   // e3 around e2
    302   fixture = la2->rotateVector(e3,0);
    303   CPPUNIT_ASSERT_EQUAL(fixture,e3);
    304   fixture = la2->rotateVector(e3,1./2.*M_PI);
    305   CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
    306   fixture = la2->rotateVector(e3,M_PI);
    307   CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
    308   fixture = la2->rotateVector(e3,2*M_PI);
    309   CPPUNIT_ASSERT_EQUAL(fixture,e3);
    310 
    311   // e1 around e3
    312   fixture = la3->rotateVector(e1,0);
    313   CPPUNIT_ASSERT_EQUAL(fixture,e1);
    314   fixture = la3->rotateVector(e1,1./2.*M_PI);
    315   CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
    316   fixture = la3->rotateVector(e1,M_PI);
    317   CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
    318   fixture = la3->rotateVector(e1,2*M_PI);
    319   CPPUNIT_ASSERT_EQUAL(fixture,e1);
     291  // unitVec[1] around unitVec[0]
     292  fixture = la1->rotateVector(unitVec[1],0);
     293  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
     294  fixture = la1->rotateVector(unitVec[1],1./2.*M_PI);
     295  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[2]);
     296  fixture = la1->rotateVector(unitVec[1],M_PI);
     297  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[1]);
     298  fixture = la1->rotateVector(unitVec[1],2*M_PI);
     299  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
     300
     301  // unitVec[2] around unitVec[1]
     302  fixture = la2->rotateVector(unitVec[2],0);
     303  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
     304  fixture = la2->rotateVector(unitVec[2],1./2.*M_PI);
     305  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[0]);
     306  fixture = la2->rotateVector(unitVec[2],M_PI);
     307  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[2]);
     308  fixture = la2->rotateVector(unitVec[2],2*M_PI);
     309  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
     310
     311  // unitVec[0] around unitVec[2]
     312  fixture = la3->rotateVector(unitVec[0],0);
     313  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
     314  fixture = la3->rotateVector(unitVec[0],1./2.*M_PI);
     315  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[1]);
     316  fixture = la3->rotateVector(unitVec[0],M_PI);
     317  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[0]);
     318  fixture = la3->rotateVector(unitVec[0],2*M_PI);
     319  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
    320320
    321321
     
    323323
    324324  // Vectors on the line
    325   fixture = lp1->rotateVector(e1,1.);
    326   CPPUNIT_ASSERT_EQUAL(fixture,e1);
    327   fixture = lp1->rotateVector(e2,1.);
    328   CPPUNIT_ASSERT_EQUAL(fixture,e2);
    329 
    330   fixture = lp2->rotateVector(e2,1.);
    331   CPPUNIT_ASSERT_EQUAL(fixture,e2);
    332   fixture = lp2->rotateVector(e3,1.);
    333   CPPUNIT_ASSERT_EQUAL(fixture,e3);
    334 
    335   fixture = lp3->rotateVector(e3,1.);
    336   CPPUNIT_ASSERT_EQUAL(fixture,e3);
    337   fixture = lp3->rotateVector(e1,1.);
    338   CPPUNIT_ASSERT_EQUAL(fixture,e1);
     325  fixture = lp1->rotateVector(unitVec[0],1.);
     326  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
     327  fixture = lp1->rotateVector(unitVec[1],1.);
     328  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
     329
     330  fixture = lp2->rotateVector(unitVec[1],1.);
     331  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
     332  fixture = lp2->rotateVector(unitVec[2],1.);
     333  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
     334
     335  fixture = lp3->rotateVector(unitVec[2],1.);
     336  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
     337  fixture = lp3->rotateVector(unitVec[0],1.);
     338  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
    339339
    340340  // the real stuff
     
    358358    std::vector<Vector> res = la1->getSphereIntersections();
    359359    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    360     CPPUNIT_ASSERT(testDirection(res[0],e1));
    361     CPPUNIT_ASSERT(testDirection(res[1],e1));
     360    CPPUNIT_ASSERT(testDirection(res[0],unitVec[0]));
     361    CPPUNIT_ASSERT(testDirection(res[1],unitVec[0]));
    362362    CPPUNIT_ASSERT(res[0]!=res[1]);
    363363  }
     
    366366    std::vector<Vector> res = la2->getSphereIntersections();
    367367    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    368     CPPUNIT_ASSERT(testDirection(res[0],e2));
    369     CPPUNIT_ASSERT(testDirection(res[1],e2));
     368    CPPUNIT_ASSERT(testDirection(res[0],unitVec[1]));
     369    CPPUNIT_ASSERT(testDirection(res[1],unitVec[1]));
    370370    CPPUNIT_ASSERT(res[0]!=res[1]);
    371371  }
     
    374374    std::vector<Vector> res = la3->getSphereIntersections();
    375375    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    376     CPPUNIT_ASSERT(testDirection(res[0],e3));
    377     CPPUNIT_ASSERT(testDirection(res[1],e3));
     376    CPPUNIT_ASSERT(testDirection(res[0],unitVec[2]));
     377    CPPUNIT_ASSERT(testDirection(res[1],unitVec[2]));
    378378    CPPUNIT_ASSERT(res[0]!=res[1]);
    379379  }
     
    382382    std::vector<Vector> res = lp1->getSphereIntersections();
    383383    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    384     CPPUNIT_ASSERT((res[0]==e1) || (res[0]==e2));
    385     CPPUNIT_ASSERT((res[1]==e1) || (res[1]==e2));
     384    CPPUNIT_ASSERT((res[0]==unitVec[0]) || (res[0]==unitVec[1]));
     385    CPPUNIT_ASSERT((res[1]==unitVec[0]) || (res[1]==unitVec[1]));
    386386    CPPUNIT_ASSERT(res[0]!=res[1]);
    387387  }
     
    390390    std::vector<Vector> res = lp2->getSphereIntersections();
    391391    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    392     CPPUNIT_ASSERT((res[0]==e2) || (res[0]==e3));
    393     CPPUNIT_ASSERT((res[1]==e2) || (res[1]==e3));
     392    CPPUNIT_ASSERT((res[0]==unitVec[1]) || (res[0]==unitVec[2]));
     393    CPPUNIT_ASSERT((res[1]==unitVec[1]) || (res[1]==unitVec[2]));
    394394    CPPUNIT_ASSERT(res[0]!=res[1]);
    395395  }
     
    398398    std::vector<Vector> res = lp3->getSphereIntersections();
    399399    CPPUNIT_ASSERT_EQUAL(res.size(),(size_t)2);
    400     CPPUNIT_ASSERT((res[0]==e3) || (res[0]==e1));
    401     CPPUNIT_ASSERT((res[1]==e3) || (res[1]==e1));
    402     CPPUNIT_ASSERT(res[0]!=res[1]);
    403   }
    404 }
     400    CPPUNIT_ASSERT((res[0]==unitVec[2]) || (res[0]==unitVec[0]));
     401    CPPUNIT_ASSERT((res[1]==unitVec[2]) || (res[1]==unitVec[0]));
     402    CPPUNIT_ASSERT(res[0]!=res[1]);
     403  }
     404}
  • src/unittests/MatrixUnittest.cpp

    r5d880e r407782  
    3939  }
    4040  perm1 = new Matrix();
    41   perm1->column(0) = e1;
    42   perm1->column(1) = e3;
    43   perm1->column(2) = e2;
     41  perm1->column(0) = unitVec[0];
     42  perm1->column(1) = unitVec[2];
     43  perm1->column(2) = unitVec[1];
    4444
    4545
    4646  perm2 = new Matrix();
    47   perm2->column(0) = e2;
    48   perm2->column(1) = e1;
    49   perm2->column(2) = e3;
     47  perm2->column(0) = unitVec[1];
     48  perm2->column(1) = unitVec[0];
     49  perm2->column(2) = unitVec[2];
    5050
    5151  perm3 = new Matrix();
    52   perm3->column(0) = e2;
    53   perm3->column(1) = e3;
    54   perm3->column(2) = e1;
     52  perm3->column(0) = unitVec[1];
     53  perm3->column(1) = unitVec[2];
     54  perm3->column(2) = unitVec[0];
    5555
    5656  perm4 = new Matrix();
    57   perm4->column(0) = e3;
    58   perm4->column(1) = e2;
    59   perm4->column(2) = e1;
     57  perm4->column(0) = unitVec[2];
     58  perm4->column(1) = unitVec[1];
     59  perm4->column(2) = unitVec[0];
    6060
    6161  perm5 = new Matrix();
    62   perm5->column(0) = e3;
    63   perm5->column(1) = e1;
    64   perm5->column(2) = e2;
     62  perm5->column(0) = unitVec[2];
     63  perm5->column(1) = unitVec[0];
     64  perm5->column(2) = unitVec[1];
    6565
    6666}
     
    108108
    109109  mat.one();
    110   CPPUNIT_ASSERT_EQUAL(mat.row(0),e1);
    111   CPPUNIT_ASSERT_EQUAL(mat.row(1),e2);
    112   CPPUNIT_ASSERT_EQUAL(mat.row(2),e3);
    113   CPPUNIT_ASSERT_EQUAL(mat.column(0),e1);
    114   CPPUNIT_ASSERT_EQUAL(mat.column(1),e2);
    115   CPPUNIT_ASSERT_EQUAL(mat.column(2),e3);
     110  CPPUNIT_ASSERT_EQUAL(mat.row(0),unitVec[0]);
     111  CPPUNIT_ASSERT_EQUAL(mat.row(1),unitVec[1]);
     112  CPPUNIT_ASSERT_EQUAL(mat.row(2),unitVec[2]);
     113  CPPUNIT_ASSERT_EQUAL(mat.column(0),unitVec[0]);
     114  CPPUNIT_ASSERT_EQUAL(mat.column(1),unitVec[1]);
     115  CPPUNIT_ASSERT_EQUAL(mat.column(2),unitVec[2]);
    116116
    117117  Vector t1=Vector(1.,1.,1.);
     
    204204
    205205  res = (*diagonal)*(*perm1);
    206   CPPUNIT_ASSERT_EQUAL(res.column(0),e1);
    207   CPPUNIT_ASSERT_EQUAL(res.column(1),3*e3);
    208   CPPUNIT_ASSERT_EQUAL(res.column(2),2*e2);
     206  CPPUNIT_ASSERT_EQUAL(res.column(0),unitVec[0]);
     207  CPPUNIT_ASSERT_EQUAL(res.column(1),3*unitVec[2]);
     208  CPPUNIT_ASSERT_EQUAL(res.column(2),2*unitVec[1]);
    209209  res = (*diagonal)*(*perm2);
    210   CPPUNIT_ASSERT_EQUAL(res.column(0),2*e2);
    211   CPPUNIT_ASSERT_EQUAL(res.column(1),e1);
    212   CPPUNIT_ASSERT_EQUAL(res.column(2),3*e3);
     210  CPPUNIT_ASSERT_EQUAL(res.column(0),2*unitVec[1]);
     211  CPPUNIT_ASSERT_EQUAL(res.column(1),unitVec[0]);
     212  CPPUNIT_ASSERT_EQUAL(res.column(2),3*unitVec[2]);
    213213  res = (*diagonal)*(*perm3);
    214   CPPUNIT_ASSERT_EQUAL(res.column(0),2*e2);
    215   CPPUNIT_ASSERT_EQUAL(res.column(1),3*e3);
    216   CPPUNIT_ASSERT_EQUAL(res.column(2),e1);
     214  CPPUNIT_ASSERT_EQUAL(res.column(0),2*unitVec[1]);
     215  CPPUNIT_ASSERT_EQUAL(res.column(1),3*unitVec[2]);
     216  CPPUNIT_ASSERT_EQUAL(res.column(2),unitVec[0]);
    217217  res = (*diagonal)*(*perm4);
    218   CPPUNIT_ASSERT_EQUAL(res.column(0),3*e3);
    219   CPPUNIT_ASSERT_EQUAL(res.column(1),2*e2);
    220   CPPUNIT_ASSERT_EQUAL(res.column(2),e1);
     218  CPPUNIT_ASSERT_EQUAL(res.column(0),3*unitVec[2]);
     219  CPPUNIT_ASSERT_EQUAL(res.column(1),2*unitVec[1]);
     220  CPPUNIT_ASSERT_EQUAL(res.column(2),unitVec[0]);
    221221  res = (*diagonal)*(*perm5);
    222   CPPUNIT_ASSERT_EQUAL(res.column(0),3*e3);
    223   CPPUNIT_ASSERT_EQUAL(res.column(1),e1);
    224   CPPUNIT_ASSERT_EQUAL(res.column(2),2*e2);
     222  CPPUNIT_ASSERT_EQUAL(res.column(0),3*unitVec[2]);
     223  CPPUNIT_ASSERT_EQUAL(res.column(1),unitVec[0]);
     224  CPPUNIT_ASSERT_EQUAL(res.column(2),2*unitVec[1]);
    225225}
    226226
     
    261261
    262262void MatrixUnittest::VecMultTest(){
    263   CPPUNIT_ASSERT_EQUAL((*zero)*e1,zeroVec);
    264   CPPUNIT_ASSERT_EQUAL((*zero)*e2,zeroVec);
    265   CPPUNIT_ASSERT_EQUAL((*zero)*e3,zeroVec);
     263  CPPUNIT_ASSERT_EQUAL((*zero)*unitVec[0],zeroVec);
     264  CPPUNIT_ASSERT_EQUAL((*zero)*unitVec[1],zeroVec);
     265  CPPUNIT_ASSERT_EQUAL((*zero)*unitVec[2],zeroVec);
    266266  CPPUNIT_ASSERT_EQUAL((*zero)*zeroVec,zeroVec);
    267267
    268   CPPUNIT_ASSERT_EQUAL((*one)*e1,e1);
    269   CPPUNIT_ASSERT_EQUAL((*one)*e2,e2);
    270   CPPUNIT_ASSERT_EQUAL((*one)*e3,e3);
     268  CPPUNIT_ASSERT_EQUAL((*one)*unitVec[0],unitVec[0]);
     269  CPPUNIT_ASSERT_EQUAL((*one)*unitVec[1],unitVec[1]);
     270  CPPUNIT_ASSERT_EQUAL((*one)*unitVec[2],unitVec[2]);
    271271  CPPUNIT_ASSERT_EQUAL((*one)*zeroVec,zeroVec);
    272272
    273   CPPUNIT_ASSERT_EQUAL((*diagonal)*e1,e1);
    274   CPPUNIT_ASSERT_EQUAL((*diagonal)*e2,2*e2);
    275   CPPUNIT_ASSERT_EQUAL((*diagonal)*e3,3*e3);
     273  CPPUNIT_ASSERT_EQUAL((*diagonal)*unitVec[0],unitVec[0]);
     274  CPPUNIT_ASSERT_EQUAL((*diagonal)*unitVec[1],2*unitVec[1]);
     275  CPPUNIT_ASSERT_EQUAL((*diagonal)*unitVec[2],3*unitVec[2]);
    276276  CPPUNIT_ASSERT_EQUAL((*diagonal)*zeroVec,zeroVec);
    277277
    278   CPPUNIT_ASSERT_EQUAL((*perm1)*e1,e1);
    279   CPPUNIT_ASSERT_EQUAL((*perm1)*e2,e3);
    280   CPPUNIT_ASSERT_EQUAL((*perm1)*e3,e2);
     278  CPPUNIT_ASSERT_EQUAL((*perm1)*unitVec[0],unitVec[0]);
     279  CPPUNIT_ASSERT_EQUAL((*perm1)*unitVec[1],unitVec[2]);
     280  CPPUNIT_ASSERT_EQUAL((*perm1)*unitVec[2],unitVec[1]);
    281281  CPPUNIT_ASSERT_EQUAL((*perm1)*zeroVec,zeroVec);
    282282
    283   CPPUNIT_ASSERT_EQUAL((*perm2)*e1,e2);
    284   CPPUNIT_ASSERT_EQUAL((*perm2)*e2,e1);
    285   CPPUNIT_ASSERT_EQUAL((*perm2)*e3,e3);
     283  CPPUNIT_ASSERT_EQUAL((*perm2)*unitVec[0],unitVec[1]);
     284  CPPUNIT_ASSERT_EQUAL((*perm2)*unitVec[1],unitVec[0]);
     285  CPPUNIT_ASSERT_EQUAL((*perm2)*unitVec[2],unitVec[2]);
    286286  CPPUNIT_ASSERT_EQUAL((*perm2)*zeroVec,zeroVec);
    287287
    288   CPPUNIT_ASSERT_EQUAL((*perm3)*e1,e2);
    289   CPPUNIT_ASSERT_EQUAL((*perm3)*e2,e3);
    290   CPPUNIT_ASSERT_EQUAL((*perm3)*e3,e1);
     288  CPPUNIT_ASSERT_EQUAL((*perm3)*unitVec[0],unitVec[1]);
     289  CPPUNIT_ASSERT_EQUAL((*perm3)*unitVec[1],unitVec[2]);
     290  CPPUNIT_ASSERT_EQUAL((*perm3)*unitVec[2],unitVec[0]);
    291291  CPPUNIT_ASSERT_EQUAL((*perm3)*zeroVec,zeroVec);
    292292
    293   CPPUNIT_ASSERT_EQUAL((*perm4)*e1,e3);
    294   CPPUNIT_ASSERT_EQUAL((*perm4)*e2,e2);
    295   CPPUNIT_ASSERT_EQUAL((*perm4)*e3,e1);
     293  CPPUNIT_ASSERT_EQUAL((*perm4)*unitVec[0],unitVec[2]);
     294  CPPUNIT_ASSERT_EQUAL((*perm4)*unitVec[1],unitVec[1]);
     295  CPPUNIT_ASSERT_EQUAL((*perm4)*unitVec[2],unitVec[0]);
    296296  CPPUNIT_ASSERT_EQUAL((*perm4)*zeroVec,zeroVec);
    297297
    298   CPPUNIT_ASSERT_EQUAL((*perm5)*e1,e3);
    299   CPPUNIT_ASSERT_EQUAL((*perm5)*e2,e1);
    300   CPPUNIT_ASSERT_EQUAL((*perm5)*e3,e2);
     298  CPPUNIT_ASSERT_EQUAL((*perm5)*unitVec[0],unitVec[2]);
     299  CPPUNIT_ASSERT_EQUAL((*perm5)*unitVec[1],unitVec[0]);
     300  CPPUNIT_ASSERT_EQUAL((*perm5)*unitVec[2],unitVec[1]);
    301301  CPPUNIT_ASSERT_EQUAL((*perm5)*zeroVec,zeroVec);
    302302
  • src/unittests/PlaneUnittest.cpp

    r5d880e r407782  
    2424
    2525void PlaneUnittest::setUp(){
    26   p1 = new Plane(e1,e2,e3);
    27   p2 = new Plane(e1,e2,zeroVec);
    28   p3 = new Plane(e1,zeroVec,e3);
    29   p4 = new Plane(zeroVec,e2,e3);
     26  p1 = new Plane(unitVec[0],unitVec[1],unitVec[2]);
     27  p2 = new Plane(unitVec[0],unitVec[1],zeroVec);
     28  p3 = new Plane(unitVec[0],zeroVec,unitVec[2]);
     29  p4 = new Plane(zeroVec,unitVec[1],unitVec[2]);
    3030}
    3131
     
    4242
    4343  // three points
    44   CPPUNIT_ASSERT_NO_THROW(Plane(e1,e2,e3));
     44  CPPUNIT_ASSERT_NO_THROW(Plane(unitVec[0],unitVec[1],unitVec[2]));
    4545  // when only two points are differnt this gives an error
    46   CPPUNIT_ASSERT_THROW(Plane(e1,e2,e2),LinearDependenceException);
     46  CPPUNIT_ASSERT_THROW(Plane(unitVec[0],unitVec[1],unitVec[1]),LinearDependenceException);
    4747  // same with only one point
    48   CPPUNIT_ASSERT_THROW(Plane(e1,e1,e1),LinearDependenceException);
     48  CPPUNIT_ASSERT_THROW(Plane(unitVec[0],unitVec[0],unitVec[0]),LinearDependenceException);
    4949
    5050  // use two vector giving two directions
    51   CPPUNIT_ASSERT_NO_THROW(Plane(e1,e2,0));
     51  CPPUNIT_ASSERT_NO_THROW(Plane(unitVec[0],unitVec[1],0));
    5252  // and again this is actually only one vector
    53   CPPUNIT_ASSERT_THROW(Plane(e1,e1,0),LinearDependenceException);
     53  CPPUNIT_ASSERT_THROW(Plane(unitVec[0],unitVec[0],0),LinearDependenceException);
    5454  // Zero vector does not give a good direction
    55   CPPUNIT_ASSERT_THROW(Plane(e1,zeroVec,0),ZeroVectorException);
     55  CPPUNIT_ASSERT_THROW(Plane(unitVec[0],zeroVec,0),ZeroVectorException);
    5656
    5757  // use a normalvector and an scalar offset
    58   CPPUNIT_ASSERT_NO_THROW(Plane(e1,0));
     58  CPPUNIT_ASSERT_NO_THROW(Plane(unitVec[0],0));
    5959  // The zero vector is no good as a normalvector
    6060  CPPUNIT_ASSERT_THROW(Plane(zeroVec,0),ZeroVectorException);
    6161
    6262  // use a normalvector and an offset vector
    63   CPPUNIT_ASSERT_NO_THROW(Plane(e1,zeroVec));
     63  CPPUNIT_ASSERT_NO_THROW(Plane(unitVec[0],zeroVec));
    6464  // and the bad zeroVector again
    6565  CPPUNIT_ASSERT_THROW(Plane(zeroVec,zeroVec),ZeroVectorException);
     
    7575  {
    7676    // construct with three points on plane
    77     Plane p1(e1,e2,zeroVec);
    78     CPPUNIT_ASSERT(testNormal(e3,p1.getNormal()));
     77    Plane p1(unitVec[0],unitVec[1],zeroVec);
     78    CPPUNIT_ASSERT(testNormal(unitVec[2],p1.getNormal()));
    7979    CPPUNIT_ASSERT_EQUAL(0.,p1.getOffset());
    8080
    81     Plane p2(e1,e3,zeroVec);
    82     CPPUNIT_ASSERT(testNormal(e2,p2.getNormal()));
     81    Plane p2(unitVec[0],unitVec[2],zeroVec);
     82    CPPUNIT_ASSERT(testNormal(unitVec[1],p2.getNormal()));
    8383    CPPUNIT_ASSERT_EQUAL(0.,p2.getOffset());
    8484
    85     Plane p3(e2,e3,zeroVec);
    86     CPPUNIT_ASSERT(testNormal(e1,p3.getNormal()));
     85    Plane p3(unitVec[1],unitVec[2],zeroVec);
     86    CPPUNIT_ASSERT(testNormal(unitVec[0],p3.getNormal()));
    8787    CPPUNIT_ASSERT_EQUAL(0.,p3.getOffset());
    8888  }
    8989  {
    9090    // construct with two directions + offset
    91     Plane p1(e1,e2,0);
    92     CPPUNIT_ASSERT(testNormal(e3,p1.getNormal()));
     91    Plane p1(unitVec[0],unitVec[1],0);
     92    CPPUNIT_ASSERT(testNormal(unitVec[2],p1.getNormal()));
    9393    CPPUNIT_ASSERT_EQUAL(0.,p1.getOffset());
    9494
    95     Plane p2(e1,e3,0);
    96     CPPUNIT_ASSERT(testNormal(e2,p2.getNormal()));
     95    Plane p2(unitVec[0],unitVec[2],0);
     96    CPPUNIT_ASSERT(testNormal(unitVec[1],p2.getNormal()));
    9797    CPPUNIT_ASSERT_EQUAL(0.,p2.getOffset());
    9898
    99     Plane p3(e2,e3,0);
    100     CPPUNIT_ASSERT(testNormal(e1,p3.getNormal()));
     99    Plane p3(unitVec[1],unitVec[2],0);
     100    CPPUNIT_ASSERT(testNormal(unitVec[0],p3.getNormal()));
    101101    CPPUNIT_ASSERT_EQUAL(0.,p3.getOffset());
    102102  }
     
    145145void PlaneUnittest::operationsTest(){
    146146  {
    147     Vector t = (1./3.)*(e1+e2+e3);
     147    Vector t = (1./3.)*(unitVec[0]+unitVec[1]+unitVec[2]);
    148148    CPPUNIT_ASSERT(fabs(p1->distance(zeroVec)-t.Norm()) < MYEPSILON);
    149149    CPPUNIT_ASSERT_EQUAL(t,p1->getClosestPoint(zeroVec));
    150150  }
    151151
    152   CPPUNIT_ASSERT(fabs(p2->distance(e3)-1) < MYEPSILON);
    153   CPPUNIT_ASSERT_EQUAL(zeroVec,p2->getClosestPoint(e3));
    154   CPPUNIT_ASSERT(fabs(p3->distance(e2)-1) < MYEPSILON);
    155   CPPUNIT_ASSERT_EQUAL(zeroVec,p3->getClosestPoint(e2));
    156   CPPUNIT_ASSERT(fabs(p4->distance(e1)-1) < MYEPSILON);
    157   CPPUNIT_ASSERT_EQUAL(zeroVec,p4->getClosestPoint(e1));
     152  CPPUNIT_ASSERT(fabs(p2->distance(unitVec[2])-1) < MYEPSILON);
     153  CPPUNIT_ASSERT_EQUAL(zeroVec,p2->getClosestPoint(unitVec[2]));
     154  CPPUNIT_ASSERT(fabs(p3->distance(unitVec[1])-1) < MYEPSILON);
     155  CPPUNIT_ASSERT_EQUAL(zeroVec,p3->getClosestPoint(unitVec[1]));
     156  CPPUNIT_ASSERT(fabs(p4->distance(unitVec[0])-1) < MYEPSILON);
     157  CPPUNIT_ASSERT_EQUAL(zeroVec,p4->getClosestPoint(unitVec[0]));
    158158}
    159159
     
    162162
    163163  // some Vectors that lie on the planes
    164   fixture = p1->mirrorVector(e1);
    165   CPPUNIT_ASSERT_EQUAL(fixture,e1);
    166   fixture = p1->mirrorVector(e2);
    167   CPPUNIT_ASSERT_EQUAL(fixture,e2);
    168   fixture = p1->mirrorVector(e3);
    169   CPPUNIT_ASSERT_EQUAL(fixture,e3);
     164  fixture = p1->mirrorVector(unitVec[0]);
     165  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
     166  fixture = p1->mirrorVector(unitVec[1]);
     167  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
     168  fixture = p1->mirrorVector(unitVec[2]);
     169  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
    170170
    171171  fixture = p2->mirrorVector(zeroVec);
    172172  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
    173   fixture = p2->mirrorVector(e1);
    174   CPPUNIT_ASSERT_EQUAL(fixture,e1);
    175   fixture = p2->mirrorVector(e2);
    176   CPPUNIT_ASSERT_EQUAL(fixture,e2);
     173  fixture = p2->mirrorVector(unitVec[0]);
     174  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
     175  fixture = p2->mirrorVector(unitVec[1]);
     176  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
    177177
    178178  fixture = p3->mirrorVector(zeroVec);
    179179  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
    180   fixture = p3->mirrorVector(e1);
    181   CPPUNIT_ASSERT_EQUAL(fixture,e1);
    182   fixture = p3->mirrorVector(e3);
    183   CPPUNIT_ASSERT_EQUAL(fixture,e3);
     180  fixture = p3->mirrorVector(unitVec[0]);
     181  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[0]);
     182  fixture = p3->mirrorVector(unitVec[2]);
     183  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
    184184
    185185  fixture = p4->mirrorVector(zeroVec);
    186186  CPPUNIT_ASSERT_EQUAL(fixture,zeroVec);
    187   fixture = p4->mirrorVector(e2);
    188   CPPUNIT_ASSERT_EQUAL(fixture,e2);
    189   fixture = p4->mirrorVector(e3);
    190   CPPUNIT_ASSERT_EQUAL(fixture,e3);
     187  fixture = p4->mirrorVector(unitVec[1]);
     188  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[1]);
     189  fixture = p4->mirrorVector(unitVec[2]);
     190  CPPUNIT_ASSERT_EQUAL(fixture,unitVec[2]);
    191191
    192192  // some Vectors outside of the planes
    193193  {
    194     Vector t = (2./3.)*(e1+e2+e3);
     194    Vector t = (2./3.)*(unitVec[0]+unitVec[1]+unitVec[2]);
    195195    fixture = p1->mirrorVector(zeroVec);
    196196    CPPUNIT_ASSERT_EQUAL(fixture,t);
    197197  }
    198198
    199   fixture = p2->mirrorVector(e3);
    200   CPPUNIT_ASSERT_EQUAL(fixture,-1*e3);
    201   fixture = p3->mirrorVector(e2);
    202   CPPUNIT_ASSERT_EQUAL(fixture,-1*e2);
    203   fixture = p4->mirrorVector(e1);
    204   CPPUNIT_ASSERT_EQUAL(fixture,-1*e1);
     199  fixture = p2->mirrorVector(unitVec[2]);
     200  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[2]);
     201  fixture = p3->mirrorVector(unitVec[1]);
     202  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[1]);
     203  fixture = p4->mirrorVector(unitVec[0]);
     204  CPPUNIT_ASSERT_EQUAL(fixture,-1*unitVec[0]);
    205205}
    206206
     
    209209  // plane at (0,0,0) normal to (1,0,0) cuts line from (0,0,0) to (2,1,0) at ???
    210210  Line l1 = makeLineThrough(zeroVec,Vector(2,1,0));
    211   CPPUNIT_ASSERT_NO_THROW(fixture = Plane(e1, zeroVec).GetIntersection(l1) );
     211  CPPUNIT_ASSERT_NO_THROW(fixture = Plane(unitVec[0], zeroVec).GetIntersection(l1) );
    212212  CPPUNIT_ASSERT_EQUAL( zeroVec, fixture );
    213213
    214214  // plane at (2,1,0) normal to (0,1,0) cuts line from (1,0,0) to (0,1,1) at ???
    215   Line l2 = makeLineThrough(e1,Vector(0,1,1));
    216   CPPUNIT_ASSERT_NO_THROW(fixture = Plane(e2, Vector(2,1,0)).GetIntersection(l2) );
     215  Line l2 = makeLineThrough(unitVec[0],Vector(0,1,1));
     216  CPPUNIT_ASSERT_NO_THROW(fixture = Plane(unitVec[1], Vector(2,1,0)).GetIntersection(l2) );
    217217  CPPUNIT_ASSERT_EQUAL( Vector(0., 1., 1.), fixture );
    218218}
  • src/unittests/ShapeUnittest.cpp

    r5d880e r407782  
    2424void ShapeUnittest::setUp()
    2525{
    26   v000 =  0*e1+0*e2+0*e3;
    27   v100 =  1*e1+0*e2+0*e3;
    28   v200 = -1*e1+0*e2+0*e3;
    29   v010 =  0*e1+1*e2+0*e3;
    30   v110 =  1*e1+1*e2+0*e3;
    31   v210 = -1*e1+1*e2+0*e3;
    32   v020 =  0*e1-1*e2+0*e3;
    33   v120 =  1*e1-1*e2+0*e3;
    34   v220 = -1*e1-1*e2+0*e3;
    35   v001 =  0*e1+0*e2+1*e3;
    36   v101 =  1*e1+0*e2+1*e3;
    37   v201 = -1*e1+0*e2+1*e3;
    38   v011 =  0*e1+1*e2+1*e3;
    39   v111 =  1*e1+1*e2+1*e3;
    40   v211 = -1*e1+1*e2+1*e3;
    41   v021 =  0*e1-1*e2+1*e3;
    42   v121 =  1*e1-1*e2+1*e3;
    43   v221 = -1*e1-1*e2+1*e3;
    44   v002 =  0*e1+0*e2-1*e3;
    45   v102 =  1*e1+0*e2-1*e3;
    46   v202 = -1*e1+0*e2-1*e3;
    47   v012 =  0*e1+1*e2-1*e3;
    48   v112 =  1*e1+1*e2-1*e3;
    49   v212 = -1*e1+1*e2-1*e3;
    50   v022 =  0*e1-1*e2-1*e3;
    51   v122 =  1*e1-1*e2-1*e3;
    52   v222 = -1*e1-1*e2-1*e3;
     26  v000 =  0*unitVec[0]+0*unitVec[1]+0*unitVec[2];
     27  v100 =  1*unitVec[0]+0*unitVec[1]+0*unitVec[2];
     28  v200 = -1*unitVec[0]+0*unitVec[1]+0*unitVec[2];
     29  v010 =  0*unitVec[0]+1*unitVec[1]+0*unitVec[2];
     30  v110 =  1*unitVec[0]+1*unitVec[1]+0*unitVec[2];
     31  v210 = -1*unitVec[0]+1*unitVec[1]+0*unitVec[2];
     32  v020 =  0*unitVec[0]-1*unitVec[1]+0*unitVec[2];
     33  v120 =  1*unitVec[0]-1*unitVec[1]+0*unitVec[2];
     34  v220 = -1*unitVec[0]-1*unitVec[1]+0*unitVec[2];
     35  v001 =  0*unitVec[0]+0*unitVec[1]+1*unitVec[2];
     36  v101 =  1*unitVec[0]+0*unitVec[1]+1*unitVec[2];
     37  v201 = -1*unitVec[0]+0*unitVec[1]+1*unitVec[2];
     38  v011 =  0*unitVec[0]+1*unitVec[1]+1*unitVec[2];
     39  v111 =  1*unitVec[0]+1*unitVec[1]+1*unitVec[2];
     40  v211 = -1*unitVec[0]+1*unitVec[1]+1*unitVec[2];
     41  v021 =  0*unitVec[0]-1*unitVec[1]+1*unitVec[2];
     42  v121 =  1*unitVec[0]-1*unitVec[1]+1*unitVec[2];
     43  v221 = -1*unitVec[0]-1*unitVec[1]+1*unitVec[2];
     44  v002 =  0*unitVec[0]+0*unitVec[1]-1*unitVec[2];
     45  v102 =  1*unitVec[0]+0*unitVec[1]-1*unitVec[2];
     46  v202 = -1*unitVec[0]+0*unitVec[1]-1*unitVec[2];
     47  v012 =  0*unitVec[0]+1*unitVec[1]-1*unitVec[2];
     48  v112 =  1*unitVec[0]+1*unitVec[1]-1*unitVec[2];
     49  v212 = -1*unitVec[0]+1*unitVec[1]-1*unitVec[2];
     50  v022 =  0*unitVec[0]-1*unitVec[1]-1*unitVec[2];
     51  v122 =  1*unitVec[0]-1*unitVec[1]-1*unitVec[2];
     52  v222 = -1*unitVec[0]-1*unitVec[1]-1*unitVec[2];
    5353}
    5454
  • src/vector.cpp

    r5d880e r407782  
    534534// some comonly used vectors
    535535const Vector zeroVec(0,0,0);
    536 const Vector e1(1,0,0);
    537 const Vector e2(0,1,0);
    538 const Vector e3(0,0,1);
     536const Vector unitVec[NDIM]={Vector(1,0,0),Vector(0,1,0),Vector(0,0,1)};
  • src/vector.hpp

    r5d880e r407782  
    106106// some commonly used and fixed vectors
    107107const extern Vector zeroVec;
    108 const extern Vector e1;
    109 const extern Vector e2;
    110 const extern Vector e3;
     108const extern Vector unitVec[NDIM];
    111109
    112110ostream & operator << (ostream& ost, const Vector &m);
Note: See TracChangeset for help on using the changeset viewer.