NAG Library Function Document
nag_2d_triang_interp (e01sjc) generates a two-dimensional surface interpolating a set of scattered data points, using the method of Renka and Cline.
||nag_2d_triang_interp (Integer m,
const double x,
const double y,
const double f,
nag_2d_triang_interp (e01sjc) constructs an interpolating surface through a set of scattered data points , for , using a method due to Renka and Cline. In the plane, the data points must be distinct. The constructed surface is continuous and has continuous first derivatives.
The method involves firstly creating a triangulation with all the
data points as nodes, the triangulation being as nearly equiangular as possible (see Cline and Renka (1984)
). Then gradients in the
-directions are estimated at node
as the partial derivatives of a quadratic function of
which interpolates the data value
and which fits the data values at nearby nodes (those within a certain distance chosen by the algorithm) in a weighted least squares sense. The weights are chosen such that closer nodes have more influence than more distant nodes on derivative estimates at node
. The computed partial derivatives, with the
values, at the three nodes of each triangle define a piecewise polynomial surface of a certain form which is the interpolant on that triangle. See Renka and Cline (1984)
for more detailed information on the algorithm,
a development of that by Lawson (1977)
. The code is derived from Renka (1984)
can subsequently be evaluated at any point
inside or outside the domain of the data by a call to
Points outside the domain are evaluated by extrapolation.
Cline A K and Renka R L (1984) A storage-efficient method for construction of a Thiessen triangulation Rocky Mountain J. Math. 14 119–139
Lawson C L (1977) Software for surface interpolation Mathematical Software III (ed J R Rice) 161–194 Academic Press
Renka R L (1984) Algorithm 624: triangulation and interpolation of arbitrarily distributed points in the plane ACM Trans. Math. Software 10 440–442
Renka R L and Cline A K (1984) A triangle-based interpolation method Rocky Mountain J. Math. 14 223–237
m – IntegerInput
, the number of data points.
x[m] – const doubleInput
y[m] – const doubleInput
f[m] – const doubleInput
: the coordinates of the
th data point, for
. The data points are accepted in any order, but see Section 8
the nodes must not all be collinear, and each node must be unique.
triang – IntegerOutput
: a data structure defining the computed triangulation, in a form suitable for passing to
grads – doubleOutput
: the estimated partial derivatives at the nodes, in a form suitable for passing to nag_2d_triang_eval (e01skc)
. The derivatives at node
with respect to
are contained in
fail – NagError *Input/Output
The NAG error argument (see Section 3.6
in the Essential Introduction).
6 Error Indicators and Warnings
All nodes are collinear. There is no unique solution.
On entry, argument had an illegal value.
On entry, , for , , .
On entry, .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG
On successful exit, the computational errors should be negligible in most situations but you should always check the computed surface for acceptability, by drawing contours for instance. The surface always interpolates the input data exactly.
The time taken for a call of nag_2d_triang_interp (e01sjc) is approximately proportional to the number of data points,
. The function is more efficient if, before entry, the values in x
are arranged so that the x
array is in ascending order.
This example reads in a set of
data points and calls nag_2d_triang_interp (e01sjc)
to construct an interpolating surface. It then calls
to evaluate the interpolant at a sample of points on a rectangular grid.
Note that this example is not typical of a realistic problem: the number of data points would normally be larger, and the interpolant would need to be evaluated on a finer grid to obtain an accurate plot, say.
9.1 Program Text
Program Text (e01sjce.c)
9.2 Program Data
Program Data (e01sjce.d)
9.3 Program Results
Program Results (e01sjce.r)