The GRID3 function fits a smooth function to a set of 3D scattered nodes (xi, yi, zi) with associated data values (fi). The function can be sampled over a set of user-specified points, or over an arbitrary 3D grid which can then be viewed using the SLICER3 procedure.

GRID3 uses the method described in Renka, R. J., “Multivariate Interpolation of Large Sets of Scattered Data,” ACM Transactions on Mathematical Software, Vol. 14, No. 2, June 1988, Pages 139-148, which has been referred to as the Modified Shepard’s Method. The function described by this method has the advantages of being equal to the values of fi, at each (xi, yi, zi), and being smooth (having continuous first partial derivatives).

Examples


Produce a set random points within the (0,1) unit cube and simulate a function:

; Number of irregular samples:
N = 300
; Generate random values between 0 and 1:
X = RANDOMU(SEED, N)
Y = RANDOMU(SEED, N)
Z = RANDOMU(SEED, N)
; The function to simulate:
F = (X-.5)^2 + (Y-.5)^2 + Z
; Return a cube with 25 equal-interval samples along each axis:
Result = GRID3(X, Y, Z, F)
; Return a cube with 11 elements along each dimension, which
; samples each axis at (0, 0.1, ..., 1.0):
Result = GRID3(X, Y, Z, F, START=[0., 0., 0], $
   DELTA=0.1, NGRID=10)
print, result

The same result is produced by the statements:

; Create sample values:
S = FINDGEN(11) / 10.
Result = GRID3(X, Y, Z, F, S, S, S, /GRID)

Syntax


Result = GRID3( X, Y, Z, F, Gx, Gy, Gz [, DELTA=scalar/vector] [, DTOL=value] [, GRID=value] [, NGRID=value] [, START=[x, y, z]] )

Return Value


If no optional or keyword parameters are supplied, GRID3 produces a regularly-sampled volume with dimensions of (25, 25, 25), made up of single-precision, floating-point values, enclosing the original data points.

Arguments


X, Y, Z, F

Arrays containing the locations of the data points, and the value of the variable to be interpolated at that point. X, Y, Z, and F must have the same number of elements (with a minimum of 10 elements per array) and are converted to floating-point if necessary.

Note: For the greatest possible accuracy, the arrays X, Y, and Z should be scaled to fit in the range [0,1].

Gx, Gy, Gz

Optional arrays containing the locations within the volume to be sampled (if the GRID keyword is not set), or the locations along each axis of the sampling grid (if the GRID keyword is set). If these parameters are supplied, the keywords DELTA, NGRID, and START are ignored.

If the keyword GRID is not set, the result has the same number of elements as Gx, Gy, and Gz. The ith element of the result contains the value of the interpolate at (Gxi, Gyi, Gzi). The result has the same dimensions as Gx.

If the GRID keyword is set, the result of GRID3 is a three-dimensional, single-precision, floating-point array with dimensions of (Nx, Ny, Nz), where Nx, Ny, and Nz are the number of elements in Gx, Gy, and Gz, respectively.

Keywords


DELTA

Set this keyword to a three-element vector or a scalar that specifies the grid spacing in the X, Y, and Z dimensions. The default spacing produces NGRID samples within the range of each axis.

DTOL

The tolerance for detecting an ill-conditioned system of equations. The default value is 0.01, which is appropriate for small ranges of X, Y, and Z. For large ranges of X, Y, or Z, it may be necessary to decrease the value of DTOL. If you receive the error message “GRID3: Ill-conditioned matrix or all nodes co-planar,” try decreasing the value of DTOL.

GRID

This keyword specifies the interpretation of Gx, Gy, and Gz. The default value for GRID is zero if Gx, Gy, and Gz are supplied, otherwise a regularly-gridded volume is produced.

NGRID

The number of samples along each axis. NGRID can be set to a scalar, in which case each axis has the same number of samples, or to a three-element array containing the number of samples for each axis. The default value for NGRID is 25.

START

A three-element array that specifies the starting value for each grid. The default value for START is the minimum value in the respective X, Y, and Z array.

Version History


Pre 4.0

Introduced

See Also


QGRID3, QHULL