#include <planar_intp.h>
This is an analog of 1-d linear interpolation for two dimensions. For a set of data , the values of
are predicted given a value of x and y. In contrast to twod_intp, the data need not be presented in a grid. This is done by finding the plane that goes through three closest points in the data set. Distances are determined with
where and
.
This procedure will fail if the three closest points are co-linear, and interp() will then call O2SCL_ERR() and return zero.
There is no caching so the numeric values of the data may be freely changed between calls to interp().
The vector and matrix types can be any types which have suitably defined functions operator
[].
For example, with 10 points in the x-y plane with and
, the planes are demarcated according to
in_planar_intp.png
den
with zero, add the option of comparing it with a small number. Definition at line 77 of file planar_intp.h.
Public Member Functions | |
int | set_data (size_t n_points, vec_t &x, vec_t &y, size_t n_dat, mat_t &dat) |
Initialize the data for the planar interpolation. | |
int | interp (double x, double y, vec_t &ip) |
Perform the planar interpolation. | |
int | interp (double x, double y, vec_t &ip, size_t &i1, double &x1, double &y1, size_t &i2, double &x2, double &y2, size_t &i3, double &x3, double &y3) |
Planar interpolation returning the closest points. | |
Protected Member Functions | |
int | swap (size_t &i1, double &c1, size_t &i2, double &c2) |
Swap points 1 and 2. | |
Protected Attributes | |
size_t | np |
The number of points. | |
size_t | nd |
The number of functions. | |
vec_t * | ux |
The x-values. | |
vec_t * | uy |
The y-values. | |
mat_t * | udat |
The data. | |
bool | data_set |
True if the data has been specified. |
int interp | ( | double | x, | |
double | y, | |||
vec_t & | ip, | |||
size_t & | i1, | |||
double & | x1, | |||
double & | y1, | |||
size_t & | i2, | |||
double & | x2, | |||
double & | y2, | |||
size_t & | i3, | |||
double & | x3, | |||
double & | y3 | |||
) | [inline] |
Planar interpolation returning the closest points.
This function interpolates x
and y
into the data returning ip
. It also returns the three closest x- and y-values used for computing the plane.
It is assumed that ip
is properly allocated beforehand.
Put in initial points
Sort initial points
Definition at line 121 of file planar_intp.h.
int interp | ( | double | x, | |
double | y, | |||
vec_t & | ip | |||
) | [inline] |
Perform the planar interpolation.
It is assumed that ip
is properly allocated beforehand.
Definition at line 106 of file planar_intp.h.
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page