planar_intp Class Template Reference

#include <planar_intp.h>


Detailed Description

template<class vec_t, class mat_t>
class planar_intp< vec_t, mat_t >

Interpolate among two independent variables with planes.

This is an analog of 1-d linear interpolation for two dimensions. For a set of data ${x_i,y_i,f_{j,i}}$, values for $f_j$ 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.

This procedure will fail if the three closest points are co-linear, and interp() will then call set_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[].

Idea for future:
Rewrite so that it never fails unless all the points in the data set lie on a line. This would probably demand sorting all of the points by distance from desired location.

Definition at line 60 of file planar_intp.h.


Public Member Functions

 planar_intp ()
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, double &x1, double &y1, double &x2, double &y2, double &x3, double &y3)
 Planar interpolation returning the closest points.

Protected Member Functions

int swap (int &i1, double &c1, int &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.

Member Function Documentation

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 94 of file planar_intp.h.

int interp ( double  x,
double  y,
vec_t &  ip,
double &  x1,
double &  y1,
double &  x2,
double &  y2,
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 108 of file planar_intp.h.


The documentation for this class was generated from the following file:
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.