Changeset 273382


Ignore:
Timestamp:
Apr 13, 2010, 1:22:42 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:
1bd79e
Parents:
72e7fa
Message:

Prepared interface of Vector Class for transition to VectorComposites

Location:
src
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    r72e7fa r273382  
    103103          dialog->queryVector("Enter reference coordinates.",&x,mol->cell_size,true);
    104104          dialog->queryVector("Enter relative coordinates.",&first->x,mol->cell_size,false);
    105           first->x.AddVector(&x);
     105          first->x += x;
    106106          dialog->display();
    107107          delete dialog;
     
    168168          */
    169169          // calc axis vector
    170           x.CopyVector(&second->x);
    171           x.SubtractVector(&third->x);
     170          x= second->x - third->x;
    172171          x.Normalize();
    173172          Log() << Verbose(0) << "x: " << x << endl;
     
    178177
    179178          // rotate vector around first angle
    180           first->x.CopyVector(&x);
     179          first->x = x;
    181180          first->x = RotateVector(first->x,z,b - M_PI);
    182181          Log() << Verbose(0) << "Rotated vector: " << first->x << endl,
    183182          // remove the projection onto the rotation plane of the second angle
    184           n.CopyVector(&y);
    185           n.Scale(first->x.ScalarProduct(&y));
     183          n = y;
     184          n.Scale(first->x.ScalarProduct(y));
    186185          Log() << Verbose(0) << "N1: " << n << endl;
    187           first->x.SubtractVector(&n);
     186          first->x -= n;
    188187          Log() << Verbose(0) << "Subtracted vector: " << first->x << endl;
    189           n.CopyVector(&z);
    190           n.Scale(first->x.ScalarProduct(&z));
     188          n = z;
     189          n.Scale(first->x.ScalarProduct(z));
    191190          Log() << Verbose(0) << "N2: " << n << endl;
    192           first->x.SubtractVector(&n);
     191          first->x -= n;
    193192          Log() << Verbose(0) << "2nd subtracted vector: " << first->x << endl;
    194193
    195194          // rotate another vector around second angle
    196           n.CopyVector(&y);
     195          n = y;
    197196          n = RotateVector(n,x,c - M_PI);
    198197          Log() << Verbose(0) << "2nd Rotated vector: " << n << endl;
    199198
    200199          // add the two linear independent vectors
    201           first->x.AddVector(&n);
     200          first->x += n;
    202201          first->x.Normalize();
    203202          first->x.Scale(a);
    204           first->x.AddVector(&second->x);
     203          first->x += second->x;
    205204
    206205          Log() << Verbose(0) << "resulting coordinates: " << first->x << endl;
     
    277276      }
    278277      mol->CenterEdge(&x);  // make every coordinate positive
    279       mol->Center.AddVector(&y); // translate by boundary
    280       helper.CopyVector(&y);
    281       helper.Scale(2.);
    282       helper.AddVector(&x);
     278      mol->Center += y; // translate by boundary
     279      helper = (2*y)+x;
    283280      mol->SetBoxDimension(&helper);  // update Box of atoms by boundary
    284281      break;
     
    340337      second = mol->AskAtom("Enter second atom: ");
    341338
    342       n.CopyVector((const Vector *)&first->x);
    343       n.SubtractVector((const Vector *)&second->x);
     339      n = first->x - second->x;
    344340      n.Normalize();
    345341      break;
     
    408404      second = mol->AskAtom("Enter second atom: ");
    409405
    410       n.CopyVector((const Vector *)&first->x);
    411       n.SubtractVector((const Vector *)&second->x);
     406      n = first->x - second->x;
    412407      n.Normalize();
    413408      break;
     
    453448        first = second;
    454449        second = first->next;
    455         if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
     450        if (first->x.DistanceSquared(second->x) > tmp1*tmp1) // distance to first above radius ...
    456451          mol->RemoveAtom(first);
    457452      }
     
    520515        tmp1 = 0.;
    521516        if (first != second) {
    522           x.CopyVector((const Vector *)&first->x);
    523           x.SubtractVector((const Vector *)&second->x);
     517          x = first->x - second->x;
    524518          tmp1 = x.Norm();
    525519        }
     
    536530      for (int i=NDIM;i--;)
    537531        min[i] = 0.;
    538       x.CopyVector((const Vector *)&first->x);
    539       x.SubtractVector((const Vector *)&second->x);
     532      x = first->x - second->x;
    540533      tmp1 = x.Norm();
    541534      Log() << Verbose(1) << "Distance vector is " << x << "." << "/n"
     
    549542      third  = mol->AskAtom("Enter last atom: ");
    550543      tmp1 = tmp2 = tmp3 = 0.;
    551       x.CopyVector((const Vector *)&first->x);
    552       x.SubtractVector((const Vector *)&second->x);
    553       y.CopyVector((const Vector *)&third->x);
    554       y.SubtractVector((const Vector *)&second->x);
     544      x = first->x - second->x;
     545      y = third->x - second->x;
    555546      Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
    556       Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
     547      Log() << Verbose(0) << (acos(x.ScalarProduct(y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
    557548      break;
    558549    case 'd':
     
    777768      y[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    778769      for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    779         x.AddVector(&y); // per factor one cell width further
     770        x += y; // per factor one cell width further
    780771        for (int k=count;k--;) { // go through every atom of the original cell
    781772          first = World::getInstance().createAtom(); // create a new body
    782           first->x.CopyVector(vectors[k]);  // use coordinate of original atom
    783           first->x.AddVector(&x);     // translate the coordinates
     773          first->x = (*vectors[k]) + x;  // use coordinate of original atom
    784774          first->type = Elements[k];  // insert original element
    785775          mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     
    793783      // correct cell size
    794784      if (axis < 0) { // if sign was negative, we have to translate everything
    795         x.Zero();
    796         x.AddVector(&y);
     785        x = y;
    797786        x.Scale(-(faktor-1));
    798787        mol->Translate(&x);
     
    894883        dialog->display();
    895884        delete dialog;
    896         mol->Center.AddVector((const Vector *)&x);
     885        mol->Center += x;
    897886     }
    898887     break;
  • src/Plane.cpp

    r72e7fa r273382  
    2020  normalVector(new Vector())
    2121{
    22   Vector x1, x2;
    23 
    24   x1.CopyVector(&y1);
    25   x1.SubtractVector(&y2);
    26   x2.CopyVector(&y3);
    27   x2.SubtractVector(&y2);
    28   if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
     22  Vector x1 = y1 -y2;
     23  Vector x2 = y3 -y2;
     24  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(x2)) < MYEPSILON)) {
    2925    throw LinearDependenceException(__FILE__,__LINE__);
    3026  }
     
    4137  normalVector->Normalize();
    4238
    43   offset=normalVector->ScalarProduct(&y1);
     39  offset=normalVector->ScalarProduct(y1);
    4440}
    4541/**
     
    5147    offset(_offset)
    5248{
    53   Vector x1,x2;
    54   x1.CopyVector(&y1);
    55   x2.CopyVector(&y2);
    56   if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
     49  Vector x1 = y1;
     50  Vector x2 = y2;
     51  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(x2)) < MYEPSILON)) {
    5752    throw LinearDependenceException(__FILE__,__LINE__);
    5853  }
     
    8479    normalVector(new Vector(_normalVector))
    8580{
    86   offset = normalVector->ScalarProduct(&_offsetVector);
     81  offset = normalVector->ScalarProduct(_offsetVector);
    8782}
    8883
     
    126121  Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl;
    127122  //Log() << Verbose(1) << "INFO: PlaneNormal is " << *PlaneNormal << " and PlaneOffset is " << *PlaneOffset << "." << endl;
    128   double factor1 = Direction.ScalarProduct(normalVector.get());
     123  double factor1 = Direction.ScalarProduct(*normalVector.get());
    129124  if (fabs(factor1) < MYEPSILON) { // Uniqueness: line parallel to plane?
    130125    Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl;
     
    132127  }
    133128
    134   double factor2 = Origin.ScalarProduct(normalVector.get());
     129  double factor2 = Origin.ScalarProduct(*normalVector.get());
    135130  if (fabs(factor2-offset) < MYEPSILON) { // Origin is in-plane
    136131    Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl;
     
    147142
    148143  // test whether resulting vector really is on plane
    149   ASSERT(fabs(res.ScalarProduct(normalVector.get()) - offset) < MYEPSILON,
     144  ASSERT(fabs(res.ScalarProduct((*normalVector.get())) - offset) < MYEPSILON,
    150145         "Calculated line-Plane intersection does not lie on plane.");
    151146  return res;
  • src/SingleVector.cpp

    r72e7fa r273382  
    119119        TranslationVector.MatrixMultiplication(matrix);
    120120        // add onto the original vector to compare with
    121         Shiftedy.CopyVector(y);
    122         Shiftedy.AddVector(&TranslationVector);
     121        Shiftedy = y + TranslationVector;
    123122        // get distance and compare with minimum so far
    124123        tmp = Distance(Shiftedy);
     
    157156        TranslationVector.MatrixMultiplication(matrix);
    158157        // add onto the original vector to compare with
    159         Shiftedy.CopyVector(y);
    160         Shiftedy.AddVector(&TranslationVector);
     158        Shiftedy = y + TranslationVector;
    161159        // get distance and compare with minimum so far
    162160        tmp = DistanceSquared(Shiftedy);
     
    180178//  Output(out);
    181179//  Log() << Verbose(0) << endl;
    182   TestVector.CopyVector(this);
     180  TestVector = *this;
    183181  TestVector.InverseMatrixMultiplication(matrix);
    184182  for(int i=NDIM;i--;) { // correct periodically
     
    190188  }
    191189  TestVector.MatrixMultiplication(matrix);
    192   CopyVector(&TestVector);
     190  CopyVector(TestVector);
    193191//  Log() << Verbose(2) << "New corrected vector is: ";
    194192//  Output(out);
     
    250248
    251249  // first create part that is orthonormal to PlaneNormal with withdraw
    252   temp = *this - PlaneOffset;
     250  temp = (*this )- PlaneOffset;
    253251  temp.MakeNormalTo(PlaneNormal);
    254252  temp.Scale(-1.);
    255253  // then add connecting vector from plane to point
    256   temp += *this-PlaneOffset;
    257   double sign = temp.ScalarProduct(&PlaneNormal);
     254  temp += (*this)-PlaneOffset;
     255  double sign = temp.ScalarProduct(PlaneNormal);
    258256  if (fabs(sign) > MYEPSILON)
    259257    sign /= fabs(sign);
     
    271269  Vector helper = y;
    272270  helper.Scale(-(ScalarProduct(y)));
    273   AddVector(&helper);
     271  AddVector(helper);
    274272};
    275273
     
    556554{
    557555  bool result = false;
    558   double factor = y1.ScalarProduct(this)/y1.NormSquared();
     556  double factor = y1.ScalarProduct(*this)/y1.NormSquared();
    559557  Vector x1;
    560   x1.CopyVector(&y1);
    561   x1.Scale(factor);
    562   SubtractVector(&x1);
     558  x1 = factor * y1;
     559  SubtractVector(x1);
    563560  for (int i=NDIM;i--;)
    564561    result = result || (fabs(x[i]) > MYEPSILON);
     
    618615bool SingleVector::IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const
    619616{
    620   Vector a;
    621   a.CopyVector(this);
    622   a.SubtractVector(&offset);
     617  Vector a = (*this) - offset;
    623618  a.InverseMatrixMultiplication(parallelepiped);
    624619  bool isInside = true;
  • src/analysis_correlation.cpp

    r72e7fa r273382  
    5555                if (Walker->nr < OtherWalker->nr)
    5656                  if ((type2 == NULL) || (OtherWalker->type == type2)) {
    57                     distance = Walker->node->PeriodicDistance(OtherWalker->node, (*MolWalker)->cell_size);
     57                    distance = Walker->node->PeriodicDistance(*(OtherWalker->node), (*MolWalker)->cell_size);
    5858                    //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    5959                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     
    104104        Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    105105        if ((type1 == NULL) || (Walker->type == type1)) {
    106           periodicX.CopyVector(Walker->node);
     106          periodicX = *(Walker->node);
    107107          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    108108          // go through every range in xyz and get distance
     
    110110            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    111111              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    112                 checkX.Init(n[0], n[1], n[2]);
    113                 checkX.AddVector(&periodicX);
     112                checkX = Vector(n[0], n[1], n[2]) + periodicX;
    114113                checkX.MatrixMultiplication(FullMatrix);
    115114                for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
     
    122121                      if (Walker->nr < OtherWalker->nr)
    123122                        if ((type2 == NULL) || (OtherWalker->type == type2)) {
    124                           periodicOtherX.CopyVector(OtherWalker->node);
     123                          periodicOtherX = *(OtherWalker->node);
    125124                          periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    126125                          // go through every range in xyz and get distance
     
    128127                            for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++)
    129128                              for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) {
    130                                 checkOtherX.Init(Othern[0], Othern[1], Othern[2]);
    131                                 checkOtherX.AddVector(&periodicOtherX);
     129                                checkOtherX = Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX;
    132130                                checkOtherX.MatrixMultiplication(FullMatrix);
    133                                 distance = checkX.Distance(&checkOtherX);
     131                                distance = checkX.Distance(checkOtherX);
    134132                                //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    135133                                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     
    174172        Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    175173        if ((type == NULL) || (Walker->type == type)) {
    176           distance = Walker->node->PeriodicDistance(point, (*MolWalker)->cell_size);
     174          distance = Walker->node->PeriodicDistance(*point, (*MolWalker)->cell_size);
    177175          Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
    178176          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
     
    216214        Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    217215        if ((type == NULL) || (Walker->type == type)) {
    218           periodicX.CopyVector(Walker->node);
     216          periodicX = *(Walker->node);
    219217          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    220218          // go through every range in xyz and get distance
     
    222220            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    223221              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    224                 checkX.Init(n[0], n[1], n[2]);
    225                 checkX.AddVector(&periodicX);
     222                checkX = Vector(n[0], n[1], n[2]) + periodicX;
    226223                checkX.MatrixMultiplication(FullMatrix);
    227                 distance = checkX.Distance(point);
     224                distance = checkX.Distance(*point);
    228225                Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
    229226                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
     
    320317        Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    321318        if ((type == NULL) || (Walker->type == type)) {
    322           periodicX.CopyVector(Walker->node);
     319          periodicX = *(Walker->node);
    323320          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    324321          // go through every range in xyz and get distance
     
    327324            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    328325              for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    329                 checkX.Init(n[0], n[1], n[2]);
    330                 checkX.AddVector(&periodicX);
     326                checkX = Vector(n[0], n[1], n[2]) + periodicX;
    331327                checkX.MatrixMultiplication(FullMatrix);
    332328                triangle = Surface->FindClosestTriangleToVector(&checkX, LC);
  • src/atom.cpp

    r72e7fa r273382  
    3333{
    3434  type = pointer->type;  // copy element of atom
    35   x.CopyVector(&pointer->x); // copy coordination
    36   v.CopyVector(&pointer->v); // copy velocity
     35  x = pointer->x; // copy coordination
     36  v = pointer->v; // copy velocity
    3737  FixedIon = pointer->FixedIon;
    3838  node = &x;
     
    4646  res->sort = &nr;
    4747  res->type = type;
    48   res->x.CopyVector(&this->x);
    49   res->v.CopyVector(&this->v);
     48  res->x = this->x;
     49  res->v = this->v;
    5050  res->FixedIon = FixedIon;
    5151  res->node = &x;
     
    252252double atom::DistanceSquaredToVector(const Vector &origin) const
    253253{
    254   return origin.DistanceSquared(&x);
     254  return origin.DistanceSquared(x);
    255255};
    256256
     
    261261double atom::DistanceToVector(const Vector &origin) const
    262262{
    263   return origin.Distance(&x);
     263  return origin.Distance(x);
    264264};
    265265
  • src/atom_trajectoryparticle.cpp

    r72e7fa r273382  
    4949  // set forces
    5050  for (int i=NDIM;i++;)
    51     Force->Matrix[0][nr][5+i] += 2.*constant*sqrt(Trajectory.R.at(startstep).Distance(&Sprinter->Trajectory.R.at(endstep)));
     51    Force->Matrix[0][nr][5+i] += 2.*constant*sqrt(Trajectory.R.at(startstep).Distance(Sprinter->Trajectory.R.at(endstep)));
    5252};
    5353
  • src/bond.cpp

    r72e7fa r273382  
    119119double bond::GetDistance() const
    120120{
    121   return (leftatom->node->Distance(rightatom->node));
     121  return (leftatom->node->Distance(*rightatom->node));
    122122};
    123123
     
    127127double bond::GetDistanceSquared() const
    128128{
    129   return (leftatom->node->DistanceSquared(rightatom->node));
     129  return (leftatom->node->DistanceSquared(*rightatom->node));
    130130};
  • src/boundary.cpp

    r72e7fa r273382  
    7878              if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around
    7979                Neighbour = BoundaryPoints[axis].begin();
    80               DistanceVector.CopyVector(&runner->second.second->x);
    81               DistanceVector.SubtractVector(&Neighbour->second.second->x);
     80              DistanceVector = runner->second.second->x - Neighbour->second.second->x;
    8281              do { // seek for neighbour pair where it flips
    8382                  OldComponent = DistanceVector[Othercomponent];
     
    8584                  if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around
    8685                    Neighbour = BoundaryPoints[axis].begin();
    87                   DistanceVector.CopyVector(&runner->second.second->x);
    88                   DistanceVector.SubtractVector(&Neighbour->second.second->x);
     86                  DistanceVector = runner->second.second->x - Neighbour->second.second->x;
    8987                  //Log() << Verbose(2) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl;
    9088                } while ((runner != Neighbour) && (fabs(OldComponent / fabs(
     
    9896                  //Log() << Verbose(1) << "The pair, where the sign of OtherComponent flips, is: " << *(Neighbour->second.second) << " and " << *(OtherNeighbour->second.second) << "." << endl;
    9997                  // now we have found the pair: Neighbour and OtherNeighbour
    100                   OtherVector.CopyVector(&runner->second.second->x);
    101                   OtherVector.SubtractVector(&OtherNeighbour->second.second->x);
     98                  OtherVector = runner->second.second->x - OtherNeighbour->second.second->x;
    10299                  //Log() << Verbose(1) << "Distances to Neighbour and OtherNeighbour are " << DistanceVector.x[component] << " and " << OtherVector.x[component] << "." << endl;
    103100                  //Log() << Verbose(1) << "OtherComponents to Neighbour and OtherNeighbour are " << DistanceVector.x[Othercomponent] << " and " << OtherVector.x[Othercomponent] << "." << endl;
     
    170167    while (Walker->next != mol->end) {
    171168      Walker = Walker->next;
    172       ProjectedVector.CopyVector(&Walker->x);
    173       ProjectedVector.SubtractVector(MolCenter);
    174       ProjectedVector.ProjectOntoPlane(&AxisVector);
     169      ProjectedVector = Walker->x - (*MolCenter);
     170      ProjectedVector.ProjectOntoPlane(AxisVector);
    175171
    176172      // correct for negative side
    177173      const double radius = ProjectedVector.NormSquared();
    178174      if (fabs(radius) > MYEPSILON)
    179         angle = ProjectedVector.Angle(&AngleReferenceVector);
     175        angle = ProjectedVector.Angle(AngleReferenceVector);
    180176      else
    181177        angle = 0.; // otherwise it's a vector in Axis Direction and unimportant for boundary issues
    182178
    183179      //Log() << Verbose(1) << "Checking sign in quadrant : " << ProjectedVector.Projection(&AngleReferenceNormalVector) << "." << endl;
    184       if (ProjectedVector.ScalarProduct(&AngleReferenceNormalVector) > 0) {
     180      if (ProjectedVector.ScalarProduct(AngleReferenceNormalVector) > 0) {
    185181        angle = 2. * M_PI - angle;
    186182      }
     
    197193          Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;
    198194        } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) {
    199           helper.CopyVector(&Walker->x);
    200           helper.SubtractVector(MolCenter);
     195          helper = Walker->x - (*MolCenter);
    201196          const double oldhelperNorm = helper.NormSquared();
    202           helper.CopyVector(&BoundaryTestPair.first->second.second->x);
    203           helper.SubtractVector(MolCenter);
     197          helper = BoundaryTestPair.first->second.second->x - (*MolCenter);
    204198          if (helper.NormSquared() < oldhelperNorm) {
    205199            BoundaryTestPair.first->second.second = Walker;
     
    251245        {
    252246          Vector SideA, SideB, SideC, SideH;
    253           SideA.CopyVector(&left->second.second->x);
    254           SideA.SubtractVector(MolCenter);
    255           SideA.ProjectOntoPlane(&AxisVector);
     247          SideA = left->second.second->x - (*MolCenter);
     248          SideA.ProjectOntoPlane(AxisVector);
    256249          //          Log() << Verbose(1) << "SideA: " << SideA << endl;
    257250
    258           SideB.CopyVector(&right->second.second->x);
    259           SideB.SubtractVector(MolCenter);
    260           SideB.ProjectOntoPlane(&AxisVector);
     251          SideB = right->second.second->x -(*MolCenter);
     252          SideB.ProjectOntoPlane(AxisVector);
    261253          //          Log() << Verbose(1) << "SideB: " << SideB << endl;
    262254
    263           SideC.CopyVector(&left->second.second->x);
    264           SideC.SubtractVector(&right->second.second->x);
    265           SideC.ProjectOntoPlane(&AxisVector);
     255          SideC = left->second.second->x - right->second.second->x;
     256          SideC.ProjectOntoPlane(AxisVector);
    266257          //          Log() << Verbose(1) << "SideC: " << SideC << endl;
    267258
    268           SideH.CopyVector(&runner->second.second->x);
    269           SideH.SubtractVector(MolCenter);
    270           SideH.ProjectOntoPlane(&AxisVector);
     259          SideH = runner->second.second->x -(*MolCenter);
     260          SideH.ProjectOntoPlane(AxisVector);
    271261          //          Log() << Verbose(1) << "SideH: " << SideH << endl;
    272262
     
    277267          const double h = SideH.Norm();
    278268          // calculate the angles
    279           const double alpha = SideA.Angle(&SideH);
    280           const double beta = SideA.Angle(&SideC);
    281           const double gamma = SideB.Angle(&SideH);
    282           const double delta = SideC.Angle(&SideH);
     269          const double alpha = SideA.Angle(SideH);
     270          const double beta = SideA.Angle(SideC);
     271          const double gamma = SideB.Angle(SideH);
     272          const double delta = SideC.Angle(SideH);
    283273          const double MinDistance = a * sin(beta) / (sin(delta)) * (((alpha < M_PI / 2.) || (gamma < M_PI / 2.)) ? 1. : -1.);
    284274          //Log() << Verbose(1) << " I calculated: a = " << a << ", h = " << h << ", beta(" << left->second.second->Name << "," << left->second.second->Name << "-" << right->second.second->Name << ") = " << beta << ", delta(" << left->second.second->Name << "," << runner->second.second->Name << ") = " << delta << ", Min = " << MinDistance << "." << endl;
     
    629619  for (TriangleMap::iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++)
    630620    { // go through every triangle, calculate volume of its pyramid with CoG as peak
    631       x.CopyVector(runner->second->endpoints[0]->node->node);
    632       x.SubtractVector(runner->second->endpoints[1]->node->node);
    633       y.CopyVector(runner->second->endpoints[0]->node->node);
    634       y.SubtractVector(runner->second->endpoints[2]->node->node);
    635       const double a = sqrt(runner->second->endpoints[0]->node->node->DistanceSquared(runner->second->endpoints[1]->node->node));
    636       const double b = sqrt(runner->second->endpoints[0]->node->node->DistanceSquared(runner->second->endpoints[2]->node->node));
    637       const double c = sqrt(runner->second->endpoints[2]->node->node->DistanceSquared(runner->second->endpoints[1]->node->node));
     621      x = (*runner->second->endpoints[0]->node->node) - (*runner->second->endpoints[1]->node->node);
     622      y = (*runner->second->endpoints[0]->node->node) - (*runner->second->endpoints[2]->node->node);
     623      const double a = sqrt(runner->second->endpoints[0]->node->node->DistanceSquared(*runner->second->endpoints[1]->node->node));
     624      const double b = sqrt(runner->second->endpoints[0]->node->node->DistanceSquared(*runner->second->endpoints[2]->node->node));
     625      const double c = sqrt(runner->second->endpoints[2]->node->node->DistanceSquared(*runner->second->endpoints[1]->node->node));
    638626      const double G = sqrt(((a + b + c) * (a + b + c) - 2 * (a * a + b * b + c * c)) / 16.); // area of tesselated triangle
    639627      x = Plane(*(runner->second->endpoints[0]->node->node),
    640628                *(runner->second->endpoints[1]->node->node),
    641629                *(runner->second->endpoints[2]->node->node)).getNormal();
    642       x.Scale(runner->second->endpoints[1]->node->node->ScalarProduct(&x));
     630      x.Scale(runner->second->endpoints[1]->node->node->ScalarProduct(x));
    643631      const double h = x.Norm(); // distance of CoG to triangle
    644632      const double PyramidVolume = (1. / 3.) * G * h; // this formula holds for _all_ pyramids (independent of n-edge base or (not) centered peak)
     
    917905            if (DoRandomRotation)
    918906              CopyAtoms[Walker->nr]->x.MatrixMultiplication(Rotations);
    919             CopyAtoms[Walker->nr]->x.AddVector(&AtomTranslations);
    920             CopyAtoms[Walker->nr]->x.AddVector(&FillerTranslations);
    921             CopyAtoms[Walker->nr]->x.AddVector(&CurrentPosition);
     907            CopyAtoms[Walker->nr]->x += AtomTranslations;
     908            CopyAtoms[Walker->nr]->x += FillerTranslations;
     909            CopyAtoms[Walker->nr]->x += CurrentPosition;
    922910
    923911            // insert into Filling
  • src/builder.cpp

    r72e7fa r273382  
    18171817                    first = second;
    18181818                    second = first->next;
    1819                     if (first->x.DistanceSquared((const Vector *)&third->x) > tmp1*tmp1) // distance to first above radius ...
     1819                    if (first->x.DistanceSquared(third->x) > tmp1*tmp1) // distance to first above radius ...
    18201820                      mol->RemoveAtom(first);
    18211821                  }
     
    20962096                    y[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    20972097                    for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    2098                       x.AddVector(&y); // per factor one cell width further
     2098                      x += y; // per factor one cell width further
    20992099                      for (int k=count;k--;) { // go through every atom of the original cell
    21002100                        first = World::getInstance().createAtom(); // create a new body
    2101                         first->x.CopyVector(vectors[k]);  // use coordinate of original atom
    2102                         first->x.AddVector(&x);      // translate the coordinates
     2101                        first->x = (*vectors[k]) + x;
    21032102                        first->type = Elements[k];  // insert original element
    21042103                        mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     
    21102109                    // correct cell size
    21112110                    if (axis < 0) { // if sign was negative, we have to translate everything
    2112                       x.Zero();
    2113                       x.AddVector(&y);
    2114                       x.Scale(-(faktor-1));
     2111                      x =(-(faktor-1)) * y;
    21152112                      mol->Translate(&x);
    21162113                    }
  • src/ellipsoid.cpp

    r72e7fa r273382  
    4242
    4343  // 1. translate coordinate system so that ellipsoid center is in origin
    44   helper.CopyVector(&x);
    45   helper.SubtractVector(&EllipsoidCenter);
    46   RefPoint.CopyVector(&helper);
     44  RefPoint = helper = x - EllipsoidCenter;
    4745  //Log() << Verbose(4) << "Translated given point is at " << RefPoint << "." << endl;
    4846
     
    8684
    8785  // 5. determine distance between backtransformed point and x
    88   distance = RefPoint.DistanceSquared(&helper);
     86  distance = RefPoint.DistanceSquared(helper);
    8987  //Log() << Verbose(4) << "Squared distance between intersection and RefPoint is " << distance << "." << endl;
    9088
     
    304302                Candidate = (*Runner);
    305303                Log() << Verbose(2) << "Current picked node is " << **Runner << " with index " << index << "." << endl;
    306                 x[PointsPicked++].CopyVector(Candidate->node);    // we have one more atom picked
     304                x[PointsPicked++] = (*Candidate->node);    // we have one more atom picked
    307305                current++;    // next pre-picked atom
    308306              }
     
    350348      //Log() << Verbose(3) << "Current node is " << *Runner->second->node << " with " << value << " ... " << threshold << ": ";
    351349      if (value > threshold) {
    352         x[PointsPicked].CopyVector(Runner->second->node->node);
     350        x[PointsPicked] = (*Runner->second->node->node);
    353351        PointsPicked++;
    354352        //Log() << Verbose(0) << "IN." << endl;
     
    387385  Center.Zero();
    388386  for (PointMap::iterator Runner = T->PointsOnBoundary.begin(); Runner != T->PointsOnBoundary.end(); Runner++)
    389     Center.AddVector(Runner->second->node->node);
     387    Center += (*Runner->second->node->node);
    390388  Center.Scale(1./T->PointsOnBoundaryCount);
    391389  Log() << Verbose(1) << "Center is at " << Center << "." << endl;
     
    405403    // calculate some sensible starting values for parameter fit
    406404    MaxDistance = 0.;
    407     MinDistance = x[0].ScalarProduct(&x[0]);
     405    MinDistance = x[0].ScalarProduct(x[0]);
    408406    for (int i=0;i<N;i++) {
    409       distance = x[i].ScalarProduct(&x[i]);
     407      distance = x[i].ScalarProduct(x[i]);
    410408      if (distance > MaxDistance)
    411409        MaxDistance = distance;
     
    414412    }
    415413    //Log() << Verbose(2) << "MinDistance " << MinDistance << ", MaxDistance " << MaxDistance << "." << endl;
    416     EllipsoidCenter.CopyVector(&Center);  // use Center of Gravity as initial center of ellipsoid
     414    EllipsoidCenter = Center;  // use Center of Gravity as initial center of ellipsoid
    417415    for (int i=0;i<3;i++)
    418416      EllipsoidAngle[i] = 0.;
  • src/molecule.cpp

    r72e7fa r273382  
    220220//  Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
    221221  // create vector in direction of bond
    222   InBondvector.CopyVector(&TopReplacement->x);
    223   InBondvector.SubtractVector(&TopOrigin->x);
     222  InBondvector = TopReplacement->x - TopOrigin->x;
    224223  bondlength = InBondvector.Norm();
    225224
     
    240239    matrix = ReturnFullMatrixforSymmetric(cell_size);
    241240    Orthovector1.MatrixMultiplication(matrix);
    242     InBondvector.SubtractVector(&Orthovector1); // subtract just the additional translation
     241    InBondvector.SubtractVector(Orthovector1); // subtract just the additional translation
    243242    Free(&matrix);
    244243    bondlength = InBondvector.Norm();
     
    265264      FirstOtherAtom = World::getInstance().createAtom();    // new atom
    266265      FirstOtherAtom->type = elemente->FindElement(1);  // element is Hydrogen
    267       FirstOtherAtom->v.CopyVector(&TopReplacement->v); // copy velocity
     266      FirstOtherAtom->v = TopReplacement->v; // copy velocity
    268267      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    269268      if (TopReplacement->type->Z == 1) { // neither rescale nor replace if it's already hydrogen
     
    274273      }
    275274      InBondvector.Scale(&BondRescale);   // rescale the distance vector to Hydrogen bond length
    276       FirstOtherAtom->x.CopyVector(&TopOrigin->x); // set coordination to origin ...
    277       FirstOtherAtom->x.AddVector(&InBondvector);  // ... and add distance vector to replacement atom
     275      FirstOtherAtom->x = TopOrigin->x; // set coordination to origin ...
     276      FirstOtherAtom->x = InBondvector;  // ... and add distance vector to replacement atom
    278277      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
    279278//      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
     
    316315        }
    317316      } else {
    318         Orthovector1.GetOneNormalVector(&InBondvector);
     317        Orthovector1.GetOneNormalVector(InBondvector);
    319318      }
    320319      //Log() << Verbose(3)<< "Orthovector1: ";
     
    331330      FirstOtherAtom->type = elemente->FindElement(1);
    332331      SecondOtherAtom->type = elemente->FindElement(1);
    333       FirstOtherAtom->v.CopyVector(&TopReplacement->v); // copy velocity
     332      FirstOtherAtom->v = TopReplacement->v; // copy velocity
    334333      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    335       SecondOtherAtom->v.CopyVector(&TopReplacement->v); // copy velocity
     334      SecondOtherAtom->v = TopReplacement->v; // copy velocity
    336335      SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
    337336      FirstOtherAtom->father = NULL;  // we are just an added hydrogen with no father
     
    388387      SecondOtherAtom->type = elemente->FindElement(1);
    389388      ThirdOtherAtom->type = elemente->FindElement(1);
    390       FirstOtherAtom->v.CopyVector(&TopReplacement->v); // copy velocity
     389      FirstOtherAtom->v = TopReplacement->v; // copy velocity
    391390      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    392       SecondOtherAtom->v.CopyVector(&TopReplacement->v); // copy velocity
     391      SecondOtherAtom->v = TopReplacement->v; // copy velocity
    393392      SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
    394       ThirdOtherAtom->v.CopyVector(&TopReplacement->v); // copy velocity
     393      ThirdOtherAtom->v = TopReplacement->v; // copy velocity
    395394      ThirdOtherAtom->FixedIon = TopReplacement->FixedIon;
    396395      FirstOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
     
    399398
    400399      // we need to vectors orthonormal the InBondvector
    401       AllWentWell = AllWentWell && Orthovector1.GetOneNormalVector(&InBondvector);
     400      AllWentWell = AllWentWell && Orthovector1.GetOneNormalVector(InBondvector);
    402401//      Log() << Verbose(3) << "Orthovector1: ";
    403402//      Orthovector1.Output(out);
     
    426425      factors[1] = f;
    427426      factors[2] = 0.;
    428       FirstOtherAtom->x.LinearCombinationOfVectors(&InBondvector, &Orthovector1, &Orthovector2, factors);
     427      FirstOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    429428      factors[1] = -0.5*f;
    430429      factors[2] = g;
    431       SecondOtherAtom->x.LinearCombinationOfVectors(&InBondvector, &Orthovector1, &Orthovector2, factors);
     430      SecondOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    432431      factors[2] = -g;
    433       ThirdOtherAtom->x.LinearCombinationOfVectors(&InBondvector, &Orthovector1, &Orthovector2, factors);
     432      ThirdOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    434433
    435434      // rescale each to correct BondDistance
     
    439438
    440439      // and relative to *origin atom
    441       FirstOtherAtom->x.AddVector(&TopOrigin->x);
    442       SecondOtherAtom->x.AddVector(&TopOrigin->x);
    443       ThirdOtherAtom->x.AddVector(&TopOrigin->x);
     440      FirstOtherAtom->x += TopOrigin->x;
     441      SecondOtherAtom->x += TopOrigin->x;
     442      ThirdOtherAtom->x += TopOrigin->x;
    444443
    445444      // ... and add to molecule
     
    10221021    Log() << Verbose(5) << "Center of Gravity: " << CenterOfGravity << endl;
    10231022    Log() << Verbose(5) << "Other Center of Gravity: " << OtherCenterOfGravity << endl;
    1024     if (CenterOfGravity.DistanceSquared(&OtherCenterOfGravity) > threshold*threshold) {
     1023    if (CenterOfGravity.DistanceSquared(OtherCenterOfGravity) > threshold*threshold) {
    10251024      Log() << Verbose(4) << "Centers of gravity don't match." << endl;
    10261025      result = false;
  • src/molecule.hpp

    r72e7fa r273382  
    145145  template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T), T t ) const;
    146146  template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T) const, T t ) const;
     147  template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T&), T &t ) const;
     148  template <typename res, typename T> void ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const;
    147149  template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const;
    148150  template <typename res, typename T, typename U> void ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const;
  • src/molecule_dynamics.cpp

    r72e7fa r273382  
    3939    // determine normalized trajectories direction vector (n1, n2)
    4040    Sprinter = Params.PermutationMap[Walker->nr];   // find first target point
    41     trajectory1.CopyVector(&Sprinter->Trajectory.R.at(Params.endstep));
    42     trajectory1.SubtractVector(&Walker->Trajectory.R.at(Params.startstep));
     41    trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep);
    4342    trajectory1.Normalize();
    4443    Norm1 = trajectory1.Norm();
    4544    Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
    46     trajectory2.CopyVector(&Sprinter->Trajectory.R.at(Params.endstep));
    47     trajectory2.SubtractVector(&Runner->Trajectory.R.at(Params.startstep));
     45    trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);
    4846    trajectory2.Normalize();
    4947    Norm2 = trajectory1.Norm();
    5048    // check whether either is zero()
    5149    if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) {
    52       tmp = Walker->Trajectory.R.at(Params.startstep).Distance(&Runner->Trajectory.R.at(Params.startstep));
     50      tmp = Walker->Trajectory.R.at(Params.startstep).Distance(Runner->Trajectory.R.at(Params.startstep));
    5351    } else if (Norm1 < MYEPSILON) {
    5452      Sprinter = Params.PermutationMap[Walker->nr];   // find first target point
    55       trajectory1.CopyVector(&Sprinter->Trajectory.R.at(Params.endstep));  // copy first offset
    56       trajectory1.SubtractVector(&Runner->Trajectory.R.at(Params.startstep));  // subtract second offset
    57       trajectory2.Scale( trajectory1.ScalarProduct(&trajectory2) ); // trajectory2 is scaled to unity, hence we don't need to divide by anything
    58       trajectory1.SubtractVector(&trajectory2);   // project the part in norm direction away
     53      trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);
     54      trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything
     55      trajectory1 -= trajectory2;   // project the part in norm direction away
    5956      tmp = trajectory1.Norm();  // remaining norm is distance
    6057    } else if (Norm2 < MYEPSILON) {
    6158      Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
    62       trajectory2.CopyVector(&Sprinter->Trajectory.R.at(Params.endstep));  // copy second offset
    63       trajectory2.SubtractVector(&Walker->Trajectory.R.at(Params.startstep));  // subtract first offset
    64       trajectory1.Scale( trajectory2.ScalarProduct(&trajectory1) ); // trajectory1 is scaled to unity, hence we don't need to divide by anything
    65       trajectory2.SubtractVector(&trajectory1);   // project the part in norm direction away
     59      trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep);  // copy second offset
     60      trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything
     61      trajectory2 -= trajectory1;   // project the part in norm direction away
    6662      tmp = trajectory2.Norm();  // remaining norm is distance
    67     } else if ((fabs(trajectory1.ScalarProduct(&trajectory2)/Norm1/Norm2) - 1.) < MYEPSILON) { // check whether they're linear dependent
     63    } else if ((fabs(trajectory1.ScalarProduct(trajectory2)/Norm1/Norm2) - 1.) < MYEPSILON) { // check whether they're linear dependent
    6864  //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear dependent: ";
    6965  //        Log() << Verbose(0) << trajectory1;
    7066  //        Log() << Verbose(0) << " and ";
    7167  //        Log() << Verbose(0) << trajectory2;
    72       tmp = Walker->Trajectory.R.at(Params.startstep).Distance(&Runner->Trajectory.R.at(Params.startstep));
     68      tmp = Walker->Trajectory.R.at(Params.startstep).Distance(Runner->Trajectory.R.at(Params.startstep));
    7369  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
    7470    } else { // determine distance by finding minimum distance
     
    9793  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
    9894      // test whether we really have the intersection (by checking on c_1 and c_2)
    99       TestVector.CopyVector(&Runner->Trajectory.R.at(Params.startstep));
     95      trajectory1.Scale(gsl_vector_get(x,0));
    10096      trajectory2.Scale(gsl_vector_get(x,1));
    101       TestVector.AddVector(&trajectory2);
    10297      normal.Scale(gsl_vector_get(x,2));
    103       TestVector.AddVector(&normal);
    104       TestVector.SubtractVector(&Walker->Trajectory.R.at(Params.startstep));
    105       trajectory1.Scale(gsl_vector_get(x,0));
    106       TestVector.SubtractVector(&trajectory1);
     98      TestVector = Runner->Trajectory.R.at(Params.startstep) + trajectory2 + normal
     99                   - (Walker->Trajectory.R.at(Params.startstep) + trajectory1);
    107100      if (TestVector.Norm() < MYEPSILON) {
    108101  //          Log() << Verbose(2) << "Test: ok.\tDistance of " << tmp << " is correct." << endl;
     
    173166    // first term: distance to target
    174167    Runner = Params.PermutationMap[Walker->nr];   // find target point
    175     tmp = (Walker->Trajectory.R.at(Params.startstep).Distance(&Runner->Trajectory.R.at(Params.endstep)));
     168    tmp = (Walker->Trajectory.R.at(Params.startstep).Distance(Runner->Trajectory.R.at(Params.endstep)));
    176169    tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
    177170    result += Params.PenaltyConstants[0] * tmp;
     
    232225    while(Runner->next != mol->end) {
    233226      Runner = Runner->next;
    234       Params.DistanceList[Walker->nr]->insert( DistancePair(Walker->Trajectory.R.at(Params.startstep).Distance(&Runner->Trajectory.R.at(Params.endstep)), Runner) );
     227      Params.DistanceList[Walker->nr]->insert( DistancePair(Walker->Trajectory.R.at(Params.startstep).Distance(Runner->Trajectory.R.at(Params.endstep)), Runner) );
    235228    }
    236229  }
  • src/molecule_fragmentation.cpp

    r72e7fa r273382  
    17051705        //Log() << Verbose (3) << "Current Walker is: " << *Walker << "." << endl;
    17061706        ColorList[Walker->nr] = black;    // mark as explored
    1707         Walker->x.AddVector(&Translationvector); // translate
     1707        Walker->x += Translationvector; // translate
    17081708        for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    17091709          if ((*Runner) != Binder) {
  • src/molecule_geometry.cpp

    r72e7fa r273382  
    3030
    3131  // go through all atoms
    32   ActOnAllVectors( &Vector::SubtractVector, Center);
     32  ActOnAllVectors( &Vector::SubtractVector, *Center);
    3333  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    3434
     
    8686//    Log() << Verbose(0) << endl;
    8787    min->Scale(-1.);
    88     max->AddVector(min);
     88    (*max) += (*min);
    8989    Translate(min);
    9090    Center.Zero();
     
    109109      ptr = ptr->next;
    110110      Num++;
    111       Center.AddVector(&ptr->x);
     111      Center += ptr->x;
    112112    }
    113113    Center.Scale(-1./Num); // divide through total number (and sign for direction)
     
    133133      ptr = ptr->next;
    134134      Num += 1.;
    135       tmp.CopyVector(&ptr->x);
    136       a->AddVector(&tmp);
     135      tmp = ptr->x;
     136      (*a) += tmp;
    137137    }
    138138    a->Scale(1./Num); // divide through total mass (and sign for direction)
     
    158158      ptr = ptr->next;
    159159      Num += ptr->type->mass;
    160       tmp.CopyVector(&ptr->x);
    161       tmp.Scale(ptr->type->mass);  // scale by mass
    162       a->AddVector(&tmp);
     160      tmp = ptr->type->mass * ptr->x;
     161      (*a) += tmp;
    163162    }
    164163    a->Scale(-1./Num); // divide through total mass (and sign for direction)
     
    186185void molecule::CenterAtVector(Vector *newcenter)
    187186{
    188   Center.CopyVector(newcenter);
     187  Center = *newcenter;
    189188};
    190189
     
    215214    ptr = ptr->next;
    216215    for (int j=0;j<MDSteps;j++)
    217       ptr->Trajectory.R.at(j).Translate(trans);
    218     ptr->x.Translate(trans);
     216      ptr->Trajectory.R.at(j).Translate(*trans);
     217    ptr->x.Translate(*trans);
    219218  }
    220219};
     
    230229
    231230  // go through all atoms
    232   ActOnAllVectors( &Vector::SubtractVector, trans);
     231  ActOnAllVectors( &Vector::SubtractVector, *trans);
    233232  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    234233
     
    243242void molecule::Mirror(const Vector *n)
    244243{
    245   ActOnAllVectors( &Vector::Mirror, n );
     244  ActOnAllVectors( &Vector::Mirror, *n );
    246245};
    247246
     
    266265      if (Walker->type->Z != 1) {
    267266#endif
    268         Testvector.CopyVector(&Walker->x);
     267        Testvector = Walker->x;
    269268        Testvector.MatrixMultiplication(inversematrix);
    270269        Translationvector.Zero();
     
    283282            }
    284283        }
    285         Testvector.AddVector(&Translationvector);
     284        Testvector += Translationvector;
    286285        Testvector.MatrixMultiplication(matrix);
    287         Center.AddVector(&Testvector);
     286        Center += Testvector;
    288287        Log() << Verbose(1) << "vector is: " << Testvector << endl;
    289288#ifdef ADDHYDROGEN
     
    291290        for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    292291          if ((*Runner)->GetOtherAtom(Walker)->type->Z == 1) {
    293             Testvector.CopyVector(&(*Runner)->GetOtherAtom(Walker)->x);
     292            Testvector = (*Runner)->GetOtherAtom(Walker)->x;
    294293            Testvector.MatrixMultiplication(inversematrix);
    295             Testvector.AddVector(&Translationvector);
     294            Testvector += Translationvector;
    296295            Testvector.MatrixMultiplication(matrix);
    297             Center.AddVector(&Testvector);
     296            Center += Testvector;
    298297            Log() << Verbose(1) << "Hydrogen vector is: " << Testvector << endl;
    299298          }
     
    329328  while (ptr->next != end) {
    330329    ptr = ptr->next;
    331     Vector x;
    332     x.CopyVector(&ptr->x);
     330    Vector x = ptr->x;
    333331    //x.SubtractVector(CenterOfGravity);
    334332    InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
     
    381379    while (ptr->next != end) {
    382380      ptr = ptr->next;
    383       Vector x;
    384       x.CopyVector(&ptr->x);
     381      Vector x = ptr->x;
    385382      //x.SubtractVector(CenterOfGravity);
    386383      InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
     
    492489    ptr = ptr->next;
    493490    if (ptr->type == ((struct lsq_params *)params)->type) { // for specific type
    494       c.CopyVector(&ptr->x);  // copy vector to temporary one
    495       c.SubtractVector(&a);   // subtract offset vector
    496       t = c.ScalarProduct(&b);           // get direction parameter
    497       d.CopyVector(&b);       // and create vector
    498       d.Scale(&t);
    499       c.SubtractVector(&d);   // ... yielding distance vector
    500       res += d.ScalarProduct((const Vector *)&d);        // add squared distance
     491      c = ptr->x - a;
     492      t = c.ScalarProduct(b);           // get direction parameter
     493      d = t*b;       // and create vector
     494      c -= d;   // ... yielding distance vector
     495      res += d.ScalarProduct(d);        // add squared distance
    501496    }
    502497  }
  • src/molecule_graph.cpp

    r72e7fa r273382  
    165165                          //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
    166166                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
    167                           const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size);
     167                          const double distance = OtherWalker->x.PeriodicDistanceSquared((Walker->x), cell_size);
    168168                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    169169                          if ((OtherWalker->father->nr > Walker->father->nr) && (status)) { // create bond if distance is smaller
  • src/molecule_template.hpp

    r72e7fa r273382  
    5555  }
    5656};
     57template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const
     58{
     59  atom *Walker = start;
     60  while (Walker->next != end) {
     61    Walker = Walker->next;
     62    ((Walker->node)->*f)(t);
     63  }
     64};
     65template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const
     66{
     67  atom *Walker = start;
     68  while (Walker->next != end) {
     69    Walker = Walker->next;
     70    ((Walker->node)->*f)(t);
     71  }
     72};
    5773// two arguments
    5874template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
  • src/moleculelist.cpp

    r72e7fa r273382  
    161161        Walker = Walker->next;
    162162        counts[Walker->type->getNumber()]++;
    163         if (Walker->x.DistanceSquared(&Origin) > size)
    164           size = Walker->x.DistanceSquared(&Origin);
     163        if (Walker->x.DistanceSquared(Origin) > size)
     164          size = Walker->x.DistanceSquared(Origin);
    165165      }
    166166      // output Index, Name, number of atoms, chemical formula
     
    501501          if ((Runner->type->Z == 1) && (Runner->nr > Walker->nr) && (Binder->GetOtherAtom(Runner) != Binder->GetOtherAtom(Walker))) { // (hydrogens have only one bonding partner!)
    502502            // 4. evaluate the morse potential for each matrix component and add up
    503             distance = Runner->x.Distance(&Walker->x);
     503            distance = Runner->x.Distance(Walker->x);
    504504            //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *Runner << "<= " << distance << "=>" << *Walker << ":" << endl;
    505505            for (int k = 0; k < a; k++) {
  • src/tesselation.cpp

    r72e7fa r273382  
    234234  // have a normal vector on the base line pointing outwards
    235235  //Log() << Verbose(0) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl;
    236   BaseLineCenter.CopyVector(endpoints[0]->node->node);
    237   BaseLineCenter.AddVector(endpoints[1]->node->node);
    238   BaseLineCenter.Scale(1./2.);
    239   BaseLine.CopyVector(endpoints[0]->node->node);
    240   BaseLine.SubtractVector(endpoints[1]->node->node);
     236  BaseLineCenter = (1./2.)*((*endpoints[0]->node->node) + (*endpoints[1]->node->node));
     237  BaseLine = (*endpoints[0]->node->node) - (*endpoints[1]->node->node);
    241238  //Log() << Verbose(0) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl;
    242239
     
    248245  for(TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) {
    249246    //Log() << Verbose(0) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;
    250     NormalCheck.AddVector(&runner->second->NormalVector);
    251     NormalCheck.Scale(sign);
     247    NormalCheck += runner->second->NormalVector;
     248    NormalCheck *= sign;
    252249    sign = -sign;
    253250    if (runner->second->NormalVector.NormSquared() > MYEPSILON)
    254       BaseLineNormal.CopyVector(&runner->second->NormalVector);   // yes, copy second on top of first
     251      BaseLineNormal = runner->second->NormalVector;   // yes, copy second on top of first
    255252    else {
    256253      eLog() << Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl;
     
    259256    if (node != NULL) {
    260257      //Log() << Verbose(0) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;
    261       helper[i].CopyVector(node->node->node);
    262       helper[i].SubtractVector(&BaseLineCenter);
     258      helper[i] = (*node->node->node) - BaseLineCenter;
    263259      helper[i].MakeNormalTo(BaseLine);  // we want to compare the triangle's heights' angles!
    264260      //Log() << Verbose(0) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;
     
    410406
    411407  // make it always point inward (any offset vector onto plane projected onto normal vector suffices)
    412   if (NormalVector.ScalarProduct(&OtherVector) > 0.)
     408  if (NormalVector.ScalarProduct(OtherVector) > 0.)
    413409    NormalVector.Scale(-1.);
    414410  Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl;
     
    446442  Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl;
    447443
    448   if (Intersection->DistanceSquared(endpoints[0]->node->node) < MYEPSILON) {
     444  if (Intersection->DistanceSquared(*endpoints[0]->node->node) < MYEPSILON) {
    449445    Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl;
    450446    return true;
    451   }   else if (Intersection->DistanceSquared(endpoints[1]->node->node) < MYEPSILON) {
     447  }   else if (Intersection->DistanceSquared(*endpoints[1]->node->node) < MYEPSILON) {
    452448    Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl;
    453449    return true;
    454   }   else if (Intersection->DistanceSquared(endpoints[2]->node->node) < MYEPSILON) {
     450  }   else if (Intersection->DistanceSquared(*endpoints[2]->node->node) < MYEPSILON) {
    455451    Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl;
    456452    return true;
     
    464460                                                    *(endpoints[(i+2)%3]->node->node),
    465461                                                    *Intersection);
    466       helper.CopyVector(endpoints[(i+1)%3]->node->node);
    467       helper.SubtractVector(endpoints[i%3]->node->node);
    468       CrossPoint.SubtractVector(endpoints[i%3]->node->node);  // cross point was returned as absolute vector
    469       const double s = CrossPoint.ScalarProduct(&helper)/helper.NormSquared();
     462      helper = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node);
     463      CrossPoint -= (*endpoints[i%3]->node->node);  // cross point was returned as absolute vector
     464      const double s = CrossPoint.ScalarProduct(helper)/helper.NormSquared();
    470465      Log() << Verbose(1) << "INFO: Factor s is " << s << "." << endl;
    471466      if ((s < -MYEPSILON) || ((s-1.) > MYEPSILON)) {
     
    510505  }
    511506  catch (LinearDependenceException &excp) {
    512     ClosestPoint->CopyVector(x);
     507    (*ClosestPoint) = (*x);
    513508  }
    514509
    515510  // 2. Calculate in plane part of line (x, intersection)
    516   Vector InPlane;
    517   InPlane.CopyVector(x);
    518   InPlane.SubtractVector(ClosestPoint);  // points from plane intersection to straight-down point
    519   InPlane.ProjectOntoPlane(&NormalVector);
    520   InPlane.AddVector(ClosestPoint);
     511  Vector InPlane = (*x) - (*ClosestPoint); // points from plane intersection to straight-down point
     512  InPlane.ProjectOntoPlane(NormalVector);
     513  InPlane += *ClosestPoint;
    521514
    522515  Log() << Verbose(2) << "INFO: Triangle is " << *this << "." << endl;
     
    532525  for (int i=0;i<3;i++) {
    533526    // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point
    534     Direction.CopyVector(endpoints[(i+1)%3]->node->node);
    535     Direction.SubtractVector(endpoints[i%3]->node->node);
     527    Direction = (*endpoints[(i+1)%3]->node->node) - (*endpoints[i%3]->node->node);
    536528    // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal);
    537529
    538530    CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(*(endpoints[i%3]->node->node), *(endpoints[(i+1)%3]->node->node));
    539531
    540     CrossDirection[i].CopyVector(&CrossPoint[i]);
    541     CrossDirection[i].SubtractVector(&InPlane);
    542     CrossPoint[i].SubtractVector(endpoints[i%3]->node->node);  // cross point was returned as absolute vector
    543     const double s = CrossPoint[i].ScalarProduct(&Direction)/Direction.NormSquared();
     532    CrossDirection[i] = CrossPoint[i] - InPlane;
     533    CrossPoint[i] -= (*endpoints[i%3]->node->node);  // cross point was returned as absolute vector
     534    const double s = CrossPoint[i].ScalarProduct(Direction)/Direction.NormSquared();
    544535    Log() << Verbose(2) << "INFO: Factor s is " << s << "." << endl;
    545536    if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) {
    546       CrossPoint[i].AddVector(endpoints[i%3]->node->node);  // make cross point absolute again
     537      CrossPoint[i] += (*endpoints[i%3]->node->node);  // make cross point absolute again
    547538      Log() << Verbose(2) << "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << *endpoints[i%3]->node->node << " and " << *endpoints[(i+1)%3]->node->node << "." << endl;
    548       const double distance = CrossPoint[i].DistanceSquared(x);
     539      const double distance = CrossPoint[i].DistanceSquared(*x);
    549540      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
    550541        ShortestDistance = distance;
    551         ClosestPoint->CopyVector(&CrossPoint[i]);
     542        (*ClosestPoint) = CrossPoint[i];
    552543      }
    553544    } else
     
    556547  InsideFlag = true;
    557548  for (int i=0;i<3;i++) {
    558     const double sign = CrossDirection[i].ScalarProduct(&CrossDirection[(i+1)%3]);
    559     const double othersign = CrossDirection[i].ScalarProduct(&CrossDirection[(i+2)%3]);;
     549    const double sign = CrossDirection[i].ScalarProduct(CrossDirection[(i+1)%3]);
     550    const double othersign = CrossDirection[i].ScalarProduct(CrossDirection[(i+2)%3]);;
    560551    if ((sign > -MYEPSILON) && (othersign > -MYEPSILON))  // have different sign
    561552      InsideFlag = false;
    562553  }
    563554  if (InsideFlag) {
    564     ClosestPoint->CopyVector(&InPlane);
    565     ShortestDistance = InPlane.DistanceSquared(x);
     555    (*ClosestPoint) = InPlane;
     556    ShortestDistance = InPlane.DistanceSquared(*x);
    566557  } else {  // also check endnodes
    567558    for (int i=0;i<3;i++) {
    568       const double distance = x->DistanceSquared(endpoints[i]->node->node);
     559      const double distance = x->DistanceSquared(*endpoints[i]->node->node);
    569560      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
    570561        ShortestDistance = distance;
    571         ClosestPoint->CopyVector(endpoints[i]->node->node);
     562        (*ClosestPoint) = (*endpoints[i]->node->node);
    572563      }
    573564    }
     
    687678  center->Zero();
    688679  for(int i=0;i<3;i++)
    689     center->AddVector(endpoints[i]->node->node);
     680    (*center) += (*endpoints[i]->node->node);
    690681  center->Scale(1./3.);
    691682  Log() << Verbose(1) << "INFO: Center is at " << *center << "." << endl;
     
    755746    for (int i=0;i<3;i++) // increase each of them
    756747      Runner[i]++;
    757     TotalNormal->AddVector(&TemporaryNormal);
     748    (*TotalNormal) += TemporaryNormal;
    758749  }
    759750  TotalNormal->Scale(1./(double)counter);
    760751
    761752  // make it always point inward (any offset vector onto plane projected onto normal vector suffices)
    762   if (TotalNormal->ScalarProduct(&OtherVector) > 0.)
     753  if (TotalNormal->ScalarProduct(OtherVector) > 0.)
    763754    TotalNormal->Scale(-1.);
    764755  Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl;
     
    777768  int counter = 0;
    778769  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
    779     center->AddVector((*Runner)->node->node);
     770    (*center) += (*(*Runner)->node->node);
    780771    counter++;
    781772  }
     
    10281019{
    10291020        Info FunctionInfo(__func__);
    1030   OptCenter.CopyVector(&OptCandidateCenter);
    1031   OtherOptCenter.CopyVector(&OtherOptCandidateCenter);
     1021  OptCenter = OptCandidateCenter;
     1022  OtherOptCenter = OtherOptCandidateCenter;
    10321023};
    10331024
     
    11051096  int num=0;
    11061097  for (GoToFirst(); (!IsEnd()); GoToNext()) {
    1107     Center->AddVector(GetPoint()->node);
     1098    (*Center) += (*GetPoint()->node);
    11081099    num++;
    11091100  }
     
    12171208          for (; C != PointsOnBoundary.end(); C++)
    12181209            {
    1219               tmp = A->second->node->node->DistanceSquared(B->second->node->node);
     1210              tmp = A->second->node->node->DistanceSquared(*B->second->node->node);
    12201211              distance = tmp * tmp;
    1221               tmp = A->second->node->node->DistanceSquared(C->second->node->node);
     1212              tmp = A->second->node->node->DistanceSquared(*C->second->node->node);
    12221213              distance += tmp * tmp;
    1223               tmp = B->second->node->node->DistanceSquared(C->second->node->node);
     1214              tmp = B->second->node->node->DistanceSquared(*C->second->node->node);
    12241215              distance += tmp * tmp;
    12251216              DistanceMMap.insert(DistanceMultiMapPair(distance, pair<PointMap::iterator, PointMap::iterator> (B, C)));
     
    12551246            continue;
    12561247          // 4a. project onto plane vector
    1257           TrialVector.CopyVector(checker->second->node->node);
    1258           TrialVector.SubtractVector(A->second->node->node);
    1259           distance = TrialVector.ScalarProduct(&PlaneVector);
     1248          TrialVector = (*checker->second->node->node) - (*A->second->node->node);
     1249          distance = TrialVector.ScalarProduct(PlaneVector);
    12601250          if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok
    12611251            continue;
     
    12851275            }
    12861276          // 4d. Check whether the point is inside the triangle (check distance to each node
    1287           tmp = checker->second->node->node->DistanceSquared(A->second->node->node);
     1277          tmp = checker->second->node->node->DistanceSquared(*A->second->node->node);
    12881278          int innerpoint = 0;
    12891279          if ((tmp < A->second->node->node->DistanceSquared(
    1290               baseline->second.first->second->node->node)) && (tmp
     1280              *baseline->second.first->second->node->node)) && (tmp
    12911281              < A->second->node->node->DistanceSquared(
    1292                   baseline->second.second->second->node->node)))
     1282                  *baseline->second.second->second->node->node)))
    12931283            innerpoint++;
    12941284          tmp = checker->second->node->node->DistanceSquared(
    1295               baseline->second.first->second->node->node);
     1285              *baseline->second.first->second->node->node);
    12961286          if ((tmp < baseline->second.first->second->node->node->DistanceSquared(
    1297               A->second->node->node)) && (tmp
     1287              *A->second->node->node)) && (tmp
    12981288              < baseline->second.first->second->node->node->DistanceSquared(
    1299                   baseline->second.second->second->node->node)))
     1289                  *baseline->second.second->second->node->node)))
    13001290            innerpoint++;
    13011291          tmp = checker->second->node->node->DistanceSquared(
    1302               baseline->second.second->second->node->node);
     1292              *baseline->second.second->second->node->node);
    13031293          if ((tmp < baseline->second.second->second->node->node->DistanceSquared(
    1304               baseline->second.first->second->node->node)) && (tmp
     1294              *baseline->second.first->second->node->node)) && (tmp
    13051295              < baseline->second.second->second->node->node->DistanceSquared(
    1306                   A->second->node->node)))
     1296                  *A->second->node->node)))
    13071297            innerpoint++;
    13081298          // 4e. If so, break 4. loop and continue with next candidate in 1. loop
     
    13901380        // prepare some auxiliary vectors
    13911381        Vector BaseLineCenter, BaseLine;
    1392         BaseLineCenter.CopyVector(baseline->second->endpoints[0]->node->node);
    1393         BaseLineCenter.AddVector(baseline->second->endpoints[1]->node->node);
    1394         BaseLineCenter.Scale(1. / 2.); // points now to center of base line
    1395         BaseLine.CopyVector(baseline->second->endpoints[0]->node->node);
    1396         BaseLine.SubtractVector(baseline->second->endpoints[1]->node->node);
     1382        BaseLineCenter = 0.5 * ((*baseline->second->endpoints[0]->node->node) +
     1383                                (*baseline->second->endpoints[1]->node->node));
     1384        BaseLine = (*baseline->second->endpoints[0]->node->node) - (*baseline->second->endpoints[1]->node->node);
    13971385
    13981386        // offset to center of triangle
    13991387        CenterVector.Zero();
    14001388        for (int i = 0; i < 3; i++)
    1401           CenterVector.AddVector(BTS->endpoints[i]->node->node);
     1389          CenterVector += (*BTS->endpoints[i]->node->node);
    14021390        CenterVector.Scale(1. / 3.);
    14031391        Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl;
    14041392
    14051393        // normal vector of triangle
    1406         NormalVector.CopyVector(Center);
    1407         NormalVector.SubtractVector(&CenterVector);
     1394        NormalVector = (*Center) - CenterVector;
    14081395        BTS->GetNormalVector(NormalVector);
    1409         NormalVector.CopyVector(&BTS->NormalVector);
     1396        NormalVector = BTS->NormalVector;
    14101397        Log() << Verbose(2) << "NormalVector of base triangle is " << NormalVector << endl;
    14111398
     
    14131400        // project center vector onto triangle plane (points from intersection plane-NormalVector to plane-CenterVector intersection)
    14141401        PropagationVector = Plane(BaseLine, NormalVector,0).getNormal();
    1415         TempVector.CopyVector(&CenterVector);
    1416         TempVector.SubtractVector(baseline->second->endpoints[0]->node->node); // TempVector is vector on triangle plane pointing from one baseline egde towards center!
     1402        TempVector = CenterVector - (*baseline->second->endpoints[0]->node->node); // TempVector is vector on triangle plane pointing from one baseline egde towards center!
    14171403        //Log() << Verbose(0) << "Projection of propagation onto temp: " << PropagationVector.Projection(&TempVector) << "." << endl;
    1418         if (PropagationVector.ScalarProduct(&TempVector) > 0) // make sure normal propagation vector points outward from baseline
     1404        if (PropagationVector.ScalarProduct(TempVector) > 0) // make sure normal propagation vector points outward from baseline
    14191405          PropagationVector.Scale(-1.);
    14201406        Log() << Verbose(2) << "PropagationVector of base triangle is " << PropagationVector << endl;
     
    14271413
    14281414            // first check direction, so that triangles don't intersect
    1429             VirtualNormalVector.CopyVector(target->second->node->node);
    1430             VirtualNormalVector.SubtractVector(&BaseLineCenter); // points from center of base line to target
    1431             VirtualNormalVector.ProjectOntoPlane(&NormalVector);
    1432             TempAngle = VirtualNormalVector.Angle(&PropagationVector);
     1415            VirtualNormalVector = (*target->second->node->node) - BaseLineCenter;
     1416            TempAngle = VirtualNormalVector.Angle(PropagationVector);
    14331417            Log() << Verbose(2) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl;
    14341418            if (TempAngle > (M_PI/2.)) { // no bends bigger than Pi/2 (90 degrees)
     
    14571441
    14581442            // check for linear dependence
    1459             TempVector.CopyVector(baseline->second->endpoints[0]->node->node);
    1460             TempVector.SubtractVector(target->second->node->node);
    1461             helper.CopyVector(baseline->second->endpoints[1]->node->node);
    1462             helper.SubtractVector(target->second->node->node);
    1463             helper.ProjectOntoPlane(&TempVector);
     1443            TempVector = (*baseline->second->endpoints[0]->node->node) - (*target->second->node->node);
     1444            helper = (*baseline->second->endpoints[1]->node->node) - (*target->second->node->node);
     1445            helper.ProjectOntoPlane(TempVector);
    14641446            if (fabs(helper.NormSquared()) < MYEPSILON) {
    14651447              Log() << Verbose(2) << "Chosen set of vectors is linear dependent." << endl;
     
    14721454                                        *(baseline->second->endpoints[1]->node->node),
    14731455                                        *(target->second->node->node)).getNormal();
    1474             TempVector.CopyVector(baseline->second->endpoints[0]->node->node);
    1475             TempVector.AddVector(baseline->second->endpoints[1]->node->node);
    1476             TempVector.AddVector(target->second->node->node);
    1477             TempVector.Scale(1./3.);
    1478             TempVector.SubtractVector(Center);
     1456            TempVector = (1./3.) * ((*baseline->second->endpoints[0]->node->node) +
     1457                                    (*baseline->second->endpoints[1]->node->node) +
     1458                                    (*target->second->node->node));
     1459            TempVector -= (*Center);
    14791460            // make it always point outward
    1480             if (VirtualNormalVector.ScalarProduct(&TempVector) < 0)
     1461            if (VirtualNormalVector.ScalarProduct(TempVector) < 0)
    14811462              VirtualNormalVector.Scale(-1.);
    14821463            // calculate angle
    1483             TempAngle = NormalVector.Angle(&VirtualNormalVector);
     1464            TempAngle = NormalVector.Angle(VirtualNormalVector);
    14841465            Log() << Verbose(2) << "NormalVector is " << VirtualNormalVector << " and the angle is " << TempAngle << "." << endl;
    14851466            if ((SmallestAngle - TempAngle) > MYEPSILON) { // set to new possible winner
     
    14891470            } else if (fabs(SmallestAngle - TempAngle) < MYEPSILON) { // check the angle to propagation, both possible targets are in one plane! (their normals have same angle)
    14901471              // hence, check the angles to some normal direction from our base line but in this common plane of both targets...
    1491               helper.CopyVector(target->second->node->node);
    1492               helper.SubtractVector(&BaseLineCenter);
    1493               helper.ProjectOntoPlane(&BaseLine);
     1472              helper = (*target->second->node->node) - BaseLineCenter;
     1473              helper.ProjectOntoPlane(BaseLine);
    14941474              // ...the one with the smaller angle is the better candidate
    1495               TempVector.CopyVector(target->second->node->node);
    1496               TempVector.SubtractVector(&BaseLineCenter);
    1497               TempVector.ProjectOntoPlane(&VirtualNormalVector);
    1498               TempAngle = TempVector.Angle(&helper);
    1499               TempVector.CopyVector(winner->second->node->node);
    1500               TempVector.SubtractVector(&BaseLineCenter);
    1501               TempVector.ProjectOntoPlane(&VirtualNormalVector);
    1502               if (TempAngle < TempVector.Angle(&helper)) {
    1503                 TempAngle = NormalVector.Angle(&VirtualNormalVector);
     1475              TempVector = (*target->second->node->node) - BaseLineCenter;
     1476              TempVector.ProjectOntoPlane(VirtualNormalVector);
     1477              TempAngle = TempVector.Angle(helper);
     1478              TempVector = (*winner->second->node->node) - BaseLineCenter;
     1479              TempVector.ProjectOntoPlane(VirtualNormalVector);
     1480              if (TempAngle < TempVector.Angle(helper)) {
     1481                TempAngle = NormalVector.Angle(VirtualNormalVector);
    15041482                SmallestAngle = TempAngle;
    15051483                winner = target;
     
    15381516          BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    15391517          BTS->GetCenter(&helper);
    1540           helper.SubtractVector(Center);
    1541           helper.Scale(-1);
     1518          helper -= (*Center);
     1519          helper *= -1;
    15421520          BTS->GetNormalVector(helper);
    15431521          TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
     
    15961574      Log() << Verbose(0) << "We have an intersection at " << Intersection << "." << endl;
    15971575      // we have the intersection, check whether in- or outside of boundary
    1598       if ((Center->DistanceSquared(Walker->node) - Center->DistanceSquared(&Intersection)) < -MYEPSILON) {
     1576      if ((Center->DistanceSquared(*Walker->node) - Center->DistanceSquared(Intersection)) < -MYEPSILON) {
    15991577        // inside, next!
    16001578        Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl;
     
    16091587          OldPoints[i] = BTS->endpoints[i];
    16101588        }
    1611         Normal.CopyVector(&BTS->NormalVector);
     1589        Normal = BTS->NormalVector;
    16121590        // add Walker to boundary points
    16131591        Log() << Verbose(0) << "Adding " << *Walker << " to BoundaryPoints." << endl;
     
    21192097
    21202098    // construct center of circle
    2121     CircleCenter.CopyVector(BaseLine.endpoints[0]->node->node);
    2122     CircleCenter.AddVector(BaseLine.endpoints[1]->node->node);
    2123     CircleCenter.Scale(0.5);
     2099    CircleCenter = 0.5 * ((*BaseLine.endpoints[0]->node->node) + (*BaseLine.endpoints[1]->node->node));
    21242100
    21252101    // construct normal vector of circle
    2126     CirclePlaneNormal.CopyVector(BaseLine.endpoints[0]->node->node);
    2127     CirclePlaneNormal.SubtractVector(BaseLine.endpoints[1]->node->node);
     2102    CirclePlaneNormal = (*BaseLine.endpoints[0]->node->node) - (*BaseLine.endpoints[1]->node->node);
    21282103
    21292104    double radius = CirclePlaneNormal.NormSquared();
    21302105    double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.);
    21312106
    2132     NormalVector.ProjectOntoPlane(&CirclePlaneNormal);
     2107    NormalVector.ProjectOntoPlane(CirclePlaneNormal);
    21332108    NormalVector.Normalize();
    21342109    ShortestAngle = 2.*M_PI; // This will indicate the quadrant.
    21352110
    2136     SphereCenter.CopyVector(&NormalVector);
    2137     SphereCenter.Scale(CircleRadius);
    2138     SphereCenter.AddVector(&CircleCenter);
     2111    SphereCenter = (CircleRadius * NormalVector) +  CircleCenter;
    21392112    // Now, NormalVector and SphereCenter are two orthonormalized vectors in the plane defined by CirclePlaneNormal (not normalized)
    21402113
     
    23372310
    23382311  // construct center of circle
    2339   CircleCenter.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
    2340   CircleCenter.AddVector(CandidateLine.BaseLine->endpoints[1]->node->node);
    2341   CircleCenter.Scale(0.5);
     2312  CircleCenter = 0.5 * ((*CandidateLine.BaseLine->endpoints[0]->node->node) +
     2313                        (*CandidateLine.BaseLine->endpoints[1]->node->node));
    23422314
    23432315  // construct normal vector of circle
    2344   CirclePlaneNormal.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
    2345   CirclePlaneNormal.SubtractVector(CandidateLine.BaseLine->endpoints[1]->node->node);
     2316  CirclePlaneNormal = (*CandidateLine.BaseLine->endpoints[0]->node->node) -
     2317                      (*CandidateLine.BaseLine->endpoints[1]->node->node);
    23462318
    23472319  // calculate squared radius of circle
    2348   radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal);
     2320  radius = CirclePlaneNormal.ScalarProduct(CirclePlaneNormal);
    23492321  if (radius/4. < RADIUS*RADIUS) {
    23502322    // construct relative sphere center with now known CircleCenter
    2351     RelativeSphereCenter.CopyVector(&T.SphereCenter);
    2352     RelativeSphereCenter.SubtractVector(&CircleCenter);
     2323    RelativeSphereCenter = T.SphereCenter - CircleCenter;
    23532324
    23542325    CircleRadius = RADIUS*RADIUS - radius/4.;
     
    23602331    // construct SearchDirection and an "outward pointer"
    23612332    SearchDirection = Plane(RelativeSphereCenter, CirclePlaneNormal,0).getNormal();
    2362     helper.CopyVector(&CircleCenter);
    2363     helper.SubtractVector(ThirdNode->node);
    2364     if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
     2333    helper = CircleCenter - (*ThirdNode->node);
     2334    if (helper.ScalarProduct(SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
    23652335      SearchDirection.Scale(-1.);
    23662336    Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
    2367     if (fabs(RelativeSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {
     2337    if (fabs(RelativeSphereCenter.ScalarProduct(SearchDirection)) > HULLEPSILON) {
    23682338      // rotated the wrong way!
    23692339      eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl;
     
    25122482    AddTesselationTriangle();
    25132483    BTS->GetCenter(&Center);
    2514     Center.SubtractVector(&CandidateLine.OptCenter);
    2515     BTS->SphereCenter.CopyVector(&CandidateLine.OptCenter);
     2484    Center -= CandidateLine.OptCenter;
     2485    BTS->SphereCenter = CandidateLine.OptCenter;
    25162486    BTS->GetNormalVector(Center);
    25172487
     
    25592529  Vector DistanceToIntersection[2], BaseLine;
    25602530  double distance[2];
    2561   BaseLine.CopyVector(Base->endpoints[1]->node->node);
    2562   BaseLine.SubtractVector(Base->endpoints[0]->node->node);
     2531  BaseLine = (*Base->endpoints[1]->node->node) - (*Base->endpoints[0]->node->node);
    25632532  for (int i=0;i<2;i++) {
    2564     DistanceToIntersection[i].CopyVector(ClosestPoint);
    2565     DistanceToIntersection[i].SubtractVector(Base->endpoints[i]->node->node);
    2566     distance[i] = BaseLine.ScalarProduct(&DistanceToIntersection[i]);
     2533    DistanceToIntersection[i] = (*ClosestPoint) - (*Base->endpoints[i]->node->node);
     2534    distance[i] = BaseLine.ScalarProduct(DistanceToIntersection[i]);
    25672535  }
    25682536  delete(ClosestPoint);
     
    26362604
    26372605  // get the distance vector from Base line to OtherBase line
    2638   Vector Distance;
    2639   Distance.CopyVector(ClosestPoint[1]);
    2640   Distance.SubtractVector(ClosestPoint[0]);
     2606  Vector Distance = (*ClosestPoint[1]) - (*ClosestPoint[0]);
    26412607
    26422608  // calculate volume
     
    26602626    for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    26612627      Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;
    2662       BaseLineNormal.AddVector(&(runner->second->NormalVector));
     2628      BaseLineNormal += (runner->second->NormalVector);
    26632629    }
    26642630    BaseLineNormal.Scale(1./2.);
    26652631
    2666     if (Distance.ScalarProduct(&BaseLineNormal) > MYEPSILON) { // Distance points outwards, hence OtherBase higher than Base -> flip
     2632    if (Distance.ScalarProduct(BaseLineNormal) > MYEPSILON) { // Distance points outwards, hence OtherBase higher than Base -> flip
    26672633      Log() << Verbose(0) << "ACCEPT: Other base line would be higher: Flipping baseline." << endl;
    26682634      // calculate volume summand as a general tetraeder
     
    26992665  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    27002666    Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;
    2701     BaseLineNormal.AddVector(&(runner->second->NormalVector));
     2667    BaseLineNormal += (runner->second->NormalVector);
    27022668  }
    27032669  BaseLineNormal.Scale(-1./2.); // has to point inside for BoundaryTriangleSet::GetNormalVector()
     
    28402806              double distance, scaleFactor;
    28412807
    2842               OrthogonalizedOben.CopyVector(&Oben);
    2843               aCandidate.CopyVector(a->node);
    2844               aCandidate.SubtractVector(Candidate->node);
    2845               OrthogonalizedOben.ProjectOntoPlane(&aCandidate);
     2808              OrthogonalizedOben = Oben;
     2809              aCandidate = (*a->node) - (*Candidate->node);
     2810              OrthogonalizedOben.ProjectOntoPlane(aCandidate);
    28462811              OrthogonalizedOben.Normalize();
    28472812              distance = 0.5 * aCandidate.Norm();
     
    28492814              OrthogonalizedOben.Scale(scaleFactor);
    28502815
    2851               Center.CopyVector(Candidate->node);
    2852               Center.AddVector(a->node);
    2853               Center.Scale(0.5);
    2854               Center.AddVector(&OrthogonalizedOben);
    2855 
    2856               AngleCheck.CopyVector(&Center);
    2857               AngleCheck.SubtractVector(a->node);
     2816              Center = 0.5 * ((*Candidate->node) + (*a->node));
     2817              Center += OrthogonalizedOben;
     2818
     2819              AngleCheck = Center - (*a->node);
    28582820              norm = aCandidate.Norm();
    28592821              // second point shall have smallest angle with respect to Oben vector
    28602822              if (norm < RADIUS*2.) {
    2861                 angle = AngleCheck.Angle(&Oben);
     2823                angle = AngleCheck.Angle(Oben);
    28622824                if (angle < Storage[0]) {
    28632825                  //Log() << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
     
    29352897
    29362898  // construct center of circle
    2937   CircleCenter.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
    2938   CircleCenter.AddVector(CandidateLine.BaseLine->endpoints[1]->node->node);
    2939   CircleCenter.Scale(0.5);
     2899  CircleCenter = 0.5 * ((*CandidateLine.BaseLine->endpoints[0]->node->node) +
     2900                        (*CandidateLine.BaseLine->endpoints[1]->node->node));
    29402901
    29412902  // construct normal vector of circle
    2942   CirclePlaneNormal.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
    2943   CirclePlaneNormal.SubtractVector(CandidateLine.BaseLine->endpoints[1]->node->node);
    2944 
    2945   RelativeOldSphereCenter.CopyVector(&OldSphereCenter);
    2946   RelativeOldSphereCenter.SubtractVector(&CircleCenter);
     2903  CirclePlaneNormal = (*CandidateLine.BaseLine->endpoints[0]->node->node) -
     2904                      (*CandidateLine.BaseLine->endpoints[1]->node->node);
     2905
     2906  RelativeOldSphereCenter = OldSphereCenter - CircleCenter;
    29472907
    29482908  // calculate squared radius TesselPoint *ThirdNode,f circle
     
    29542914
    29552915    // test whether old center is on the band's plane
    2956     if (fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {
    2957       eLog() << Verbose(1) << "Something's very wrong here: RelativeOldSphereCenter is not on the band's plane as desired by " << fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl;
    2958       RelativeOldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal);
     2916    if (fabs(RelativeOldSphereCenter.ScalarProduct(CirclePlaneNormal)) > HULLEPSILON) {
     2917      eLog() << Verbose(1) << "Something's very wrong here: RelativeOldSphereCenter is not on the band's plane as desired by " << fabs(RelativeOldSphereCenter.ScalarProduct(CirclePlaneNormal)) << "!" << endl;
     2918      RelativeOldSphereCenter.ProjectOntoPlane(CirclePlaneNormal);
    29592919    }
    29602920    radius = RelativeOldSphereCenter.NormSquared();
     
    29642924      // check SearchDirection
    29652925      Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
    2966       if (fabs(RelativeOldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {  // rotated the wrong way!
     2926      if (fabs(RelativeOldSphereCenter.ScalarProduct(SearchDirection)) > HULLEPSILON) {  // rotated the wrong way!
    29672927        eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl;
    29682928      }
     
    30112971
    30122972                    Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl;
    3013                     radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&NewPlaneCenter);
     2973                    radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(NewPlaneCenter);
    30142974                    Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
    30152975                    Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
    30162976                    Log() << Verbose(1) << "INFO: Radius of CircumCenterCircle is " << radius << "." << endl;
    30172977                    if (radius < RADIUS*RADIUS) {
    3018                       otherradius = CandidateLine.BaseLine->endpoints[1]->node->node->DistanceSquared(&NewPlaneCenter);
     2978                      otherradius = CandidateLine.BaseLine->endpoints[1]->node->node->DistanceSquared(NewPlaneCenter);
    30192979                      if (fabs(radius - otherradius) > HULLEPSILON) {
    30202980                        eLog() << Verbose(1) << "Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius-otherradius) << endl;
    30212981                      }
    30222982                      // construct both new centers
    3023                       NewSphereCenter.CopyVector(&NewPlaneCenter);
    3024                       OtherNewSphereCenter.CopyVector(&NewPlaneCenter);
    3025                       helper.CopyVector(&NewNormalVector);
    3026                       helper.Scale(sqrt(RADIUS*RADIUS - radius));
     2983                      NewSphereCenter = NewPlaneCenter;
     2984                      OtherNewSphereCenter = NewPlaneCenter;
     2985                      helper = sqrt(RADIUS*RADIUS - radius) * NewNormalVector;
    30272986                      Log() << Verbose(2) << "INFO: Distance of NewPlaneCenter " << NewPlaneCenter << " to either NewSphereCenter is " << helper.Norm() << " of vector " << helper << " with sphere radius " << RADIUS << "." << endl;
    3028                       NewSphereCenter.AddVector(&helper);
     2987                      NewSphereCenter += helper;
    30292988                      Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl;
    30302989                      // OtherNewSphereCenter is created by the same vector just in the other direction
    30312990                      helper.Scale(-1.);
    3032                       OtherNewSphereCenter.AddVector(&helper);
     2991                      OtherNewSphereCenter += helper;
    30332992                      Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl;
    30342993
     
    30413000                      if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) {
    30423001                        if (fabs(alpha - Otheralpha) > MYEPSILON) {
    3043                           CandidateLine.OptCenter.CopyVector(&NewSphereCenter);
    3044                           CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter);
     3002                          CandidateLine.OptCenter = NewSphereCenter;
     3003                          CandidateLine.OtherOptCenter = OtherNewSphereCenter;
    30453004                        } else {
    3046                           CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter);
    3047                           CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter);
     3005                          CandidateLine.OptCenter = OtherNewSphereCenter;
     3006                          CandidateLine.OtherOptCenter = NewSphereCenter;
    30483007                        }
    30493008                        // if there is an equal candidate, add it to the list without clearing the list
     
    31683127            FindPoint = PointsOnBoundary.find((*Runner)->nr);
    31693128            if (FindPoint != PointsOnBoundary.end()) {
    3170               points->insert(DistanceToPointPair (FindPoint->second->node->node->DistanceSquared(x), FindPoint->second) );
     3129              points->insert(DistanceToPointPair (FindPoint->second->node->node->DistanceSquared(*x), FindPoint->second) );
    31713130              Log() << Verbose(1) << "INFO: Putting " << *FindPoint->second << " into the list." << endl;
    31723131            }
     
    32123171    for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) {
    32133172      // calculate closest point on line to desired point
    3214       helper.CopyVector((LineRunner->second)->endpoints[0]->node->node);
    3215       helper.AddVector((LineRunner->second)->endpoints[1]->node->node);
    3216       helper.Scale(0.5);
    3217       Center.CopyVector(x);
    3218       Center.SubtractVector(&helper);
    3219       BaseLine.CopyVector((LineRunner->second)->endpoints[0]->node->node);
    3220       BaseLine.SubtractVector((LineRunner->second)->endpoints[1]->node->node);
    3221       Center.ProjectOntoPlane(&BaseLine);
     3173      helper = 0.5 * ((*(LineRunner->second)->endpoints[0]->node->node) +
     3174                      (*(LineRunner->second)->endpoints[1]->node->node));
     3175      Center = (*x) - helper;
     3176      BaseLine = (*(LineRunner->second)->endpoints[0]->node->node) -
     3177                 (*(LineRunner->second)->endpoints[1]->node->node);
     3178      Center.ProjectOntoPlane(BaseLine);
    32223179      const double distance = Center.NormSquared();
    32233180      if ((ClosestLine == NULL) || (distance < MinDistance)) {
    32243181        // additionally calculate intersection on line (whether it's on the line section or not)
    3225         helper.CopyVector(x);
    3226         helper.SubtractVector((LineRunner->second)->endpoints[0]->node->node);
    3227         helper.SubtractVector(&Center);
    3228         const double lengthA = helper.ScalarProduct(&BaseLine);
    3229         helper.CopyVector(x);
    3230         helper.SubtractVector((LineRunner->second)->endpoints[1]->node->node);
    3231         helper.SubtractVector(&Center);
    3232         const double lengthB = helper.ScalarProduct(&BaseLine);
     3182        helper = (*x) - (*(LineRunner->second)->endpoints[0]->node->node) - Center;
     3183        const double lengthA = helper.ScalarProduct(BaseLine);
     3184        helper = (*x) - (*(LineRunner->second)->endpoints[1]->node->node) - Center;
     3185        const double lengthB = helper.ScalarProduct(BaseLine);
    32333186        if (lengthB*lengthA < 0) {  // if have different sign
    32343187          ClosestLine = LineRunner->second;
     
    32803233    for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) {
    32813234
    3282       BaseLine.CopyVector((LineRunner->second)->endpoints[0]->node->node);
    3283       BaseLine.SubtractVector((LineRunner->second)->endpoints[1]->node->node);
     3235      BaseLine = (*(LineRunner->second)->endpoints[0]->node->node) -
     3236                 (*(LineRunner->second)->endpoints[1]->node->node);
    32843237      const double lengthBase = BaseLine.NormSquared();
    32853238
    3286       BaseLineIntersection.CopyVector(x);
    3287       BaseLineIntersection.SubtractVector((LineRunner->second)->endpoints[0]->node->node);
     3239      BaseLineIntersection = (*x) - (*(LineRunner->second)->endpoints[0]->node->node);
    32883240      const double lengthEndA = BaseLineIntersection.NormSquared();
    32893241
    3290       BaseLineIntersection.CopyVector(x);
    3291       BaseLineIntersection.SubtractVector((LineRunner->second)->endpoints[1]->node->node);
     3242      BaseLineIntersection = (*x) - (*(LineRunner->second)->endpoints[1]->node->node);
    32923243      const double lengthEndB = BaseLineIntersection.NormSquared();
    32933244
     
    33073258      } else { // intersection is closer, calculate
    33083259        // calculate closest point on line to desired point
    3309         BaseLineIntersection.CopyVector(x);
    3310         BaseLineIntersection.SubtractVector((LineRunner->second)->endpoints[1]->node->node);
    3311         Center.CopyVector(&BaseLineIntersection);
    3312         Center.ProjectOntoPlane(&BaseLine);
    3313         BaseLineIntersection.SubtractVector(&Center);
     3260        BaseLineIntersection = (*x) - (*(LineRunner->second)->endpoints[1]->node->node);
     3261        Center = BaseLineIntersection;
     3262        Center.ProjectOntoPlane(BaseLine);
     3263        BaseLineIntersection -= Center;
    33143264        const double distance = BaseLineIntersection.NormSquared();
    33153265        if (Center.NormSquared() > BaseLine.NormSquared()) {
     
    33633313  for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) {
    33643314    (*Runner)->GetCenter(&Center);
    3365     helper.CopyVector(x);
    3366     helper.SubtractVector(&Center);
    3367     const double Alignment = helper.Angle(&(*Runner)->NormalVector);
     3315    helper = (*x) - Center;
     3316    const double Alignment = helper.Angle((*Runner)->NormalVector);
    33683317    if (Alignment < MinAlignment) {
    33693318      result = *Runner;
     
    34273376  triangle->GetCenter(&Center);
    34283377  Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl;
    3429   DistanceToCenter.CopyVector(&Center);
    3430   DistanceToCenter.SubtractVector(&Point);
     3378  DistanceToCenter = Center - Point;
    34313379  Log() << Verbose(2) << "INFO: Vector from point to test to center is " << DistanceToCenter << "." << endl;
    34323380
    34333381  // check whether we are on boundary
    3434   if (fabs(DistanceToCenter.ScalarProduct(&triangle->NormalVector)) < MYEPSILON) {
     3382  if (fabs(DistanceToCenter.ScalarProduct(triangle->NormalVector)) < MYEPSILON) {
    34353383    // calculate whether inside of triangle
    3436     DistanceToCenter.CopyVector(&Point);
    3437     Center.CopyVector(&Point);
    3438     Center.SubtractVector(&triangle->NormalVector); // points towards MolCenter
    3439     DistanceToCenter.AddVector(&triangle->NormalVector); // points outside
     3384    DistanceToCenter = Point + triangle->NormalVector; // points outside
     3385    Center = Point - triangle->NormalVector; // points towards MolCenter
    34403386    Log() << Verbose(1) << "INFO: Calling Intersection with " << Center << " and " << DistanceToCenter << "." << endl;
    34413387    if (triangle->GetIntersectionInsideTriangle(&Center, &DistanceToCenter, &Intersection)) {
     
    34523398
    34533399    // then check direction to boundary
    3454     if (DistanceToCenter.ScalarProduct(&triangle->NormalVector) > MYEPSILON) {
     3400    if (DistanceToCenter.ScalarProduct(triangle->NormalVector) > MYEPSILON) {
    34553401      Log() << Verbose(1) << Point << " is an inner point, " << distance << " below surface." << endl;
    34563402      return -distance;
     
    35683514  if ((triangles != NULL) && (!triangles->empty())) {
    35693515    for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++)
    3570       PlaneNormal.AddVector(&(*Runner)->NormalVector);
     3516      PlaneNormal += (*Runner)->NormalVector;
    35713517  } else {
    35723518    eLog() << Verbose(0) << "Could not find any triangles for point " << *Point << "." << endl;
     
    35793525  // construct one orthogonal vector
    35803526  if (Reference != NULL) {
    3581     AngleZero.CopyVector(Reference);
    3582     AngleZero.SubtractVector(Point->node);
    3583     AngleZero.ProjectOntoPlane(&PlaneNormal);
     3527    AngleZero = (*Reference) - (*Point->node);
     3528    AngleZero.ProjectOntoPlane(PlaneNormal);
    35843529  }
    35853530  if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) {
    35863531    Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl;
    3587     AngleZero.CopyVector((*SetOfNeighbours->begin())->node);
    3588     AngleZero.SubtractVector(Point->node);
    3589     AngleZero.ProjectOntoPlane(&PlaneNormal);
     3532    AngleZero = (*(*SetOfNeighbours->begin())->node) - (*Point->node);
     3533    AngleZero.ProjectOntoPlane(PlaneNormal);
    35903534    if (AngleZero.NormSquared() < MYEPSILON) {
    35913535      eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl;
     
    36023546  // go through all connected points and calculate angle
    36033547  for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) {
    3604     helper.CopyVector((*listRunner)->node);
    3605     helper.SubtractVector(Point->node);
    3606     helper.ProjectOntoPlane(&PlaneNormal);
     3548    helper = (*(*listRunner)->node) - (*Point->node);
     3549    helper.ProjectOntoPlane(PlaneNormal);
    36073550    double angle = GetAngle(helper, AngleZero, OrthogonalVector);
    36083551    Log() << Verbose(0) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl;
     
    36713614    TesselB++;
    36723615    TesselC++;
    3673     PlaneNormal.AddVector(&helper);
     3616    PlaneNormal += helper;
    36743617  }
    36753618  //Log() << Verbose(0) << "Summed vectors " << center << "; number of points " << connectedPoints.size()
     
    36863629  // construct one orthogonal vector
    36873630  if (Reference != NULL) {
    3688     AngleZero.CopyVector(Reference);
    3689     AngleZero.SubtractVector(Point->node);
    3690     AngleZero.ProjectOntoPlane(&PlaneNormal);
     3631    AngleZero = (*Reference) - (*Point->node);
     3632    AngleZero.ProjectOntoPlane(PlaneNormal);
    36913633  }
    36923634  if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) {
    36933635    Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl;
    3694     AngleZero.CopyVector((*SetOfNeighbours->begin())->node);
    3695     AngleZero.SubtractVector(Point->node);
    3696     AngleZero.ProjectOntoPlane(&PlaneNormal);
     3636    AngleZero = (*(*SetOfNeighbours->begin())->node) - (*Point->node);
     3637    AngleZero.ProjectOntoPlane(PlaneNormal);
    36973638    if (AngleZero.NormSquared() < MYEPSILON) {
    36983639      eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl;
     
    37103651  pair <map<double, TesselPoint*>::iterator, bool > InserterTest;
    37113652  for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) {
    3712     helper.CopyVector((*listRunner)->node);
    3713     helper.SubtractVector(Point->node);
    3714     helper.ProjectOntoPlane(&PlaneNormal);
     3653    helper = (*(*listRunner)->node) - (*Point->node);
     3654    helper.ProjectOntoPlane(PlaneNormal);
    37153655    double angle = GetAngle(helper, AngleZero, OrthogonalVector);
    37163656    if (angle > M_PI) // the correction is of no use here (and not desired)
     
    39593899
    39603900  // copy old location for the volume
    3961   OldPoint.CopyVector(point->node->node);
     3901  OldPoint = (*point->node->node);
    39623902
    39633903  // get list of connected points
     
    39873927  for (TriangleMap::iterator Runner = Candidates.begin(); Runner != Candidates.end(); Runner++) {
    39883928    Log() << Verbose(1) << "INFO: Removing triangle " << *(Runner->second) << "." << endl;
    3989     NormalVector.SubtractVector(&Runner->second->NormalVector); // has to point inward
     3929    NormalVector -= Runner->second->NormalVector; // has to point inward
    39903930    RemoveTesselationTriangle(Runner->second);
    39913931    count++;
     
    40233963          StartNode--;
    40243964          //Log() << Verbose(3) << "INFO: StartNode is " << **StartNode << "." << endl;
    4025           Point.CopyVector((*StartNode)->node);
    4026           Point.SubtractVector((*MiddleNode)->node);
     3965          Point = (*(*StartNode)->node) - (*(*MiddleNode)->node);
    40273966          StartNode = MiddleNode;
    40283967          StartNode++;
     
    40303969            StartNode = connectedPath->begin();
    40313970          //Log() << Verbose(3) << "INFO: EndNode is " << **StartNode << "." << endl;
    4032           Reference.CopyVector((*StartNode)->node);
    4033           Reference.SubtractVector((*MiddleNode)->node);
    4034           OrthogonalVector.CopyVector((*MiddleNode)->node);
    4035           OrthogonalVector.SubtractVector(&OldPoint);
     3971          Reference = (*(*StartNode)->node) - (*(*MiddleNode)->node);
     3972          OrthogonalVector = (*(*MiddleNode)->node) - OldPoint;
    40363973          OrthogonalVector.MakeNormalTo(Reference);
    40373974          angle = GetAngle(Point, Reference, OrthogonalVector);
     
    45024439  class BoundaryLineSet *BestLine = NULL;
    45034440  for (LineMap::iterator Runner = NearestBoundaryPoint->lines.begin(); Runner != NearestBoundaryPoint->lines.end(); Runner++) {
    4504     BaseLine.CopyVector(Runner->second->endpoints[0]->node->node);
    4505     BaseLine.SubtractVector(Runner->second->endpoints[1]->node->node);
    4506     CenterToPoint.CopyVector(Runner->second->endpoints[0]->node->node);
    4507     CenterToPoint.AddVector(Runner->second->endpoints[1]->node->node);
    4508     CenterToPoint.Scale(0.5);
    4509     CenterToPoint.SubtractVector(point->node);
    4510     angle = CenterToPoint.Angle(&BaseLine);
     4441    BaseLine = (*Runner->second->endpoints[0]->node->node) -
     4442               (*Runner->second->endpoints[1]->node->node);
     4443    CenterToPoint = 0.5 * ((*Runner->second->endpoints[0]->node->node) +
     4444                           (*Runner->second->endpoints[1]->node->node));
     4445    CenterToPoint -= (*point->node);
     4446    angle = CenterToPoint.Angle(BaseLine);
    45114447    if (fabs(angle - M_PI/2.) < fabs(BestAngle - M_PI/2.)) {
    45124448      BestAngle = angle;
     
    46724608      for (map < int, Vector *>::iterator VectorRunner = VectorWalker; VectorRunner != TriangleVectors.end(); VectorRunner++)
    46734609        if (VectorWalker != VectorRunner) { // skip equals
    4674           const double SCP = VectorWalker->second->ScalarProduct(VectorRunner->second);  // ScalarProduct should result in -1. for degenerated triangles
     4610          const double SCP = VectorWalker->second->ScalarProduct(*VectorRunner->second);  // ScalarProduct should result in -1. for degenerated triangles
    46754611          Log() << Verbose(1) << "Checking " << *VectorWalker->second<< " against " << *VectorRunner->second << ": " << SCP << endl;
    46764612          if (fabs(SCP + 1.) < ParallelEpsilon) {
     
    47584694    TriangleSet::iterator TriangleWalker = T->begin();  // is the inner iterator
    47594695    /// 4a. Get NormalVector for one side (this is "front")
    4760     NormalVector.CopyVector(&(*TriangleWalker)->NormalVector);
     4696    NormalVector = (*TriangleWalker)->NormalVector;
    47614697    Log() << Verbose(1) << "\"front\" defining triangle is " << **TriangleWalker << " and Normal vector of \"front\" side is " << NormalVector << endl;
    47624698    TriangleWalker++;
     
    47694705      TriangleSprinter++;
    47704706      Log() << Verbose(1) << "Current triangle to test for removal: " << *triangle << endl;
    4771       if (triangle->NormalVector.ScalarProduct(&NormalVector) < 0) { // if from other side, then delete and remove from list
     4707      if (triangle->NormalVector.ScalarProduct(NormalVector) < 0) { // if from other side, then delete and remove from list
    47724708        Log() << Verbose(1) << " Removing ... " << endl;
    47734709        TriangleNrs.push(triangle->Nr);
     
    47914727      AddTesselationTriangle(); // ... and add
    47924728      TriangleNrs.pop();
    4793       BTS->NormalVector.CopyVector(&(*TriangleWalker)->NormalVector);
    4794       BTS->NormalVector.Scale(-1.);
     4729      BTS->NormalVector = -1 * (*TriangleWalker)->NormalVector;
    47954730      TriangleWalker++;
    47964731    }
  • src/tesselationhelpers.cpp

    r72e7fa r273382  
    8888  center->at(2) =  0.5 * m14/ m11;
    8989
    90   if (fabs(a.Distance(center) - RADIUS) > MYEPSILON)
    91     eLog() << Verbose(1) << "The given center is further way by " << fabs(a.Distance(center) - RADIUS) << " from a than RADIUS." << endl;
     90  if (fabs(a.Distance(*center) - RADIUS) > MYEPSILON)
     91    eLog() << Verbose(1) << "The given center is further way by " << fabs(a.Distance(*center) - RADIUS) << " from a than RADIUS." << endl;
    9292
    9393  gsl_matrix_free(A);
     
    121121  Vector OtherCenter;
    122122  Center->Zero();
    123   helper.CopyVector(&a);
    124   helper.Scale(sin(2.*alpha));
    125   Center->AddVector(&helper);
    126   helper.CopyVector(&b);
    127   helper.Scale(sin(2.*beta));
    128   Center->AddVector(&helper);
    129   helper.CopyVector(&c);
    130   helper.Scale(sin(2.*gamma));
    131   Center->AddVector(&helper);
     123  helper = sin(2.*alpha) * a;
     124  (*Center) += helper;
     125  helper = sin(2.*beta) * b;
     126  (*Center) += helper;
     127  helper = sin(2.*gamma) * c;
     128  (*Center) += helper;
    132129  //*Center = a * sin(2.*alpha) + b * sin(2.*beta) + c * sin(2.*gamma) ;
    133130  Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma)));
    134   NewUmkreismittelpunkt->CopyVector(Center);
     131  (*NewUmkreismittelpunkt) = (*Center);
    135132  Log() << Verbose(1) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n";
    136133  // Here we calculated center of circumscribing circle, using barycentric coordinates
    137134  Log() << Verbose(1) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n";
    138135
    139   TempNormal.CopyVector(&a);
    140   TempNormal.SubtractVector(&b);
    141   helper.CopyVector(&a);
    142   helper.SubtractVector(&c);
    143   TempNormal.VectorProduct(&helper);
     136  TempNormal = a - b;
     137  helper = a - c;
     138  TempNormal.VectorProduct(helper);
    144139  if (fabs(HalfplaneIndicator) < MYEPSILON)
    145140    {
    146       if ((TempNormal.ScalarProduct(AlternativeDirection) <0 && AlternativeIndicator >0) || (TempNormal.ScalarProduct(AlternativeDirection) >0 && AlternativeIndicator <0))
     141      if ((TempNormal.ScalarProduct(*AlternativeDirection) <0 && AlternativeIndicator >0) || (TempNormal.ScalarProduct(*AlternativeDirection) >0 && AlternativeIndicator <0))
    147142        {
    148           TempNormal.Scale(-1);
     143          TempNormal *= -1;
    149144        }
    150145    }
    151146  else
    152147    {
    153       if (((TempNormal.ScalarProduct(Direction)<0) && (HalfplaneIndicator >0)) || ((TempNormal.ScalarProduct(Direction)>0) && (HalfplaneIndicator<0)))
     148      if (((TempNormal.ScalarProduct(*Direction)<0) && (HalfplaneIndicator >0)) || ((TempNormal.ScalarProduct(*Direction)>0) && (HalfplaneIndicator<0)))
    154149        {
    155           TempNormal.Scale(-1);
     150          TempNormal *= -1;
    156151        }
    157152    }
     
    163158  Log() << Verbose(1) << "Shift vector to sphere of circumference is " << TempNormal << ".\n";
    164159
    165   Center->AddVector(&TempNormal);
     160  (*Center) += TempNormal;
    166161  Log() << Verbose(1) << "Center of sphere of circumference is " << *Center << ".\n";
    167162  GetSphere(&OtherCenter, a, b, c, RADIUS);
     
    181176  Vector helper;
    182177  double alpha, beta, gamma;
    183   Vector SideA, SideB, SideC;
    184   SideA.CopyVector(b);
    185   SideA.SubtractVector(&c);
    186   SideB.CopyVector(c);
    187   SideB.SubtractVector(&a);
    188   SideC.CopyVector(a);
    189   SideC.SubtractVector(&b);
    190   alpha = M_PI - SideB.Angle(&SideC);
    191   beta = M_PI - SideC.Angle(&SideA);
    192   gamma = M_PI - SideA.Angle(&SideB);
     178  Vector SideA = b - c;
     179  Vector SideB = c - a;
     180  Vector SideC = a - b;
     181  alpha = M_PI - SideB.Angle(SideC);
     182  beta = M_PI - SideC.Angle(SideA);
     183  gamma = M_PI - SideA.Angle(SideB);
    193184  //Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl;
    194185  if (fabs(M_PI - alpha - beta - gamma) > HULLEPSILON) {
     
    197188
    198189  Center->Zero();
    199   helper.CopyVector(a);
    200   helper.Scale(sin(2.*alpha));
    201   Center->AddVector(&helper);
    202   helper.CopyVector(b);
    203   helper.Scale(sin(2.*beta));
    204   Center->AddVector(&helper);
    205   helper.CopyVector(c);
    206   helper.Scale(sin(2.*gamma));
    207   Center->AddVector(&helper);
     190  helper = sin(2.*alpha) * a;
     191  (*Center) += helper;
     192  helper = sin(2.*beta) * b;
     193  (*Center) += helper;
     194  helper = sin(2.*gamma) * c;
     195  (*Center) += helper;
    208196  Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma)));
    209197};
     
    227215  Vector helper;
    228216  double radius, alpha;
    229   Vector RelativeOldSphereCenter;
    230   Vector RelativeNewSphereCenter;
    231 
    232   RelativeOldSphereCenter.CopyVector(&OldSphereCenter);
    233   RelativeOldSphereCenter.SubtractVector(&CircleCenter);
    234   RelativeNewSphereCenter.CopyVector(&NewSphereCenter);
    235   RelativeNewSphereCenter.SubtractVector(&CircleCenter);
    236   helper.CopyVector(&RelativeNewSphereCenter);
     217
     218  Vector RelativeOldSphereCenter = OldSphereCenter - CircleCenter;
     219  Vector RelativeNewSphereCenter = NewSphereCenter - CircleCenter;
     220  helper = RelativeNewSphereCenter;
    237221  // test whether new center is on the parameter circle's plane
    238   if (fabs(helper.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {
    239     eLog() << Verbose(1) << "Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(&CirclePlaneNormal))  << "!" << endl;
    240     helper.ProjectOntoPlane(&CirclePlaneNormal);
     222  if (fabs(helper.ScalarProduct(CirclePlaneNormal)) > HULLEPSILON) {
     223    eLog() << Verbose(1) << "Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(CirclePlaneNormal))  << "!" << endl;
     224    helper.ProjectOntoPlane(CirclePlaneNormal);
    241225  }
    242226  radius = helper.NormSquared();
     
    244228  if (fabs(radius - CircleRadius) > HULLEPSILON)
    245229    eLog() << Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl;
    246   alpha = helper.Angle(&RelativeOldSphereCenter);
     230  alpha = helper.Angle(RelativeOldSphereCenter);
    247231  // make the angle unique by checking the halfplanes/search direction
    248   if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)  // acos is not unique on [0, 2.*M_PI), hence extra check to decide between two half intervals
     232  if (helper.ScalarProduct(SearchDirection) < -HULLEPSILON)  // acos is not unique on [0, 2.*M_PI), hence extra check to decide between two half intervals
    249233    alpha = 2.*M_PI - alpha;
    250234  Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << RelativeOldSphereCenter << " and resulting angle is " << alpha << "." << endl;
    251   radius = helper.Distance(&RelativeOldSphereCenter);
    252   helper.ProjectOntoPlane(&NormalVector);
     235  radius = helper.Distance(RelativeOldSphereCenter);
     236  helper.ProjectOntoPlane(NormalVector);
    253237  // check whether new center is somewhat away or at least right over the current baseline to prevent intersecting triangles
    254238  if ((radius > HULLEPSILON) || (helper.Norm() < HULLEPSILON)) {
     
    280264  struct Intersection *I = (struct Intersection *)params;
    281265  Vector intersection;
    282   Vector SideA,SideB,HeightA, HeightB;
    283266  for (int i=0;i<NDIM;i++)
    284267    intersection[i] = gsl_vector_get(x, i);
    285268
    286   SideA.CopyVector(&(I->x1));
    287   SideA.SubtractVector(&I->x2);
    288   HeightA.CopyVector(&intersection);
    289   HeightA.SubtractVector(&I->x1);
    290   HeightA.ProjectOntoPlane(&SideA);
    291 
    292   SideB.CopyVector(&I->x3);
    293   SideB.SubtractVector(&I->x4);
    294   HeightB.CopyVector(&intersection);
    295   HeightB.SubtractVector(&I->x3);
    296   HeightB.ProjectOntoPlane(&SideB);
    297 
    298   retval = HeightA.ScalarProduct(&HeightA) + HeightB.ScalarProduct(&HeightB);
     269  Vector SideA = I->x1 -I->x2 ;
     270  Vector HeightA = intersection - I->x1;
     271  HeightA.ProjectOntoPlane(SideA);
     272
     273  Vector SideB = I->x3 - I->x4;
     274  Vector HeightB = intersection - I->x3;
     275  HeightB.ProjectOntoPlane(SideB);
     276
     277  retval = HeightA.ScalarProduct(HeightA) + HeightB.ScalarProduct(HeightB);
    299278  //Log() << Verbose(1) << "MinIntersectDistance called, result: " << retval << endl;
    300279
     
    321300
    322301  struct Intersection par;
    323     par.x1.CopyVector(&point1);
    324     par.x2.CopyVector(&point2);
    325     par.x3.CopyVector(&point3);
    326     par.x4.CopyVector(&point4);
     302    par.x1 = point1;
     303    par.x2 = point2;
     304    par.x3 = point3;
     305    par.x4 = point4;
    327306
    328307    const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex;
     
    370349
    371350    // check whether intersection is in between or not
    372   Vector intersection, SideA, SideB, HeightA, HeightB;
     351  Vector intersection;
    373352  double t1, t2;
    374353  for (int i = 0; i < NDIM; i++) {
     
    376355  }
    377356
    378   SideA.CopyVector(&par.x2);
    379   SideA.SubtractVector(&par.x1);
    380   HeightA.CopyVector(&intersection);
    381   HeightA.SubtractVector(&par.x1);
    382 
    383   t1 = HeightA.ScalarProduct(&SideA)/SideA.ScalarProduct(&SideA);
    384 
    385   SideB.CopyVector(&par.x4);
    386   SideB.SubtractVector(&par.x3);
    387   HeightB.CopyVector(&intersection);
    388   HeightB.SubtractVector(&par.x3);
    389 
    390   t2 = HeightB.ScalarProduct(&SideB)/SideB.ScalarProduct(&SideB);
     357  Vector SideA = par.x2 - par.x1;
     358  Vector HeightA = intersection - par.x1;
     359
     360  t1 = HeightA.ScalarProduct(SideA)/SideA.ScalarProduct(SideA);
     361
     362  Vector SideB = par.x4 - par.x3;
     363  Vector HeightB = intersection - par.x3;
     364
     365  t2 = HeightB.ScalarProduct(SideB)/SideB.ScalarProduct(SideB);
    391366
    392367  Log() << Verbose(1) << "Intersection " << intersection << " is at "
     
    428403  if (point.IsZero())
    429404    return M_PI;
    430   double phi = point.Angle(&reference);
    431   if (OrthogonalVector.ScalarProduct(&point) > 0) {
     405  double phi = point.Angle(reference);
     406  if (OrthogonalVector.ScalarProduct(point) > 0) {
    432407    phi = 2.*M_PI - phi;
    433408  }
     
    456431  TetraederVector[2].CopyVector(c);
    457432  for (int j=0;j<3;j++)
    458     TetraederVector[j].SubtractVector(&d);
    459   Point.CopyVector(&TetraederVector[0]);
    460   Point.VectorProduct(&TetraederVector[1]);
    461   volume = 1./6. * fabs(Point.ScalarProduct(&TetraederVector[2]));
     433    TetraederVector[j].SubtractVector(d);
     434  Point.CopyVector(TetraederVector[0]);
     435  Point.VectorProduct(TetraederVector[1]);
     436  volume = 1./6. * fabs(Point.ScalarProduct(TetraederVector[2]));
    462437  return volume;
    463438};
     
    583558        if (List != NULL) {
    584559          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    585             helper.CopyVector(Point);
    586             helper.SubtractVector((*Runner)->node);
    587             double currentNorm = helper. Norm();
     560            helper = (*Point) - (*(*Runner)->node);
     561            double currentNorm = helper.Norm();
    588562            if (currentNorm < distance) {
    589563              // remember second point
     
    638612        if (List != NULL) {
    639613          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    640             helper.CopyVector(Point);
    641             helper.SubtractVector((*Runner)->node);
     614            helper = (*Point) - (*(*Runner)->node);
    642615            double currentNorm = helper.NormSquared();
    643616            if (currentNorm < distance) {
     
    678651        Info FunctionInfo(__func__);
    679652  // construct the plane of the two baselines (i.e. take both their directional vectors)
    680   Vector Normal;
    681   Vector Baseline, OtherBaseline;
    682   Baseline.CopyVector(Base->endpoints[1]->node->node);
    683   Baseline.SubtractVector(Base->endpoints[0]->node->node);
    684   OtherBaseline.CopyVector(OtherBase->endpoints[1]->node->node);
    685   OtherBaseline.SubtractVector(OtherBase->endpoints[0]->node->node);
    686   Normal.CopyVector(&Baseline);
    687   Normal.VectorProduct(&OtherBaseline);
     653  Vector Baseline = (*Base->endpoints[1]->node->node) - (*Base->endpoints[0]->node->node);
     654  Vector OtherBaseline = (*OtherBase->endpoints[1]->node->node) - (*OtherBase->endpoints[0]->node->node);
     655  Vector Normal = Baseline;
     656  Normal.VectorProduct(OtherBaseline);
    688657  Normal.Normalize();
    689658  Log() << Verbose(1) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl;
    690659
    691660  // project one offset point of OtherBase onto this plane (and add plane offset vector)
    692   Vector NewOffset;
    693   NewOffset.CopyVector(OtherBase->endpoints[0]->node->node);
    694   NewOffset.SubtractVector(Base->endpoints[0]->node->node);
    695   NewOffset.ProjectOntoPlane(&Normal);
    696   NewOffset.AddVector(Base->endpoints[0]->node->node);
    697   Vector NewDirection;
    698   NewDirection.CopyVector(&NewOffset);
    699   NewDirection.AddVector(&OtherBaseline);
     661  Vector NewOffset = (*OtherBase->endpoints[0]->node->node) - (*Base->endpoints[0]->node->node);
     662  NewOffset.ProjectOntoPlane(Normal);
     663  NewOffset += (*Base->endpoints[0]->node->node);
     664  Vector NewDirection = NewOffset + OtherBaseline;
    700665
    701666  // calculate the intersection between this projected baseline and Base
     
    704669                                                   *(Base->endpoints[1]->node->node),
    705670                                                     NewOffset, NewDirection);
    706   Normal.CopyVector(Intersection);
    707   Normal.SubtractVector(Base->endpoints[0]->node->node);
    708   Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(&Baseline)/Baseline.NormSquared()) << "." << endl;
     671  Normal = (*Intersection) - (*Base->endpoints[0]->node->node);
     672  Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(Baseline)/Baseline.NormSquared()) << "." << endl;
    709673
    710674  return Intersection;
     
    724688    return -1;
    725689  }
    726   distance = x->DistanceToPlane(&triangle->NormalVector, triangle->endpoints[0]->node->node);
     690  distance = x->DistanceToPlane(triangle->NormalVector, *triangle->endpoints[0]->node->node);
    727691  return distance;
    728692};
     
    787751    Vector *center = cloud->GetCenter();
    788752    // make the circumsphere's center absolute again
    789     helper.CopyVector(Tess->LastTriangle->endpoints[0]->node->node);
    790     helper.AddVector(Tess->LastTriangle->endpoints[1]->node->node);
    791     helper.AddVector(Tess->LastTriangle->endpoints[2]->node->node);
    792     helper.Scale(1./3.);
    793     helper.SubtractVector(center);
     753    Vector helper = (1./3.) * ((*Tess->LastTriangle->endpoints[0]->node->node) +
     754                               (*Tess->LastTriangle->endpoints[1]->node->node) +
     755                               (*Tess->LastTriangle->endpoints[2]->node->node));
     756    helper -= (*center);
    794757    // and add to file plus translucency object
    795758    *rasterfile << "# current virtual sphere\n";
  • src/test/ActOnAlltest.hpp

    r72e7fa r273382  
    2727
    2828  template <typename klasse, typename res, typename T> void ActOnAll( res (klasse::*f)(T), T t );
     29  template <typename klasse, typename res, typename T> void ActOnAll( res (klasse::*f)(T&), T &t );
    2930  template <typename klasse, typename res, typename T, typename U> void ActOnAll( res (klasse::*f)(T, U), T t, U u );
    3031  template <typename klasse, typename res, typename T, typename U, typename V> void ActOnAll( res (klasse::*f)(T, U, V), T t, U u, V v);
     
    7677};
    7778
     79template <typename klasse, typename res, typename T> void VectorList::ActOnAll( res (klasse::*f)(T&), T &t )
     80{
     81  for (ListOfVectors::iterator Runner = Vectors.begin(); Runner != Vectors.end(); Runner++)
     82    ((*Runner)->*f)(t);
     83};
     84
    7885template <typename klasse, typename res, typename T, typename U> void VectorList::ActOnAll( res (klasse::*f)(T, U), T t, U u )
    7986{
  • src/unittests/ActOnAllUnitTest.cpp

    r72e7fa r273382  
    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};
  • src/unittests/vectorunittest.cpp

    r72e7fa r273382  
    7272  CPPUNIT_ASSERT_EQUAL( Vector(2.,3.,4.), fixture );
    7373  // summation and scaling
    74   fixture.CopyVector(&zero);
    75   fixture.AddVector(&unit);
    76   CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    77   fixture.CopyVector(&zero);
    78   fixture.SubtractVector(&unit);
     74  fixture = zero + unit;
     75  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
     76  fixture = zero - unit;
    7977  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    8078  CPPUNIT_ASSERT_EQUAL( false, fixture.IsZero() );
    81   fixture.CopyVector(&zero);
    82   fixture.AddVector(&zero);
     79  fixture = zero + zero;
    8380  CPPUNIT_ASSERT_EQUAL( true, fixture.IsZero() );
    84   fixture.CopyVector(&notunit);
    85   fixture.SubtractVector(&otherunit);
    86   CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    87   fixture.CopyVector(&unit);
    88   fixture.AddVector(&otherunit);
     81  fixture = notunit - otherunit;
     82  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
     83  fixture = unit - otherunit;
    8984  CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() );
    90   fixture.CopyVector(&notunit);
    91   fixture.SubtractVector(&unit);
    92   fixture.SubtractVector(&otherunit);
     85  fixture = notunit - unit - otherunit;
    9386  CPPUNIT_ASSERT_EQUAL( false, fixture.IsZero() );
    94   fixture.CopyVector(&unit);
    95   fixture.Scale(0.98);
     87  fixture = 0.98 * unit;
    9688  CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() );
    97   fixture.CopyVector(&unit);
    98   fixture.Scale(1.);
    99   CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    100   fixture.CopyVector(&unit);
     89  fixture = 1. * unit;
     90  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    10191  factor = 0.98;
    102   fixture.Scale(factor);
     92  fixture = factor * unit;
    10393  CPPUNIT_ASSERT_EQUAL( false, fixture.IsOne() );
    104   fixture.CopyVector(&unit);
    10594  factor = 1.;
    106   fixture.Scale(factor);
     95  fixture = factor * unit;
    10796  CPPUNIT_ASSERT_EQUAL( true, fixture.IsOne() );
    10897};
     
    134123void VectorTest::EuclidianScalarProductTest()
    135124{
    136   CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(&zero) );
    137   CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(&unit) );
    138   CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(&otherunit) );
    139   CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(&notunit) );
    140   CPPUNIT_ASSERT_EQUAL( 1., unit.ScalarProduct(&unit) );
    141   CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(&unit) );
    142   CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(&unit) );
    143   CPPUNIT_ASSERT_EQUAL( 1., otherunit.ScalarProduct(&notunit) );
    144   CPPUNIT_ASSERT_EQUAL( 2., two.ScalarProduct(&unit) );
    145   CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(&otherunit) );
    146   CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(&notunit) );
     125  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(zero) );
     126  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(unit) );
     127  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(otherunit) );
     128  CPPUNIT_ASSERT_EQUAL( 0., zero.ScalarProduct(notunit) );
     129  CPPUNIT_ASSERT_EQUAL( 1., unit.ScalarProduct(unit) );
     130  CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(unit) );
     131  CPPUNIT_ASSERT_EQUAL( 0., otherunit.ScalarProduct(unit) );
     132  CPPUNIT_ASSERT_EQUAL( 1., otherunit.ScalarProduct(notunit) );
     133  CPPUNIT_ASSERT_EQUAL( 2., two.ScalarProduct(unit) );
     134  CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(otherunit) );
     135  CPPUNIT_ASSERT_EQUAL( 1., two.ScalarProduct(notunit) );
    147136}
    148137
     
    165154void VectorTest::EuclidianDistancesTest()
    166155{
    167   CPPUNIT_ASSERT_EQUAL( 1., zero.Distance(&unit) );
    168   CPPUNIT_ASSERT_EQUAL( sqrt(2.), otherunit.Distance(&unit) );
    169   CPPUNIT_ASSERT_EQUAL( sqrt(2.), zero.Distance(&notunit) );
    170   CPPUNIT_ASSERT_EQUAL( 1., otherunit.Distance(&notunit) );
    171   CPPUNIT_ASSERT_EQUAL( sqrt(5.), two.Distance(&notunit) );
     156  CPPUNIT_ASSERT_EQUAL( 1., zero.Distance(unit) );
     157  CPPUNIT_ASSERT_EQUAL( sqrt(2.), otherunit.Distance(unit) );
     158  CPPUNIT_ASSERT_EQUAL( sqrt(2.), zero.Distance(notunit) );
     159  CPPUNIT_ASSERT_EQUAL( 1., otherunit.Distance(notunit) );
     160  CPPUNIT_ASSERT_EQUAL( sqrt(5.), two.Distance(notunit) );
    172161}
    173162
     
    176165void VectorTest::EuclidianAnglesTest()
    177166{
    178   CPPUNIT_ASSERT_EQUAL( M_PI, zero.Angle(&unit) );
    179   CPPUNIT_ASSERT_EQUAL( 0., unit.Angle(&unit) );
    180   CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - otherunit.Angle(&unit)) < MYEPSILON );
    181   CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - unit.Angle(&notunit)) < MYEPSILON );
    182   CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/4. - otherunit.Angle(&notunit)) < MYEPSILON );
     167  CPPUNIT_ASSERT_EQUAL( M_PI, zero.Angle(unit) );
     168  CPPUNIT_ASSERT_EQUAL( 0., unit.Angle(unit) );
     169  CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - otherunit.Angle(unit)) < MYEPSILON );
     170  CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/2. - unit.Angle(notunit)) < MYEPSILON );
     171  CPPUNIT_ASSERT_EQUAL( true, fabs(M_PI/4. - otherunit.Angle(notunit)) < MYEPSILON );
    183172};
    184173
     
    187176void VectorTest::ProjectionTest()
    188177{
    189   CPPUNIT_ASSERT_EQUAL( zero, zero.Projection(&unit) );
    190   CPPUNIT_ASSERT_EQUAL( zero, otherunit.Projection(&unit) );
    191   CPPUNIT_ASSERT_EQUAL( Vector(0.4,0.2,0.),  otherunit.Projection(&two) );
    192   CPPUNIT_ASSERT_EQUAL( Vector(0.,1.,0.),  two.Projection(&otherunit) );
     178  CPPUNIT_ASSERT_EQUAL( zero, zero.Projection(unit) );
     179  CPPUNIT_ASSERT_EQUAL( zero, otherunit.Projection(unit) );
     180  CPPUNIT_ASSERT_EQUAL( Vector(0.4,0.2,0.),  otherunit.Projection(two) );
     181  CPPUNIT_ASSERT_EQUAL( Vector(0.,1.,0.),  two.Projection(otherunit) );
    193182};
    194183
  • src/vector.cpp

    r72e7fa r273382  
    7070 * \return \f$| x - y |^2\f$
    7171 */
    72 double Vector::DistanceSquared(const Vector * const y) const
     72double Vector::DistanceSquared(const Vector &y) const
    7373{
    7474  double res = 0.;
    7575  for (int i=NDIM;i--;)
    76     res += (x[i]-y->x[i])*(x[i]-y->x[i]);
     76    res += (x[i]-y[i])*(x[i]-y[i]);
    7777  return (res);
    7878};
     
    8282 * \return \f$| x - y |\f$
    8383 */
    84 double Vector::Distance(const Vector * const y) const
    85 {
    86   double res = 0.;
    87   for (int i=NDIM;i--;)
    88     res += (x[i]-y->x[i])*(x[i]-y->x[i]);
    89   return (sqrt(res));
     84double Vector::Distance(const Vector &y) const
     85{
     86  return (sqrt(DistanceSquared(y)));
    9087};
    9188
     
    9592 * \return \f$| x - y |\f$
    9693 */
    97 double Vector::PeriodicDistance(const Vector * const y, const double * const cell_size) const
     94double Vector::PeriodicDistance(const Vector &y, const double * const cell_size) const
    9895{
    9996  double res = Distance(y), tmp, matrix[NDIM*NDIM];
     
    119116        TranslationVector.MatrixMultiplication(matrix);
    120117        // add onto the original vector to compare with
    121         Shiftedy.CopyVector(y);
    122         Shiftedy.AddVector(&TranslationVector);
     118        Shiftedy = y + TranslationVector;
    123119        // get distance and compare with minimum so far
    124         tmp = Distance(&Shiftedy);
     120        tmp = Distance(Shiftedy);
    125121        if (tmp < res) res = tmp;
    126122      }
     
    133129 * \return \f$| x - y |^2\f$
    134130 */
    135 double Vector::PeriodicDistanceSquared(const Vector * const y, const double * const cell_size) const
     131double Vector::PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const
    136132{
    137133  double res = DistanceSquared(y), tmp, matrix[NDIM*NDIM];
     
    157153        TranslationVector.MatrixMultiplication(matrix);
    158154        // add onto the original vector to compare with
    159         Shiftedy.CopyVector(y);
    160         Shiftedy.AddVector(&TranslationVector);
     155        Shiftedy = y + TranslationVector;
    161156        // get distance and compare with minimum so far
    162         tmp = DistanceSquared(&Shiftedy);
     157        tmp = DistanceSquared(Shiftedy);
    163158        if (tmp < res) res = tmp;
    164159      }
     
    180175//  Output(out);
    181176//  Log() << Verbose(0) << endl;
    182   TestVector.CopyVector(this);
     177  TestVector = (*this);
    183178  TestVector.InverseMatrixMultiplication(matrix);
    184179  for(int i=NDIM;i--;) { // correct periodically
     
    190185  }
    191186  TestVector.MatrixMultiplication(matrix);
    192   CopyVector(&TestVector);
     187  (*this) = TestVector;
    193188//  Log() << Verbose(2) << "New corrected vector is: ";
    194189//  Output(out);
     
    201196 * \return \f$\langle x, y \rangle\f$
    202197 */
    203 double Vector::ScalarProduct(const Vector * const y) const
     198double Vector::ScalarProduct(const Vector &y) const
    204199{
    205200  double res = 0.;
    206201  for (int i=NDIM;i--;)
    207     res += x[i]*y->x[i];
     202    res += x[i]*y[i];
    208203  return (res);
    209204};
     
    216211 *  \return \f$ x \times y \f&
    217212 */
    218 void Vector::VectorProduct(const Vector * const y)
     213void Vector::VectorProduct(const Vector &y)
    219214{
    220215  Vector tmp;
    221   tmp.x[0] = x[1]* (y->x[2]) - x[2]* (y->x[1]);
    222   tmp.x[1] = x[2]* (y->x[0]) - x[0]* (y->x[2]);
    223   tmp.x[2] = x[0]* (y->x[1]) - x[1]* (y->x[0]);
    224   this->CopyVector(&tmp);
     216  tmp[0] = x[1]* (y[2]) - x[2]* (y[1]);
     217  tmp[1] = x[2]* (y[0]) - x[0]* (y[2]);
     218  tmp[2] = x[0]* (y[1]) - x[1]* (y[0]);
     219  (*this) = tmp;
    225220};
    226221
     
    230225 * \return \f$\langle x, y \rangle\f$
    231226 */
    232 void Vector::ProjectOntoPlane(const Vector * const y)
    233 {
    234   Vector tmp;
    235   tmp.CopyVector(y);
     227void Vector::ProjectOntoPlane(const Vector &y)
     228{
     229  Vector tmp = y;
    236230  tmp.Normalize();
    237   tmp.Scale(ScalarProduct(&tmp));
    238   this->SubtractVector(&tmp);
     231  tmp *= ScalarProduct(tmp);
     232  (*this) -= tmp;
    239233};
    240234
     
    245239 * \return distance to plane
    246240 */
    247 double Vector::DistanceToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const
    248 {
    249   Vector temp;
    250 
     241double Vector::DistanceToPlane(const Vector &PlaneNormal, const Vector &PlaneOffset) const
     242{
    251243  // first create part that is orthonormal to PlaneNormal with withdraw
    252   temp.CopyVector(this);
    253   temp.SubtractVector(PlaneOffset);
    254   temp.MakeNormalTo(*PlaneNormal);
    255   temp.Scale(-1.);
     244  Vector temp = (*this) - PlaneOffset;
     245  temp.MakeNormalTo(PlaneNormal);
     246  temp *= -1.;
    256247  // then add connecting vector from plane to point
    257   temp.AddVector(this);
    258   temp.SubtractVector(PlaneOffset);
     248  temp += (*this);
     249  temp -= PlaneOffset;
    259250  double sign = temp.ScalarProduct(PlaneNormal);
    260251  if (fabs(sign) > MYEPSILON)
     
    269260 * \param *y array to second vector
    270261 */
    271 void Vector::ProjectIt(const Vector * const y)
    272 {
    273   Vector helper(*y);
     262void Vector::ProjectIt(const Vector &y)
     263{
     264  Vector helper = y;
    274265  helper.Scale(-(ScalarProduct(y)));
    275   AddVector(&helper);
     266  AddVector(helper);
    276267};
    277268
     
    280271 * \return Vector
    281272 */
    282 Vector Vector::Projection(const Vector * const y) const
    283 {
    284   Vector helper(*y);
    285   helper.Scale((ScalarProduct(y)/y->NormSquared()));
     273Vector Vector::Projection(const Vector &y) const
     274{
     275  Vector helper = y;
     276  helper.Scale((ScalarProduct(y)/y.NormSquared()));
    286277
    287278  return helper;
     
    293284double Vector::Norm() const
    294285{
    295   double res = 0.;
    296   for (int i=NDIM;i--;)
    297     res += this->x[i]*this->x[i];
    298   return (sqrt(res));
     286  return (sqrt(NormSquared()));
    299287};
    300288
     
    304292double Vector::NormSquared() const
    305293{
    306   return (ScalarProduct(this));
     294  return (ScalarProduct(*this));
    307295};
    308296
     
    363351 * @return true - vector is normalized, false - vector is not
    364352 */
    365 bool Vector::IsNormalTo(const Vector * const normal) const
     353bool Vector::IsNormalTo(const Vector &normal) const
    366354{
    367355  if (ScalarProduct(normal) < MYEPSILON)
     
    374362 * @return true - vector is normalized, false - vector is not
    375363 */
    376 bool Vector::IsEqualTo(const Vector * const a) const
     364bool Vector::IsEqualTo(const Vector &a) const
    377365{
    378366  bool status = true;
    379367  for (int i=0;i<NDIM;i++) {
    380     if (fabs(x[i] - a->x[i]) > MYEPSILON)
     368    if (fabs(x[i] - a[i]) > MYEPSILON)
    381369      status = false;
    382370  }
     
    388376 * \return \f$\acos\bigl(frac{\langle x, y \rangle}{|x||y|}\bigr)\f$
    389377 */
    390 double Vector::Angle(const Vector * const y) const
    391 {
    392   double norm1 = Norm(), norm2 = y->Norm();
     378double Vector::Angle(const Vector &y) const
     379{
     380  double norm1 = Norm(), norm2 = y.Norm();
    393381  double angle = -1;
    394382  if ((fabs(norm1) > MYEPSILON) && (fabs(norm2) > MYEPSILON))
     
    446434const Vector& Vector::operator+=(const Vector& b)
    447435{
    448   this->AddVector(&b);
     436  this->AddVector(b);
    449437  return *this;
    450438};
     
    457445const Vector& Vector::operator-=(const Vector& b)
    458446{
    459   this->SubtractVector(&b);
     447  this->SubtractVector(b);
    460448  return *this;
    461449};
     
    480468{
    481469  Vector x = *this;
    482   x.AddVector(&b);
     470  x.AddVector(b);
    483471  return x;
    484472};
     
    492480{
    493481  Vector x = *this;
    494   x.SubtractVector(&b);
     482  x.SubtractVector(b);
    495483  return x;
    496484};
     
    556544 * \param trans[] translation vector.
    557545 */
    558 void Vector::Translate(const Vector * const trans)
    559 {
    560   for (int i=NDIM;i--;)
    561     x[i] += trans->x[i];
     546void Vector::Translate(const Vector &trans)
     547{
     548  for (int i=NDIM;i--;)
     549    x[i] += trans[i];
    562550};
    563551
     
    639627 * \param *factors three-component vector with the factor for each given vector
    640628 */
    641 void Vector::LinearCombinationOfVectors(const Vector * const x1, const Vector * const x2, const Vector * const x3, const double * const factors)
    642 {
    643   for(int i=NDIM;i--;)
    644     x[i] = factors[0]*x1->x[i] + factors[1]*x2->x[i] + factors[2]*x3->x[i];
     629void Vector::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors)
     630{
     631  (*this) = (factors[0]*x1) +
     632            (factors[1]*x2) +
     633            (factors[2]*x3);
    645634};
    646635
     
    648637 * \param n[] normal vector of mirror plane.
    649638 */
    650 void Vector::Mirror(const Vector * const n)
     639void Vector::Mirror(const Vector &n)
    651640{
    652641  double projection;
    653   projection = ScalarProduct(n)/n->ScalarProduct(n);    // remove constancy from n (keep as logical one)
     642  projection = ScalarProduct(n)/n.NormSquared();    // remove constancy from n (keep as logical one)
    654643  // withdraw projected vector twice from original one
    655644  for (int i=NDIM;i--;)
    656     x[i] -= 2.*projection*n->x[i];
     645    x[i] -= 2.*projection*n[i];
    657646};
    658647
     
    667656{
    668657  bool result = false;
    669   double factor = y1.ScalarProduct(this)/y1.NormSquared();
    670   Vector x1;
    671   x1.CopyVector(&y1);
    672   x1.Scale(factor);
    673   SubtractVector(&x1);
     658  double factor = y1.ScalarProduct(*this)/y1.NormSquared();
     659  Vector x1 = factor * y1 ;
     660  SubtractVector(x1);
    674661  for (int i=NDIM;i--;)
    675662    result = result || (fabs(x[i]) > MYEPSILON);
     
    684671 * \return true - success, false - failure (null vector given)
    685672 */
    686 bool Vector::GetOneNormalVector(const Vector * const GivenVector)
     673bool Vector::GetOneNormalVector(const Vector &GivenVector)
    687674{
    688675  int Components[NDIM]; // contains indices of non-zero components
     
    695682  // find two components != 0
    696683  for (j=0;j<NDIM;j++)
    697     if (fabs(GivenVector->x[j]) > MYEPSILON)
     684    if (fabs(GivenVector[j]) > MYEPSILON)
    698685      Components[Last++] = j;
    699686
     
    701688    case 3:  // threecomponent system
    702689    case 2:  // two component system
    703       norm = sqrt(1./(GivenVector->x[Components[1]]*GivenVector->x[Components[1]]) + 1./(GivenVector->x[Components[0]]*GivenVector->x[Components[0]]));
     690      norm = sqrt(1./(GivenVector[Components[1]]*GivenVector[Components[1]]) + 1./(GivenVector[Components[0]]*GivenVector[Components[0]]));
    704691      x[Components[2]] = 0.;
    705692      // in skp both remaining parts shall become zero but with opposite sign and third is zero
    706       x[Components[1]] = -1./GivenVector->x[Components[1]] / norm;
    707       x[Components[0]] = 1./GivenVector->x[Components[0]] / norm;
     693      x[Components[1]] = -1./GivenVector[Components[1]] / norm;
     694      x[Components[0]] = 1./GivenVector[Components[0]] / norm;
    708695      return true;
    709696      break;
     
    720707};
    721708
    722 /** Determines parameter needed to multiply this vector to obtain intersection point with plane defined by \a *A, \a *B and \a *C.
    723  * \param *A first plane vector
    724  * \param *B second plane vector
    725  * \param *C third plane vector
    726  * \return scaling parameter for this vector
    727  */
    728 double Vector::CutsPlaneAt(const Vector * const A, const Vector * const B, const Vector * const C) const
    729 {
    730 //  Log() << Verbose(3) << "For comparison: ";
    731 //  Log() << Verbose(0) << "A " << A->Projection(this) << "\t";
    732 //  Log() << Verbose(0) << "B " << B->Projection(this) << "\t";
    733 //  Log() << Verbose(0) << "C " << C->Projection(this) << "\t";
    734 //  Log() << Verbose(0) << endl;
    735   return A->ScalarProduct(this);
    736 };
    737 
    738 
    739709/** Adds vector \a *y componentwise.
    740710 * \param *y vector
    741711 */
    742 void Vector::AddVector(const Vector * const y)
    743 {
    744   for (int i=NDIM;i--;)
    745     this->x[i] += y->x[i];
     712void Vector::AddVector(const Vector &y)
     713{
     714  for (int i=NDIM;i--;)
     715    this->x[i] += y[i];
    746716}
    747717
     
    749719 * \param *y vector
    750720 */
    751 void Vector::SubtractVector(const Vector * const y)
    752 {
    753   for (int i=NDIM;i--;)
    754     this->x[i] -= y->x[i];
    755 }
    756 
    757 /** Copy vector \a *y componentwise.
    758  * \param *y vector
    759  */
    760 void Vector::CopyVector(const Vector * const y)
    761 {
    762   // check for self assignment
    763   if(y!=this){
    764     for (int i=NDIM;i--;)
    765       this->x[i] = y->x[i];
    766   }
     721void Vector::SubtractVector(const Vector &y)
     722{
     723  for (int i=NDIM;i--;)
     724    this->x[i] -= y[i];
    767725}
    768726
     
    964922bool Vector::IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const
    965923{
    966   Vector a;
    967   a.CopyVector(this);
    968   a.SubtractVector(&offset);
     924  Vector a = (*this) - offset;
    969925  a.InverseMatrixMultiplication(parallelepiped);
    970926  bool isInside = true;
  • src/vector.hpp

    r72e7fa r273382  
    3333  virtual ~Vector();
    3434
    35   virtual double Distance(const Vector * const y) const;
    36   virtual double DistanceSquared(const Vector * const y) const;
    37   virtual double DistanceToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const;
    38   virtual double PeriodicDistance(const Vector * const y, const double * const cell_size) const;
    39   virtual double PeriodicDistanceSquared(const Vector * const y, const double * const cell_size) const;
    40   virtual double ScalarProduct(const Vector * const y) const;
     35  virtual double Distance(const Vector &y) const;
     36  virtual double DistanceSquared(const Vector &y) const;
     37  virtual double DistanceToPlane(const Vector &PlaneNormal, const Vector &PlaneOffset) const;
     38  virtual double PeriodicDistance(const Vector &y, const double * const cell_size) const;
     39  virtual double PeriodicDistanceSquared(const Vector &y, const double * const cell_size) const;
     40  virtual double ScalarProduct(const Vector &y) const;
    4141  virtual double Norm() const;
    4242  virtual double NormSquared() const;
    43   virtual double Angle(const Vector * const y) const;
     43  virtual double Angle(const Vector &y) const;
    4444  virtual bool IsZero() const;
    4545  virtual bool IsOne() const;
    46   virtual bool IsNormalTo(const Vector * const normal) const;
    47   virtual bool IsEqualTo(const Vector * const a) const;
     46  virtual bool IsNormalTo(const Vector &normal) const;
     47  virtual bool IsEqualTo(const Vector &a) const;
    4848
    49   virtual void AddVector(const Vector * const y);
    50   virtual void SubtractVector(const Vector * const y);
    51   virtual void CopyVector(const Vector * const y);
     49  virtual void AddVector(const Vector &y);
     50  virtual void SubtractVector(const Vector &y);
    5251  virtual void CopyVector(const Vector &y);
    53   virtual void VectorProduct(const Vector * const y);
    54   virtual void ProjectOntoPlane(const Vector * const y);
    55   virtual void ProjectIt(const Vector * const y);
    56   virtual Vector Projection(const Vector * const y) const;
     52  virtual void VectorProduct(const Vector &y);
     53  virtual void ProjectOntoPlane(const Vector &y);
     54  virtual void ProjectIt(const Vector &y);
     55  virtual Vector Projection(const Vector &y) const;
    5756  virtual void Zero();
    5857  virtual void One(const double one);
    5958  virtual void Init(const double x1, const double x2, const double x3);
    6059  virtual void Normalize();
    61   virtual void Translate(const Vector * const x);
    62   virtual void Mirror(const Vector * const x);
     60  virtual void Translate(const Vector &x);
     61  virtual void Mirror(const Vector &x);
    6362  virtual void Scale(const double ** const factor);
    6463  virtual void Scale(const double * const factor);
     
    6766  virtual bool InverseMatrixMultiplication(const double * const M);
    6867  virtual void KeepPeriodic(const double * const matrix);
    69   virtual void LinearCombinationOfVectors(const Vector * const x1, const Vector * const x2, const Vector * const x3, const double * const factors);
    70   virtual double CutsPlaneAt(const Vector * const A, const Vector * const B, const Vector * const C) const;
    71   virtual bool GetOneNormalVector(const Vector * const x1);
     68  virtual void LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors);
     69  virtual bool GetOneNormalVector(const Vector &x1);
    7270  virtual bool MakeNormalTo(const Vector &y1);
    7371  //bool SolveSystem(Vector * x1, Vector * x2, Vector * y, const double alpha, const double beta, const double c);
  • src/vector_ops.cpp

    r72e7fa r273382  
    121121  // normalise this vector with respect to axis
    122122  a.CopyVector(vec);
    123   a.ProjectOntoPlane(&axis);
     123  a.ProjectOntoPlane(axis);
    124124  // construct normal vector
    125125  try {
     
    135135  y.Scale(sin(alpha));
    136136  a.Scale(cos(alpha));
    137   res = vec.Projection(&axis);
     137  res = vec.Projection(axis);
    138138  // add scaled normal vector onto this vector
    139   res.AddVector(&y);
     139  res += y;
    140140  // add part in axis direction
    141   res.AddVector(&a);
     141  res += a;
    142142  return res;
    143143};
     
    197197  Vector parallel;
    198198  double factor = 0.;
    199   if (fabs(a.ScalarProduct(&b)*a.ScalarProduct(&b)/a.NormSquared()/b.NormSquared() - 1.) < MYEPSILON) {
     199  if (fabs(a.ScalarProduct(b)*a.ScalarProduct(b)/a.NormSquared()/b.NormSquared() - 1.) < MYEPSILON) {
    200200    parallel = Line1a - Line2a;
    201     factor = parallel.ScalarProduct(&a)/a.Norm();
     201    factor = parallel.ScalarProduct(a)/a.Norm();
    202202    if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    203203      res = Line2a;
     
    206206    } else {
    207207      parallel = Line1a - Line2b;
    208       factor = parallel.ScalarProduct(&a)/a.Norm();
     208      factor = parallel.ScalarProduct(a)/a.Norm();
    209209      if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    210210        res = Line2b;
     
    221221  double s;
    222222  Vector temp1, temp2;
    223   temp1.CopyVector(&c);
    224   temp1.VectorProduct(&b);
    225   temp2.CopyVector(&a);
    226   temp2.VectorProduct(&b);
     223  temp1 = c;
     224  temp1.VectorProduct(b);
     225  temp2 = a;
     226  temp2.VectorProduct(b);
    227227  Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl;
    228228  if (fabs(temp2.NormSquared()) > MYEPSILON)
    229     s = temp1.ScalarProduct(&temp2)/temp2.NormSquared();
     229    s = temp1.ScalarProduct(temp2)/temp2.NormSquared();
    230230  else
    231231    s = 0.;
    232   Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;
     232  Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;
    233233
    234234  // construct intersection
Note: See TracChangeset for help on using the changeset viewer.