# 2.2.3.8.4 Matrix::GetInterpolatedValue

## Description

Get an interpolated Z value from an internal Origin matrix.

## Syntax

double GetInterpolatedValue( double dX, double dY, int nMethod = INTERPOLATE_NEAREST, int * pnError = NULL )

## Parameters

dX
[input] The X coordinate value
dY
[input] The Y coordinate value
nMethod
[input] Determines interpolation method. An enumerated value from the system header file OC_const.h including the values INTERPOLATE_NEAREST,
INTERPOLATE_BILINEAR, INTERPOLATE_BICUBIC, INTERPOLATE_2DSPLINE, and INTERPOLATE_VERTICINTERPOL
pnError
[output] A pointer to an error code

## Return

Returns the interpolated Z value on success or NANUM and an error code on failure.

Possible values for *pnError include:

-1=Complex matrix not supported

-5=Interpolate method does not exist

-6=dX or dY value is out of range

-8=The matrix must be at least 2*2 for bilinear method

-9=The matrix must be at least 3*3 for bicubic method

-10=The matrix must be at least 4*4 for 2D spline method

73=Memory allocation failed

243=Data is too ill conditioned to compute the B spline

## Examples

EX1

// Get the interpolated Z value from a matrix
void Matrix_GetInterpolatedValue_ex1()
{
double dZ;
int nError;

matrix mat1 = {
{2, 2, 2, 2},
{2, 1, 1, 2},
{2, 1, 1, 2},
{2, 2, 2, 2}
};

MatrixPage MatPg1;
MatPg1.Create("Origin");
MatrixLayer MatLy1 = MatPg1.Layers(0);
Matrix Mat1(MatLy1);
printf("  Target matrix %s has been created.\n",Mat1.GetName());
Mat1.SetXMin(0);
Mat1.SetXMax(10);
Mat1.SetYMin(0);
Mat1.SetYMax(10);
Mat1 = mat1;

// Demonstaration of GetInterpolatedValue to get the interpolated Z value
// This will print the following message:
// Interpolated Z value at (5,5) = 0.734375
dZ = Mat1.GetInterpolatedValue(5,5,INTERPOLATE_2DSPLINE, &nError );
if(dZ==NANUM) {
printf("  Error: GetInterpolatedValue failed.Error code = %d\n",nError);
return;
}
else
printf("  Interpolated Z value at (5,5) = %g\n",dZ);
}

## Remark

Get an interpolated Z value from an internal Origin matrix using the specified interpolation method and interpolating in two dimensions for the specified x and y coordinates.