Classes | Functions

Interpolate Namespace Reference

Classes

class  PolyReg1D
class  PolyReg1DWithUdf
struct  Applier2D
 specification for a 2D interpolator More...
class  LinearReg2D
 Linear 2D interpolation. More...
class  LinearReg2DWithUdf
 Linear 2D interpolation with standard undef handling. More...
class  PolyReg2D
class  PolyReg2DWithUdf
class  LinearReg3D
class  LinearReg3DWithUdf
class  PolyReg3D

Functions

template<class T >
linearReg1D (T v0, T v1, float x)
template<class T >
linearReg1DWithUdf (T v0, T v1, float x)
template<class T >
linear1D (float x0, T v0, float x1, T v1, float x)
template<class iT >
iT linear1Di (float x0, iT v0, float x1, iT v1, float x)
 Interpolate 1D regularly sampled, using a 3rd order polynome.
template<class T >
polyReg1D (T vm1, T v0, T v1, T v2, float x)
 PolyReg1D which smoothly handles undefined values.
template<class T >
polyReg1DWithUdf (T vm1, T v0, T v1, T v2, float x)
template<class T >
parabolic1D (float x0, T v0, float x1, T v1, float x2, T v2, float x)
template<class T >
poly1D (float x0, T v0, float x1, T v1, float x2, T v2, float x3, T v3, float x)
template<class T >
predictAtZero1D (T vm2, T vm1, T v1, T v2)
template<class T >
predictAtZero1D (T vm3, T vm2, T vm1, T v1, T v2, T v3)
template<class T >
linearReg2D (T v00, T v01, T v10, T v11, float x, float y)
template<class T >
linearReg2DWithUdf (T v00, T v01, T v10, T v11, float x, float y)
 Interpolate 2D regularly sampled, using a 2nd order surface.
template<class T >
polyReg2D (T vm10, T vm11, T v0m1, T v00, T v01, T v02, T v1m1, T v10, T v11, T v12, T v20, T v21, float x, float y, float xs=1)
 PolyReg2D which smoothly handles undefined values.
template<class T >
polyReg2DWithUdf (T vm10, T vm11, T v0m1, T v00, T v01, T v02, T v1m1, T v10, T v11, T v12, T v20, T v21, float x, float y)
template<class T >
linearReg3D (T v000, T v100, T v010, T v110, T v001, T v101, T v011, T v111, float x, float y, float z)
template<class T >
linearReg3DWithUdf (T v000, T v100, T v010, T v110, T v001, T v101, T v011, T v111, float x, float y, float z)
 Interpolate 3D regularly sampled, using a 3rd order surface.
template<class T >
polyReg3D (const T *const *const *v, float x, float y, float z)
 PolyReg3D which smoothly handles undefined values.
template<class T >
linearRegND (int N, const T *v, const T *pos)

Function Documentation

template<class T >
T Interpolate::linear1D ( float  x0,
v0,
float  x1,
v1,
float  x 
) [inline]

> Interpolate linearly when two points are known. Make sure these points are not at the same posistion (crash!).

template<class iT >
iT Interpolate::linear1Di ( float  x0,
iT  v0,
float  x1,
iT  v1,
float  x 
) [inline]

Interpolate 1D regularly sampled, using a 3rd order polynome.

> Same as above, use when iT is from int family

template<class T >
T Interpolate::linearReg1D ( v0,
v1,
float  x 
) [inline]

> Linear interpolation as usual.

template<class T >
T Interpolate::linearReg1DWithUdf ( v0,
v1,
float  x 
) [inline]

> Linear interpolation as usual with standard undef handling.

template<class T >
T Interpolate::linearReg2D ( v00,
v01,
v10,
v11,
float  x,
float  y 
) [inline]
template<class T >
T Interpolate::linearReg2DWithUdf ( v00,
v01,
v10,
v11,
float  x,
float  y 
) [inline]

Interpolate 2D regularly sampled, using a 2nd order surface.

Contrary to teh linear approach it does matter whether deltaX is different from deltaY. That is why you can supply an xstretch. If xstretch > 1 then the deltaX < deltaY, moreover: xstretch = deltaY / deltaX;

template<class T >
T Interpolate::linearReg3D ( v000,
v100,
v010,
v110,
v001,
v101,
v011,
v111,
float  x,
float  y,
float  z 
) [inline]
template<class T >
T Interpolate::linearReg3DWithUdf ( v000,
v100,
v010,
v110,
v001,
v101,
v011,
v111,
float  x,
float  y,
float  z 
) [inline]

Interpolate 3D regularly sampled, using a 3rd order surface.

Current implementation takes the average of the outer squares. In the parameter passing, the z is the fastest dimension.

       ..    ..       Z  Y-dir
  ..  ....  ....  ..  ^ /
  ..  ....  ....  ..  | --> X-dir
       ..    ..
  ^- From here to -^
x=-1   0      1     2
 
template<class T >
T Interpolate::linearRegND ( int  N,
const T *  v,
const T *  pos 
) [inline]

> Linear ND interpolation.

Input: Array sz=2^N values as following 4D example Arr[0] = val[0][0][0][0] Arr[1] = val[1][0][0][0] Arr[2] = val[0][1][0][0] Arr[3] = val[1][1][0][0] Arr[4] = val[0][0][1][0] Arr[5] = val[1][0][1][0] Arr[6] = val[0][1][1][0] Arr[7] = val[1][1][1][0] Arr[8] = val[0][0][0][1] Arr[9] = val[1][0][0][1] Arr[10] = val[0][1][0][1] Arr[11] = val[1][1][0][1] Arr[12] = val[0][0][1][1] Arr[13] = val[1][0][1][1] Arr[14] = val[0][1][1][1] Arr[15] = val[1][1][1][1]

Fill the vals with something like:

od_int64 sz = IntPower( 2, N ); for ( od_int64 ipt=0; ipt<sz; ipt++ ) { TypeSet<int> idxs( N, 0 ); od_int64 bits = ipt; for ( int idim=0; idim<nrdims; idim++ ) { if ( bits & 1 ) idxs[idim]++; bits >>= 1; } pts += getVals( idxs ); }

You therefore provide all the points in the (hyper)cube around the point of evaluation. The [0][0]...[0] point can be determined using 'floor', as in:

for ( int idim=0; idim<nrdims; idim++ ) { const float fidx = samplings[idim].getIndex( vals[idim] ); const int idx0 = (int)floor(fidx); pos[idim] = fidx - idx0; idx0s += idx0; }

template<class T >
T Interpolate::parabolic1D ( float  x0,
v0,
float  x1,
v1,
float  x2,
v2,
float  x 
) [inline]

> Interpolate when 3 points are known. Make sure none of the positions are the same. Will just crash 'silently'. No undefined values allowed.

template<class T >
T Interpolate::poly1D ( float  x0,
v0,
float  x1,
v1,
float  x2,
v2,
float  x3,
v3,
float  x 
) [inline]

> Interpolate when 4 points are known. Make sure none of the positions are the same. Will just crash 'silently'. No undefined values allowed.

template<class T >
T Interpolate::polyReg1D ( vm1,
v0,
v1,
v2,
float  x 
) [inline]

PolyReg1D which smoothly handles undefined values.

Note that this class _requires_ x to be between 0 and 1 for correct undef handling. Correct means: if the nearest sample is undefined, return undefined. Otherwise always return a value.

template<class T >
T Interpolate::polyReg1DWithUdf ( vm1,
v0,
v1,
v2,
float  x 
) [inline]
template<class T >
T Interpolate::polyReg2D ( vm10,
vm11,
v0m1,
v00,
v01,
v02,
v1m1,
v10,
v11,
v12,
v20,
v21,
float  x,
float  y,
float  xs = 1 
) [inline]

PolyReg2D which smoothly handles undefined values.

Note that this class _requires_ x and y to be between 0 and 1 for correct undef handling. Correct means: if the nearest sample is undefined, return undefined. Otherwise always return a value.

template<class T >
T Interpolate::polyReg2DWithUdf ( vm10,
vm11,
v0m1,
v00,
v01,
v02,
v1m1,
v10,
v11,
v12,
v20,
v21,
float  x,
float  y 
) [inline]
template<class T >
T Interpolate::polyReg3D ( const T *const *const *  v,
float  x,
float  y,
float  z 
) [inline]

PolyReg3D which smoothly handles undefined values.

Note that this class _requires_ x, y and z to be between 0 and 1 for correct undef handling. Correct means: if the nearest sample is undefined, return undefined. Otherwise always return a value.

template<class T >
T Interpolate::predictAtZero1D ( vm3,
vm2,
vm1,
v1,
v2,
v3 
) [inline]

> Predict at sample position 0 when three previous and three next are known. Returned is the value of the 5th order polynome that goes through the points.

template<class T >
T Interpolate::predictAtZero1D ( vm2,
vm1,
v1,
v2 
) [inline]

> Predict at sample position 0 when two previous and two next are known. Returned is the value of the 3rd order polynome that goes through the points.