Ignore:
Timestamp:
May 18, 2016, 10:03:09 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Children:
c805f7
Parents:
706d48
git-author:
Frederik Heber <heber@…> (03/10/16 14:52:28)
git-committer:
Frederik Heber <heber@…> (05/18/16 22:03:09)
Message:

Moved getNearestLowerGridPoint and ..Higher:: from SamplingGrid to SamplingGridProperties.

  • we only use functions from ..Properties anyway.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/SetValues/SamplingGrid.cpp

    r706d48 rc9b843  
    272272    return 0.;
    273273}
    274 
    275 double SamplingGrid::getNearestLowerGridPoint(
    276     const double value, const size_t axis) const
    277 {
    278   const double length = getTotalLengthPerAxis(axis);
    279   if ((fabs(length) < std::numeric_limits<double>::epsilon()) || (getGridPointsPerAxis() == 0))
    280     return begin[axis];
    281   if ((value - end[axis]) > -std::numeric_limits<double>::epsilon()*1.e4)
    282     return end[axis];
    283   const double offset = value - begin[axis];
    284   if (offset < std::numeric_limits<double>::epsilon()*1.e4)
    285     return begin[axis];
    286   // modify value a little if value actually has been on a grid point but
    287   // perturbed by numerical rounding: here up, as we always go lower
    288   const double factor =
    289       floor((double)getGridPointsPerAxis()*(offset/length)
    290           +std::numeric_limits<double>::epsilon()*1.e4);
    291   return begin[axis]+factor*getDeltaPerAxis(axis);
    292 }
    293 
    294 double SamplingGrid::getNearestHigherGridPoint(
    295     const double value, const size_t axis) const
    296 {
    297   const double length = getTotalLengthPerAxis(axis);
    298   if ((fabs(length) < std::numeric_limits<double>::epsilon()) || (getGridPointsPerAxis() == 0))
    299     return end[axis];
    300   if ((value - end[axis]) > -std::numeric_limits<double>::epsilon()*1.e4)
    301     return end[axis];
    302   const double offset = value - begin[axis];
    303   if (offset < std::numeric_limits<double>::epsilon()*1.e4)
    304     return begin[axis];
    305   // modify value a little if value actually has been on a grid point but
    306   // perturbed by numerical rounding: here down, as we always go higher
    307   const double factor =
    308       ceil((double)getGridPointsPerAxis()*(offset/length)
    309           -std::numeric_limits<double>::epsilon()*1.e4);
    310   return begin[axis]+factor*getDeltaPerAxis(axis);
    311 }
    312 
    313274void SamplingGrid::setWindowSize(
    314275    const double _begin_window[3],
Note: See TracChangeset for help on using the changeset viewer.