![]() |
Grid Interpolation
|
Main interpolation class. More...
#include <gridInterp.h>

Public Member Functions | |
| interp () | |
| double | interpolate (double x, double y=0, double z=0) const |
| This is the method to call to do the interpolation. More... | |
| void | setAxis (int idim, std::vector< double > &x_in) |
| Set the Axis object. More... | |
| void | setAxis (int idim, double origin_in, double dx_in, int n) |
| Set the Axis object when the ticks are evenly spaced. More... | |
| void | setMethod (METHOD method_in) |
| sets the method More... | |
| void | getDataFromFile (std::string filename) |
| Get the Data From File object. More... | |
| void | setValues (int l, int r, int c, double v_in) |
| Set the values of the iterpolation. More... | |
| void | setElevation (int l, int r, int c, double v_in) |
| void | reset () |
| Resets the class to the empty state. More... | |
Private Member Functions | |
| double | interp1D (double x) const |
| The interpolate method will call this when dim is 1. More... | |
| double | interp2D (double x, double y) const |
| The interpolate method will call this when dim is 2. More... | |
| double | interp3D (double x, double y, double z) const |
| The interpolate method will call this when dim is 3. More... | |
Private Attributes | |
| std::vector< axis > | a |
| A vector of axis objects. More... | |
| GridValues | v |
| The container for the values that are used in the interpolation. More... | |
| GridValues | elev |
| In 3D this holds the layer elevation information. More... | |
| METHOD | method = METHOD::INVALID_METHOD |
| This holds the interpolation method. More... | |
| double | translateX = 0.0 |
| double | translateY = 0.0 |
| double | rotate = 0.0 |
| double | cosTH |
| double | sinTH |
| bool | bPreTransform = false |
Main interpolation class.
This is a templated class where the dimention is the template parameter
| dim | is the dimension of the interpolation |
| GRID_INTERP::interp< dim >::interp | ( | ) |
| void GRID_INTERP::interp< dim >::getDataFromFile | ( | std::string | filename | ) |
Get the Data From File object.
The data must be in the following format
1st line:
METHOD NX NY NZ
where method is one of the GRID_INTERP::METHOD methods
Nx, NY, NZ are the number of x coordinates (columns), y coordinates (rows) and z coordinates (layers).
In case of 1 or 2D only NX or NX and NY are needed.
2nd line:
axisFileX axisFileY axisFileZ
This is a list of files that define the options for the X Y and Z axis.
The data format for these files is defined in GRID_INTERP::axis::dataFromFile
Next lines:
For 1D repeat NX lines the values.
For 2D repeat NY lines where each line containts NX values
For 3D repeat NZ times the NY x NX data.
Note that the number of values must be consistent with the number of axis values depending the selected MODE.
| filename |
|
private |
The interpolate method will call this when dim is 1.
|
private |
The interpolate method will call this when dim is 2.
|
private |
The interpolate method will call this when dim is 3.
| double GRID_INTERP::interp< dim >::interpolate | ( | double | x, |
| double | y = 0, |
||
| double | z = 0 |
||
| ) | const |
This is the method to call to do the interpolation.
| x | is the x coordinate |
| y | is the y coordinate. It is used only in 2D or 3D |
| z | is the z coordinate. It is used only in 3D |
| void GRID_INTERP::interp< dim >::reset | ( | ) |
Resets the class to the empty state.
| void GRID_INTERP::interp< dim >::setAxis | ( | int | idim, |
| std::vector< double > & | x_in | ||
| ) |
Set the Axis object.
This method is used when the ticks are not evenly spaced
| idim | is the index of the dimension. For the x, y and z axis this is 0, 1 and 2 repsectively |
| x_in | the vector with the coordinates of the ticks |
| void GRID_INTERP::interp< dim >::setAxis | ( | int | idim, |
| double | origin_in, | ||
| double | dx_in, | ||
| int | n | ||
| ) |
Set the Axis object when the ticks are evenly spaced.
| idim | is the dimension index of the axis to set |
| origin_in | is the starting point of the idim axis |
| dx_in | is the space between the ticks |
| n | the number of ticks in the idim axis |
| void GRID_INTERP::interp< dim >::setElevation | ( | int | l, |
| int | r, | ||
| int | c, | ||
| double | v_in | ||
| ) |
Similarly to the method interp::setValues this sets the layer elevation when the interpolation is 3D and GRID_INTERP::TYPE::LAYER. The same rules also apply.
| void GRID_INTERP::interp< dim >::setMethod | ( | METHOD | method_in | ) |
sets the method
Sets the interpolation Method of the interp class
| method_in | is the interpolation method |
| void GRID_INTERP::interp< dim >::setValues | ( | int | l, |
| int | r, | ||
| int | c, | ||
| double | v_in | ||
| ) |
Set the values of the iterpolation.
When setting these values using either the interp::getDataFromFile or this method, l, r, c correspond to the index of the x y z direction. Typically, in grid data the layer or row 1 is the top layer or the first row in a martix respectivelly. However the data in the code are using the cartesian coordinate system where the origin is the l = 0, r = 0, c = 0. The top layer correspond to the last index of the z axis.
| l | layer or the index in the z coordinate |
| r | row or the index in the y coordinate |
| c | column or the index in the x coordinate |
| v_in | The value that correspons to (c,r,l) |
|
private |
A vector of axis objects.
|
private |
|
private |
|
private |
In 3D this holds the layer elevation information.
|
private |
This holds the interpolation method.
|
private |
|
private |
|
private |
A utility method which is used in MODE::CELL and METHOD::LINEAR Finds the correct cells to interpolate the value for the given input
|
private |
|
private |
The container for the values that are used in the interpolation.
1.8.13