# 2.1.18.18 ocmath_tps_eval

## Description

This function evaluate the value of given points using thin plate spline method.

## Syntax

int ocmath_tps_eval( int np, const double * px, const double * py, double * pz, ocmath_strTPS * strTPS, bool bExtrapolation = true, double dNAN = NANUM, double dTol = 1E-3 )

## Parameters

np
[input] the number of points to evaluate.
px
[input] arrays contain the x coordinates of the interpolation points.
py
[input] arrays contain the y coordinates of the interpolation points.
pz
[output] the interpolant value of the given points.
strTPS
[input] the structure contains the thin plate spline interpolation coefficients.
bExtrapolation
[input] the function will perform extrapolation on the points outside of the data hull if bExtrapolation = TRUE; or assign dNAN to all the outside poins if bExtrapolation = FALSE;
dNAN
[Input] the outside points will be set to dNAN if bExtrapolation = false. It is ignored when bExtrapolation = true.
dTol
[input] If bExtrapolation = false, the polygon that outline the margin of scatter data points will be inflated by dTol. This tolerence value is useful when the margin of scatter is a straight line but some points deviate by a small amout.

## Return

OE_NOERROR for successful or

OE_TPS_FIT for error caused by ocmath_tps_fit or

OE_NULL_POINTER if pointer is null.

## Examples

EX1

#include <wks2mat.h>
int ocmath_tps_eval_ex1()
{
double			vX[]={1,2,3,4,5,6,7,8};
double			vY[]={8,7,6,5,4,3,2,1};
double			vZ[]={2,8,2,8,2,8,2,8};
int				nPoints = 8;
double			dRegularization,dSmooth  = 0;
double			dx,dy,dz;
int				nSamp = 6;
const double	fInv = 1.0/(double)nSamp;
ocmath_strTPS strTPS;
ocmath_tps_initial(&strTPS);
int nRet = ocmath_tps_fit(nPoints,vX,vY,vZ,dSmooth,&strTPS,&dRegularization);
if(nRet <0)
return 0;

for(int jj = 0;jj<= nSamp; jj++ )
{
dy = fInv*jj;
for(int ii = 0; ii<= nSamp; ii++)
{
dx = fInv*ii;
if(ocmath_tps_eval(1,&dx,&dy,&dz,&strTPS) < 0)
return 0;
else
printf("%9.6f\t",dz);
}
printf("\n");
}

return 1;
}