Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

QGRID3


Syntax | Return Value | Arguments | Keywords | Examples | Version History | See Also

The QGRID3 function linearly interpolates the dependent variable values to points in a regularly sampled volume. Its inputs are a triangulation of scattered data points in three dimensions, and the value of a dependent variable for each point.

Syntax

Result = QGRID3( XYZ, F, Tetrahedra [, DELTA=vector ] [, DIMENSION=vector ] [, MISSING=value ] [, START=vector ] )

or

Result = QGRID3( X, Y, Z, F, Tetrahedra [, DELTA=array ] [, DIMENSION=array ] [, MISSING=value ] [, START=array ] )

Return Value

Result is a 3-dimensional array of either single or double precision floating type, of the specified dimensions.

Arguments

XYZ

This is a 3-by-n array containing the scattered points.

X, Y, Z

One-dimensional vectors containing the X, Y, and Z point coordinates.

Tetrahedra

A longword array containing the point indices of each tetrahedron, as created by QHULL.

Keywords

Note
Any of the keywords may be set to a scalar if all elements are the same.

DELTA

A scalar or three element array specifying the grid spacing in X, Y, and Z. If this keyword is not specified, it is set to create a grid of DIMENSION cells, enclosing the volume from START to [max(x), max(y), max(z)].

DIMENSION

A three element array specifying the grid dimensions in X, Y, and Z. Default value is 25 for each dimension.

MISSING

The value to be used for grid points that lie outside the convex hull of the scattered points. The default is 0.

START

A three element array specifying the start of the grid in X, Y, and Z. Default value is [min(x), min(y), min(z)].

Examples

Example 1

This example interpolates a data set measured on an irregular grid.

; Create a dataset of N points. 
n = 200 
x = RANDOMU(seed, n) 
y = RANDOMU(seed, n) 
z = RANDOMU(seed, n) 
 
; Create dependent variable. 
f = x^2 - x*y + z^2 + 1  
 
; Obtain a tetrahedra using the QHULL procedure. 
QHULL, x, y, z, tet, /DELAUNAY  
 
; Create a volume with dimensions [51, 51, 51] 
; over the unit cube. 
volume = QGRID3(x, y, z, f, tet, START=0, DIMENSION=51, $ 
   DELTA=0.02) 
 
; Display the volume. 
XVOLUME, BYTSCL(volume) 

Example 2

This example is similar to the previous one, however in this example we use a [3, n] array of points.

; Create a dataset of N points. 
n = 200 
p = RANDOMU(seed, 3, n) 
 
; Create dependent variable. 
f = p[0,*]^2 - p[0,*]*p[1,*] + p[2,*]^2 + 1  
 
; Obtain a tetrahedra. 
QHULL, p, tet, /DELAUNAY  
 
; Create a volume with dimensions [51, 51, 51] over the unit cube. 
volume = QGRID3(p, f, tet, START=0, DIMENSION=51, DELTA=0.02) 
 
; Display the volume. 
XVOLUME, BYTSCL(volume) 

Example 3

The following example uses the data from the irreg_grid2.txt ASCII file. This file contains scattered three-dimensional data. This file contains bore hole data for a square mile of land. The QHULL procedure is used to triangulate the three-dimensional locations. The QGRID3 function uses the results from QHULL to grid the data into a volume. The scattered data is displayed as symbol polyline objects in the XOBJVIEW utility. The resulting gridded volume is displayed in the XVOLUME utility:

; Import the Data: 
 
; Determine the path to the file. This file contains bore hole 
; data for a square mile of land.  The bore hole samples were 
; roughly taken diagonally from the upper left corner of the 
; square to the lower right corner. 
file = FILEPATH('irreg_grid2.txt', $ 
   SUBDIRECTORY = ['examples', 'data']) 
 
; Import the data from the file into a structure. 
dataStructure = READ_ASCII(file) 
 
; Get the imported array from the first field of 
; the structure. 
dataArray = TRANSPOSE(dataStructure.field1) 
 
; Initialize the variables of this example from 
; the imported array. 
x = dataArray[*, 0] 
y = dataArray[*, 1] 
z = dataArray[*, 2] 
data = dataArray[*, 3] 
 
; Determine number of data points. 
nPoints = N_ELEMENTS(data) 
 
; Triangulate the Data with QHULL: 
 
; Construct the convex hulls of the volume. 
QHULL, x, y, z, tetrahedra, /DELAUNAY 
 
; Grid the Data and Display the Results: 
 
; Initialize volume parameters. 
cubeSize = [51, 51, 51] 
; Grid the data into a volume. 
volume = QGRID3(x, y, z, data, tetrahedra, START = 0, $ 
   DIMENSION = cubeSize, DELTA = 0.02) 
; Scale the volume to be able to view the full data value range 
; with the color tables provided in the XVOLUME utility. 
scaledVolume = BYTSCL(volume) 
 
; Display the results in the XVOLUME utility. 
XVOLUME, scaledVolume 
 
; Derive the isosurface for mineral deposits with the data value 
; of 2.5. 
ISOSURFACE, volume, 2.5, vertices, connectivity 
 
; Initialize a model to contain the isosurface. 
oModel = OBJ_NEW('IDLgrModel') 
 
; Initialize the polygon object of the isosurface. 
oPolygon = OBJ_NEW('IDLgrPolygon', vertices, $ 
   POLYGONS = connectivity, COLOR = [0, 0, 255]) 
 
; Determine the range in each direction. 
xRange = [0, cubeSize[0]] 
yRange = [0, cubeSize[1]] 
zRange = [0, cubeSize[2]] 
 
; Initialize an axis for each direction. 
oAxes = OBJARR(3) 
oAxes[0] = OBJ_NEW('IDLgrAxis', 0, RANGE = xRange, $ 
   LOCATION = [xRange[0], yRange[0], zRange[0]], /EXACT, $ 
   TICKLEN = (0.02*(yRange[1] - yRange[0]))) 
oAxes[1] = OBJ_NEW('IDLgrAxis', 1, RANGE = yRange, $ 
   LOCATION = [xRange[0], yRange[0], zRange[0]], /EXACT, $ 
   TICKLEN = (0.02*(xRange[1] - xRange[0]))) 
oAxes[2] = OBJ_NEW('IDLgrAxis', 2, RANGE = zRange, $ 
   LOCATION = [xRange[0], yRange[1], zRange[0]], /EXACT, $ 
   TICKLEN = (0.02*(xRange[1] - xRange[0]))) 
 
; Add the polygon and axes object to the model. 
oModel -> Add, oPolygon 
oModel -> Add, oAxes 
 
; Rotate the model for a better perspective. 
oModel -> Rotate, [0, 0, 1], 30. 
oModel -> Rotate, [1, 0, 0], -45. 
 
; Display the model, which contains the isosurface. 
XOBJVIEW, oModel, /BLOCK, SCALE = 0.75, $ 
   TITLE = 'Isosurface at the Value of 2.5' 
 
; Cleanup object references. 
OBJ_DESTROY, [oModel] 

Version History

Introduced: 5.5

See Also

QHULL


Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]