Interpolator::FourNearestNeighboursMeanInterpolator2D Class Reference

This class performs a 4 nearest neighbour mean interpolation. More...

#include <FourNearestNeighboursMeanInterpolator2D.h>

Inherits Interpolator::NearestNeighbourInterpolator2D.

Inheritance diagram for Interpolator::FourNearestNeighboursMeanInterpolator2D:

Inheritance graph
[legend]
Collaboration diagram for Interpolator::FourNearestNeighboursMeanInterpolator2D:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FourNearestNeighboursMeanInterpolator2D ()
 Default constructor.
virtual ~FourNearestNeighboursMeanInterpolator2D ()
 Destructor.
 FourNearestNeighboursMeanInterpolator2D (std::string sName, std::string sDescription, InterpolationData2D *mInterpolationData)
 This constructor requires 3 parameters :
  • the name of the interpolator
  • the description of the interpolator
  • the interpolation data.

virtual double getInterpolatedValue (double dXValue, double dYValue)
 Return the interpolated value for the wanted couple (dXValue,dYvalue).

Private Member Functions

virtual double compute (double dXValue, double dYValue)
 Return the interpolated value for the wanted couple (dXValue,dYvalue).

Detailed Description

This class performs a 4 nearest neighbour mean interpolation.

Definition at line 17 of file FourNearestNeighboursMeanInterpolator2D.h.


Constructor & Destructor Documentation

Interpolator::FourNearestNeighboursMeanInterpolator2D::FourNearestNeighboursMeanInterpolator2D  ) 
 

Default constructor.

Definition at line 16 of file FourNearestNeighboursMeanInterpolator2D.cpp.

00017 {
00018 
00019 }

Interpolator::FourNearestNeighboursMeanInterpolator2D::~FourNearestNeighboursMeanInterpolator2D  )  [virtual]
 

Destructor.

Definition at line 22 of file FourNearestNeighboursMeanInterpolator2D.cpp.

00023 {
00024 
00025 }

Interpolator::FourNearestNeighboursMeanInterpolator2D::FourNearestNeighboursMeanInterpolator2D std::string  sName,
std::string  sDescription,
InterpolationData2D mInterpolationData
 

This constructor requires 3 parameters :

  • the name of the interpolator
  • the description of the interpolator
  • the interpolation data.

Definition at line 31 of file FourNearestNeighboursMeanInterpolator2D.cpp.

00034                                                                                  : 
00035 NearestNeighbourInterpolator2D(sName,sDescription,"4 Nearest Neighbours Mean",mInterpolationData)
00036 {
00037 }


Member Function Documentation

double Interpolator::FourNearestNeighboursMeanInterpolator2D::compute double  dXValue,
double  dYValue
[private, virtual]
 

Return the interpolated value for the wanted couple (dXValue,dYvalue).

Reimplemented from Interpolator::NearestNeighbourInterpolator2D.

Definition at line 47 of file FourNearestNeighboursMeanInterpolator2D.cpp.

References Interpolator::Interpolator2D::_mInterpolationData, Interpolator::Interpolator::_verb, Interpolator::Interpolator2D::findXIndex(), Interpolator::Interpolator2D::findYIndex(), Interpolator::InterpolationData2D::getNbXData(), Interpolator::InterpolationData2D::getNbYData(), and Interpolator::InterpolationData2D::getZValue().

Referenced by getInterpolatedValue().

00048 {
00049         //Faire algo quicksort pour plus de rapidité et faire les verifs sur les index calculés et sur le z si possible 
00050         int iXIndex = findXIndex(dXValue);
00051         int iYIndex = findYIndex(dYValue);
00052         
00053         double z,z1,z2,z3,z4,x1,x3,y1,y2;
00054 
00055         //The 4 cases where the indexes for X and Y are outside the arrays (four corners cases)
00056         if ((iXIndex >= _mInterpolationData->getNbXData()) && (iYIndex >= _mInterpolationData->getNbYData()))
00057         {
00058                 if(Interpolator::_verb == true) cout << "case 1" << endl;
00059                 z = _mInterpolationData->getZValue(iXIndex-1,iYIndex-1);
00060         }
00061         
00062         else if ((iXIndex == -1) && (iYIndex == -1))
00063         {       
00064                 if(Interpolator::_verb == true) cout << "case 2" << endl;
00065                 z = _mInterpolationData->getZValue(0,0);
00066         }
00067 
00068         else if ((iXIndex == -1) && (iYIndex >= _mInterpolationData->getNbYData()))
00069         {
00070                 if(Interpolator::_verb == true) cout << "case 3" << endl;
00071                 z = _mInterpolationData->getZValue(0,iYIndex-1);
00072         }
00073 
00074         else if ((iXIndex >= _mInterpolationData->getNbXData()) && (iYIndex == -1))
00075         {
00076                 if(Interpolator::_verb == true) cout << "case 4" << endl;
00077                 z = _mInterpolationData->getZValue(iXIndex-1,0);
00078         }
00079 
00080 
00081         //The case when the X index is outside (bigger than the last index) of the array
00082         else if (iXIndex >= _mInterpolationData->getNbXData()) 
00083         {
00084                 if(Interpolator::_verb == true) cout << "case 5" << endl;
00085                  x1     =  _mInterpolationData->getXValue(iXIndex-1);
00086                  
00087                  y1 =  _mInterpolationData->getYValue(iYIndex);
00088                  y2 =  _mInterpolationData->getYValue(iYIndex+1);
00089 
00090                  z1     = _mInterpolationData->getZValue(iXIndex-1,iYIndex);
00091                  z2     = _mInterpolationData->getZValue(iXIndex-1,iYIndex+1);          
00092                 
00093                 if(Interpolator::_verb == true) cout << "(iX-1="         << iXIndex-1   << "|iY="   << iYIndex   << ")     --> (" << x1  << "," << y1  << "," << z1  << ")" << endl;
00094                 if(Interpolator::_verb == true) cout << "(iX=" << iXIndex << "|iY+1=" << iYIndex+1 << ") --> (" << x1 << "," << y2 << "," << z2  << ")" << endl;
00095 
00096                 double zMean = (z1 + z2)/2.0;
00097                  
00098                  z = zMean;
00099         }
00100         
00101         //The case when the X index is outside (lower than the first index) of the array
00102         else if (iXIndex == -1) 
00103         {
00104                 if(Interpolator::_verb == true) cout << "case 6" << endl;
00105                  x1     =  _mInterpolationData->getXValue(iXIndex+1);
00106                  
00107                  y1 =  _mInterpolationData->getYValue(iYIndex);
00108                  y2 =  _mInterpolationData->getYValue(iYIndex+1);
00109 
00110                  z1     = _mInterpolationData->getZValue(iXIndex+1,iYIndex);
00111                  z2     = _mInterpolationData->getZValue(iXIndex+1,iYIndex+1);          
00112                 
00113                 if(Interpolator::_verb == true) cout << "(iX="   << iXIndex   << "|iY="   << iYIndex   << ")     --> (" << x1  << "," << y1  << "," << z1  << ")" << endl;
00114                 if(Interpolator::_verb == true) cout << "(iX+1=" << iXIndex+1 << "|iY+1=" << iYIndex+1 << ") --> (" << x1 << "," << y2 << "," << z2  << ")" << endl;
00115 
00116                 double zMean = (z1 + z2)/2.0;
00117                  
00118                  z = zMean;
00119         }
00120 
00121         //The case when the Y index is outside (bigger than the last index) of the array
00122         else if (iYIndex >= _mInterpolationData->getNbYData())
00123         {
00124                 if(Interpolator::_verb == true) cout << "case 7" << endl;
00125                  y1 =  _mInterpolationData->getYValue(iYIndex-1);
00126 
00127                  z1     = _mInterpolationData->getZValue(iXIndex,iYIndex-1);
00128                  z3     = _mInterpolationData->getZValue(iXIndex+1,iYIndex-1);          
00129         
00130                  x1     =  _mInterpolationData->getXValue(iXIndex);
00131                  x3     =  _mInterpolationData->getXValue(iXIndex+1);
00132                 
00133                 if(Interpolator::_verb == true) cout << "(iX="   << iXIndex   << "|iY-1="   << iYIndex-1   << ")     --> (" << x1  << "," << y1  << "," << z1  << ")" << endl;
00134                 if(Interpolator::_verb == true) cout << "(iX+1=" << iXIndex+1 << "|iY=" << iYIndex << ") --> (" << x3 << "," << y1 << "," << z3  << ")" << endl;
00135 
00136                 double zMean = (z1 + z3)/2.0;
00137                  
00138                  z = zMean;
00139         }
00140         
00141                 
00142         //The case when the Y index is outside (lower than the first index) of the array
00143         else if (iYIndex == -1 )
00144         {
00145                 if(Interpolator::_verb == true) cout << "case 8" << endl;
00146                  y1 =  _mInterpolationData->getYValue(iYIndex+1);
00147 
00148                  z1     = _mInterpolationData->getZValue(iXIndex,iYIndex+1);
00149                  z3     = _mInterpolationData->getZValue(iXIndex+1,iYIndex+1);          
00150         
00151                  x1     =  _mInterpolationData->getXValue(iXIndex);
00152                  x3     =  _mInterpolationData->getXValue(iXIndex+1);
00153                 
00154                 if(Interpolator::_verb == true) cout << "(iX="   << iXIndex   << "|iY="   << iYIndex   << ")     --> (" << x1  << "," << y1  << "," << z1  << ")" << endl;
00155                 if(Interpolator::_verb == true) cout << "(iX+1=" << iXIndex+1 << "|iY+1=" << iYIndex+1 << ") --> (" << x3 << "," << y1 << "," << z3  << ")" << endl;
00156 
00157 
00158                 double zMean = (z1 + z3)/2.0;
00159                  
00160                  z = zMean;
00161         }
00162 
00163 
00164         //Normal case
00165         else 
00166         {
00167                 if(Interpolator::_verb == true) cout << "case 9" << endl;
00168                  z1     = _mInterpolationData->getZValue(iXIndex,iYIndex);
00169                  z2     = _mInterpolationData->getZValue(iXIndex,iYIndex+1);    
00170                  z3     = _mInterpolationData->getZValue(iXIndex+1,iYIndex+1);  
00171                  z4     = _mInterpolationData->getZValue(iXIndex+1,iYIndex);    
00172                 
00173                  x1     =  _mInterpolationData->getXValue(iXIndex);
00174                  x3     =  _mInterpolationData->getXValue(iXIndex+1);
00175                  y1     =  _mInterpolationData->getYValue(iYIndex);
00176                  y2     =  _mInterpolationData->getYValue(iYIndex+1);   
00177                  
00178                 if(Interpolator::_verb == true) cout << "(iX="   << iXIndex   << "|iY="   << iYIndex   << ")     --> (" << x1  << "," << y1  << "," << z1  << ")" << endl;
00179                 if(Interpolator::_verb == true) cout << "(iX+1=" << iXIndex+1 << "|iY="   << iYIndex   << ")   --> (" << x3 << "," << y1  << "," << z2  << ")" << endl;
00180                 if(Interpolator::_verb == true) cout << "(iX+1=" << iXIndex+1 << "|iY+1=" << iYIndex+1 << ") --> (" << x3 << "," << y2 << "," << z3  << ")" << endl;
00181                 if(Interpolator::_verb == true) cout << "(iX="   << iXIndex << "|iY+1="   << iYIndex+1 << ")   --> (" << x1  << "," << y2 << "," << z4  << ")" << endl;
00182 
00183                 double zMean = (z1 + z2 + z3 + z4)/4.0;
00184                 z = zMean;
00185         }
00186         if(Interpolator::_verb == true) cout << _mInterpolationData->getZName() << "=f(" << _mInterpolationData->getXName() << "," << _mInterpolationData->getYName() << ")=f("<< dXValue << "," << dYValue<< ")=" <<  z << endl;
00187         //if(Interpolator::_verb == true) cout << "z=f("<< dXValue << "," << dYValue<< ")=" <<  z << endl;
00188         return z;
00189 }

Here is the call graph for this function:

double Interpolator::FourNearestNeighboursMeanInterpolator2D::getInterpolatedValue double  dXValue,
double  dYValue
[virtual]
 

Return the interpolated value for the wanted couple (dXValue,dYvalue).

Reimplemented from Interpolator::NearestNeighbourInterpolator2D.

Definition at line 40 of file FourNearestNeighboursMeanInterpolator2D.cpp.

References compute().

00041 {
00042         double z = compute(dXValue,dYValue);
00043         return z;
00044 }

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Tue Apr 14 09:51:12 2009 for Interpolator Library by  doxygen 1.4.5