L_UMTP_2DInterpolation
This function block is used for sequential 2D interpolation on a rectangular surface. It is a generalization of FB L_UMTP_BilinearInterpolation to the interpolation vectors for x and y and the selection of the interpolation type for the coordinate directions x and z: piecewise linear and cubic spline with Hermite or natural boundary conditions.
Calculation procedure in FB:
-
First interpolation in x-direction to determine a grid point vector. The calculation for computation time optimization is only performed with lrx change or aFALSEäTRUE edge at input xEnable.
-
Second interpolation in y-direction to determine the result lrz.
If lrx or lry are outside the minimum or maximum values of alrX or alrY, the input values are limited. This means that no extrapolation will be applied.
alrX and alrY must be strictly monotonically increasing.
If the basic data of the interpolation (number of interpolation points, values in alrX, alrY or alrZ or eInterpTypeX/Y) are changed, a FALSEäTRUE edge is again required at input xEnable.
The function block can also be used to perform a 1D interpolation. Therefore, the number di-NumOfYValues should be set to one.
|
|
Function: 2D-Interpolation
|
L_UMTP_2DInterpolation |
|||||||
|---|---|---|---|---|---|---|---|
|
BOOL |
— |
|
xEnable |
xValid |
|
— |
BOOL |
|
ARRAY [*] OF LREAL |
— |
|
alrX |
xError |
|
— |
BOOL |
|
DINT |
— |
|
diNumOfXValues |
eErrorID |
|
— |
L_IE1P_Error |
|
L_UMTP_InterpolationType |
— |
|
eInterpTypeX |
lrz |
|
— |
LREAL |
|
ARRAY [*] OF LREAL |
— |
|
alrY |
|
|
|
|
|
DINT |
— |
|
diNumOfYValues |
|
|
|
|
|
L_UMTP_InterpolationType |
— |
|
eInterpTypeY |
|
|
|
|
|
ARRAY [*,*] OF LREAL |
— |
|
alrZ |
|
|
|
|
|
LREAL |
— |
|
lrx |
|
|
|
|
|
LREAL |
— |
|
lry |
|
|
|
|
Inputs
|
Name Data type |
Information/possible settings |
|
|---|---|---|
|
xEnable BOOL
|
TRUE |
Perform interpolation |
|
FALSEäTRUE |
If values in alrX, alrY, alrZ or the number of interpolation points to be used or the type of interpolation for x or y are changed a positive edge at the xEnable input is required. |
|
|
alrX ARRAY [*] OF LREAL |
Support points in x-direction
|
|
|
diNumOfXValues DINT |
Optional: Number of values from alrX and rows in alrZ to be evaluated for interpolation |
|
|
eInterpTypeX L_UMTP_InterpolationType |
Type of interpolation in x-direction |
|
|
alrY ARRAY [*] OF LREAL |
Support points in y-direction
|
|
|
diNumOfYValues DINT |
Optional: Number of values from alrY and rows in alrZ to be evaluated for interpolation |
|
|
eInterpTypeY L_UMTP_InterpolationType |
Type of interpolation in y-direction |
|
|
alrZ ARRAY [*,*] OF LREAL |
Values at the interpolation points z = z(x,y) 2D matrix with variable dimension, max. 10 × 10 entries. The dimensions of alrX, alrY and alrZ must match. |
|
|
lrx LREAL |
x-coordinate to be evaluated |
|
|
lry LREAL |
y-coordinate to be evaluated |
|
Outputs
|
Name Data type |
Information/possible settings |
|---|---|
|
xValid BOOL |
Input values are plausible and calculation of lrz successful |
|
xError BOOL |
An error has occurred |
|
eErrorID L_IE1P_Fehler |
Detailed error information |
|
lrz LREAL |
Interpolated value lrz = lrz(lrx,lry), based on the interpolation points alrX, alrY and alrZ |
Application example
|
(* Declaration *) alrX : ARRAY[1..10] OF LREAL; alrY : ARRAY[1..10] OF LREAL; alrZ : ARRAY[1..10,1..10] OF LREAL; fb2DInterp1 : L_UMTP_2DInterpolation; lry : LREAL;
(* Implementation *) // support points for interpolation – x direction alrX[1] := 0.0; alrX[2] := 1.0;
// support points for interpolation – y direction alrY[1] := -4.0; alrY[2] := -2.0; alrY[3] := 2.0; alrY[4] := 4.0; alrY[5] := 6.0; alrY[6] := 10.0;
// support points for interpolation – z values alrZ[1,1] := 11.0; alrZ[2,1] := 15.0; alrZ[1,2] := 8.0; alrZ[2,2] := 13.0; alrZ[1,3] := 8.0; alrZ[2,3] := 11.0; alrZ[1,4] := 3.0; alrZ[2,4] := 7.0; alrZ[1,5] := 5.0; alrZ[2,5] := 8.0; alrZ[1,6] := 5.0; alrZ[2,6] := 9.0;
// call fb fb2DInterp1(xEnable := TRUE, alrX := alrX, diNbrOfXValues := 1, // 1D interpolation eInterpTypeX := L_UMTP_InterpolationType.Linear, alrY := alrY, diNbrOfYValues := 6, // use first 6 values of alrY eInterpTypeY := L_UMTP_InterpolationType.Linear, alrZ := alrZ, lrx := 0.3, lry := lry); |
The following graphic shows the interpolation results by comparing the available interpolation types.
|
|
Comparison of the different interpolation types (in y-direction) for the above code example for different lry values at lrx := 0.3;