Ignore:
Timestamp:
Apr 7, 2010, 3:45:38 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
0f55b2
Parents:
770138
Message:

Made data internal data-structure of vector class private

  • Replaced occurences of access to internals with operator
  • moved Vector-class into LinAlg-Module
  • Reworked Vector to allow clean modularization
  • Added Plane class to describe arbitrary planes in 3d space
File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/boundary.cpp

    r770138 r71910a  
    1818#include "tesselation.hpp"
    1919#include "tesselationhelpers.hpp"
     20#include "Plane.hpp"
    2021
    2122#include<gsl/gsl_poly.h>
     
    8081              DistanceVector.SubtractVector(&Neighbour->second.second->x);
    8182              do { // seek for neighbour pair where it flips
    82                   OldComponent = DistanceVector.x[Othercomponent];
     83                  OldComponent = DistanceVector[Othercomponent];
    8384                  Neighbour++;
    8485                  if (Neighbour == BoundaryPoints[axis].end()) // make it wrap around
     
    8889                  //Log() << Verbose(2) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl;
    8990                } while ((runner != Neighbour) && (fabs(OldComponent / fabs(
    90                   OldComponent) - DistanceVector.x[Othercomponent] / fabs(
    91                   DistanceVector.x[Othercomponent])) < MYEPSILON)); // as long as sign does not flip
     91                  OldComponent) - DistanceVector[Othercomponent] / fabs(
     92                  DistanceVector[Othercomponent])) < MYEPSILON)); // as long as sign does not flip
    9293              if (runner != Neighbour) {
    9394                  OtherNeighbour = Neighbour;
     
    102103                  //Log() << Verbose(1) << "OtherComponents to Neighbour and OtherNeighbour are " << DistanceVector.x[Othercomponent] << " and " << OtherVector.x[Othercomponent] << "." << endl;
    103104                  // do linear interpolation between points (is exact) to extract exact intersection between Neighbour and OtherNeighbour
    104                   w1 = fabs(OtherVector.x[Othercomponent]);
    105                   w2 = fabs(DistanceVector.x[Othercomponent]);
    106                   tmp = fabs((w1 * DistanceVector.x[component] + w2
    107                       * OtherVector.x[component]) / (w1 + w2));
     105                  w1 = fabs(OtherVector[Othercomponent]);
     106                  w2 = fabs(DistanceVector[Othercomponent]);
     107                  tmp = fabs((w1 * DistanceVector[component] + w2
     108                      * OtherVector[component]) / (w1 + w2));
    108109                  // mark if it has greater diameter
    109110                  //Log() << Verbose(1) << "Comparing current greatest " << GreatestDiameter[component] << " to new " << tmp << "." << endl;
     
    159160    AngleReferenceVector.Zero();
    160161    AngleReferenceNormalVector.Zero();
    161     AxisVector.x[axis] = 1.;
    162     AngleReferenceVector.x[(axis + 1) % NDIM] = 1.;
    163     AngleReferenceNormalVector.x[(axis + 2) % NDIM] = 1.;
     162    AxisVector[axis] = 1.;
     163    AngleReferenceVector[(axis + 1) % NDIM] = 1.;
     164    AngleReferenceNormalVector[(axis + 2) % NDIM] = 1.;
    164165
    165166    Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl;
     
    636637      const double c = sqrt(runner->second->endpoints[2]->node->node->DistanceSquared(runner->second->endpoints[1]->node->node));
    637638      const double G = sqrt(((a + b + c) * (a + b + c) - 2 * (a * a + b * b + c * c)) / 16.); // area of tesselated triangle
    638       x.MakeNormalVector(runner->second->endpoints[0]->node->node, runner->second->endpoints[1]->node->node, runner->second->endpoints[2]->node->node);
     639      x = Plane(*(runner->second->endpoints[0]->node->node),
     640                *(runner->second->endpoints[1]->node->node),
     641                *(runner->second->endpoints[2]->node->node)).getNormal();
    639642      x.Scale(runner->second->endpoints[1]->node->node->ScalarProduct(&x));
    640643      const double h = x.Norm(); // distance of CoG to triangle
     
    751754    Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl;
    752755    for (int i = 0; i < NDIM; i++)
    753       BoxLengths.x[i] = GreatestDiameter[i];
     756      BoxLengths[i] = GreatestDiameter[i];
    754757    mol->CenterEdge(&BoxLengths);
    755758  } else {
    756     BoxLengths.x[0] = (repetition[0] * GreatestDiameter[0] + repetition[1] * GreatestDiameter[1] + repetition[2] * GreatestDiameter[2]);
    757     BoxLengths.x[1] = (repetition[0] * repetition[1] * GreatestDiameter[0] * GreatestDiameter[1] + repetition[0] * repetition[2] * GreatestDiameter[0] * GreatestDiameter[2] + repetition[1] * repetition[2] * GreatestDiameter[1] * GreatestDiameter[2]);
    758     BoxLengths.x[2] = minimumvolume - cellvolume;
     759    BoxLengths[0] = (repetition[0] * GreatestDiameter[0] + repetition[1] * GreatestDiameter[1] + repetition[2] * GreatestDiameter[2]);
     760    BoxLengths[1] = (repetition[0] * repetition[1] * GreatestDiameter[0] * GreatestDiameter[1] + repetition[0] * repetition[2] * GreatestDiameter[0] * GreatestDiameter[2] + repetition[1] * repetition[2] * GreatestDiameter[1] * GreatestDiameter[2]);
     761    BoxLengths[2] = minimumvolume - cellvolume;
    759762    double x0 = 0.;
    760763    double x1 = 0.;
    761764    double x2 = 0.;
    762     if (gsl_poly_solve_cubic(BoxLengths.x[0], BoxLengths.x[1], BoxLengths.x[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return
     765    if (gsl_poly_solve_cubic(BoxLengths[0], BoxLengths[1], BoxLengths[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return
    763766      Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl;
    764767    else {
     
    769772    cellvolume = 1.;
    770773    for (int i = 0; i < NDIM; i++) {
    771       BoxLengths.x[i] = repetition[i] * (x0 + GreatestDiameter[i]);
    772       cellvolume *= BoxLengths.x[i];
     774      BoxLengths[i] = repetition[i] * (x0 + GreatestDiameter[i]);
     775      cellvolume *= BoxLengths[i];
    773776    }
    774777
     
    780783  // update Box of atoms by boundary
    781784  mol->SetBoxDimension(&BoxLengths);
    782   Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     785  Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths[0] << " and " << BoxLengths[1] << " and " << BoxLengths[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
    783786};
    784787
     
    839842  FillerDistance.InverseMatrixMultiplication(M);
    840843  for(int i=0;i<NDIM;i++)
    841     N[i] = (int) ceil(1./FillerDistance.x[i]);
     844    N[i] = static_cast<int>(ceil(1./FillerDistance[i]));
    842845  Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl;
    843846
     
    880883          // create molecule random translation vector ...
    881884          for (int i=0;i<NDIM;i++)
    882             FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
     885            FillerTranslations[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
    883886          Log() << Verbose(2) << "INFO: Translating this filler by " << FillerTranslations << "." << endl;
    884887
     
    892895            // create atomic random translation vector ...
    893896            for (int i=0;i<NDIM;i++)
    894               AtomTranslations.x[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.);
     897              AtomTranslations[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.);
    895898
    896899            // ... and rotation matrix
Note: See TracChangeset for help on using the changeset viewer.