ug4
ug::IDWInterpolation< WDim, TPntIterator, TData > Class Template Reference

Class for inverse distance weighting based on a general data type. More...

#include <invdist_user_data.h>

Public Types

typedef TData data_type
 type of the data to extrapolate More...
 
typedef TPntIterator t_pnt_iter
 type of the interpolation point iterator More...
 

Static Public Member Functions

static void compute (data_type &res, const MathVector< dim > &pos, number R, t_pnt_iter pnt_beg, t_pnt_iter pnt_end, number order, number small_dist=1e-7)
 computes the interpolation basing on the interpolation points in a given ball More...
 
static void compute (data_type &res, const MathVector< dim > &pos, t_pnt_iter pnt_beg, t_pnt_iter pnt_end, number order, number small_dist=1e-7)
 computes the interpolation basing on all the interpolation points More...
 

Static Public Attributes

static const int dim = WDim
 dimensionality of the space (i.e. of the coordinate vectors) More...
 

Detailed Description

template<int WDim, typename TPntIterator, typename TData = number>
class ug::IDWInterpolation< WDim, TPntIterator, TData >

Class for inverse distance weighting based on a general data type.

The static functions in the class compute the field given by the IDW interpolation of a given order for given interpolation points and values. Type of the values specified by the template parameter (and may be a scalar or a tensor arithmetic type).

Having a set of interpolation points \( \mathbf{x}_i \) with values \( u_i \) at them, the interpolated value \( u \) at point \( \mathbf{x} \not\in \{ \mathbf{x}_i \} \) is computed as

\begin{eqnarray*} u = \frac {\sum_i w_i \cdot u_i} {\sum_i w_i}, \end{eqnarray*}

where

\begin{eqnarray*} w_i := \frac{1}{\| \mathbf{x} - \mathbf{x}_i \|_2^p} \end{eqnarray*}

( \( p \) being the order of the interpolation). For \( \mathbf{x} = \mathbf{x}_i \) (up to some numerical precision), we set \( u = u_i \).

Remarks
For \( p \) less or equal the dimension of the geometric space, the interpolated value \( u \) may be essentially influenced by the values at \( \mathbf{x}_i \) located far away from \( \mathbf{x} \). However, this influence may be avoided by specifying the radius \( R \): Then only those \( \mathbf{x}_i \) (and therefore \( u_i \)) are considered in the sums, for which \( \| \mathbf{x} - \mathbf{x}_i \|_2 \le R \) holds.
Note that if the radius \( R \) is specified, then it can happen that the interpolated value depends only on values at points located on one side of \( \mathbf{x} \), completely ignoring a trend prescribed by points on the other sides. Thus, \( R \) should be large enough.

To loop the interpolation points, iterators of the templated type TPntIterator are used. Every element of the reference elements should have two members: pos and value: TPntIterator ptr; ptr->pos is a MathVector<WDim> object with the coordinates of the interpolation point; ptr->value is a TData object of the value at that point.

Template Parameters
WDimdimensionality of the space
TPntIteratorinterpolation point iterator type
TDatatype of the values to interpolate

Member Typedef Documentation

◆ data_type

template<int WDim, typename TPntIterator , typename TData = number>
typedef TData ug::IDWInterpolation< WDim, TPntIterator, TData >::data_type

type of the data to extrapolate

◆ t_pnt_iter

template<int WDim, typename TPntIterator , typename TData = number>
typedef TPntIterator ug::IDWInterpolation< WDim, TPntIterator, TData >::t_pnt_iter

type of the interpolation point iterator

Member Function Documentation

◆ compute() [1/2]

template<int WDim, typename TPntIterator , typename TData >
void ug::IDWInterpolation< WDim, TPntIterator, TData >::compute ( data_type res,
const MathVector< dim > &  pos,
number  R,
t_pnt_iter  pnt_beg,
t_pnt_iter  pnt_end,
number  order,
number  small_dist = 1e-7 
)
static

computes the interpolation basing on the interpolation points in a given ball

Computes the interpolation basing on the interpolation points in a given ball.

Parameters
resinterpolated value
posgeometric position where to interpolate
Rradius of the ball (if 0 then the whole space)
pnt_begthe first interpolation point
pnt_enddelimiter of the iterpolation points
orderorder of the interpolation
small_distdistance at which we do not distinguish the points

References ug::IDWInterpolation< WDim, TPntIterator, TData >::compute(), UG_THROW, and ug::VecDistance().

◆ compute() [2/2]

template<int WDim, typename TPntIterator , typename TData >
void ug::IDWInterpolation< WDim, TPntIterator, TData >::compute ( data_type res,
const MathVector< dim > &  pos,
t_pnt_iter  pnt_beg,
t_pnt_iter  pnt_end,
number  order,
number  small_dist = 1e-7 
)
static

computes the interpolation basing on all the interpolation points

Computes the interpolation basing on all the interpolation point.

Parameters
resinterpolated value
posgeometric position where to interpolate
pnt_begthe first interpolation point
pnt_enddelimiter of the iterpolation points
orderorder of the interpolation
small_distdistance at which we do not distinguish the points

References UG_THROW, and ug::VecDistance().

Referenced by ug::IDWInterpolation< WDim, TPntIterator, TData >::compute(), and ug::IDWUserData< WDim, TData >::evaluate().

Member Data Documentation

◆ dim

template<int WDim, typename TPntIterator , typename TData = number>
const int ug::IDWInterpolation< WDim, TPntIterator, TData >::dim = WDim
static

dimensionality of the space (i.e. of the coordinate vectors)


The documentation for this class was generated from the following files: