REGION_SAMPLE
Select Points from a Region


REGION_SAMPLE is a FORTRAN90 library which samples various computational regions.

A computational region is a (usually finite) subset of 2D, 3D or M-dimensional space, which is often an ideal model of some physically interesting space, such as a channel in which liquid is flowing, or the body of some metallic structure. For certain algorithms, it is necessary to "sample" this region, that is, to select, uniformly at random, a set of N points that lie in the region.

It's easy to do this for the unit square or hypercube, simply by invoking the pseudorandom number generator. It's also easy to extend this idea to any rectangular object. However, this gets more difficult to do when the region has a curved or complicated geometry, which might include holes.

One way to handle many different kinds of regions in a uniform way is to allow the sampling of the region to be carried out by a subroutine which "knows" the region's shape. The input to the subroutine is simply N, the number of points requested, and the routine generates the points using whatever method is appropriate. When all else fails, a rejection method can usually be used.

REGION_SAMPLE is simply a collection of some of the routines that have been used for such computations.

Related Data and Programs:

PLOT_POINTS is an executable FORTRAN90 program which can be used to create Encapsulated PostScript images (EPS files) from the output files.

RANDOM_DATA is an executable FORTRAN90 program which produces random data from a number of regions.

RBOX is an executable C program which produces random data from a number of regions.

REGION_SAMPLE is also available in a C++ version and a MATLAB version.

RSITES is an executable C++ program which produces random data in an M-dimensional box.

TABLE is a format used to store the input and output files used by the program.

UNIFORM is a FORTRAN90 library of routines for sampling the uniform random distribution.

Source Code:

Examples and Tests:

Test files you may copy include:

FORK is a subset of [0,100] x [0,100] comprising a rectangular "handle" and semicircular annulus that resembles an inverted tuning fork:

SPHERE is the interior of a sphere:

List of Routines:

You can go up one level to the FORTRAN90 source codes.


Last revised on 12 November 2006.