HEX_GRID_ANGLE Angled Hexagonal Grids

HEX_GRID_ANGLE is a FORTRAN90 library which produces a hexagonal grid of points in the unit square or an arbitrary box, allowing the user to specify an arbitrary center, angle, and grid density.

Specifically, the grid begins with a single point called CENTER, whose location in the unit square or box is specified by the user. The next "layer" of points is produced by stepping out H units in a user-specified direction ANGLE, and marking off points on the hexagon. Further layers of points are added until a layer is reached that lies entirely outside the region.

HEX_GRID_ANGLE was developed to allow more flexibility than the HEX_GRID library provided. In particular, that library always starts the grid at the origin, always runs the first grid line along the X-axis, and always requires that the first grid line terminate exactly with at point at X = 1. By contrast, the HEX_GRID_ANGLE library allows the user total freedom to specify the center, angle, and spacing of the hexagonal grid.

One reason for developing this library was to try to see whether you could always force 100 points of the hexagonal grid to fall into the unit square simply by choosing a spacing H that guaranteed that the Voronoi region around each point (also a hexagon) had an area of 1/100. We finally realized that this cannot be guaranteed, since the hexagonal and Cartesian coordinate systems are "incommensurable". They only match up asymptotically. So, even though we carefully chose the spacing H, it is only on average that we found 100 points in a unit square, but also found squares with 98, 99, or 104 points as well.

Moreover, it will not be possible to choose a hexagonal grid with the property that it is equivalent to the tessellation generated by the the intersection of the hexagonal grid with a single unit square.

Languages:

HEX_GRID_ANGLE is available in a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

CVT, a FORTRAN90 library which computes elements of a Centroidal Voronoi Tessellation.

FAURE, a FORTRAN90 library which computes elements of a Faure quasirandom sequence.

GRID, a FORTRAN90 library which computes elements of a grid dataset.

HALTON, a FORTRAN90 library which computes elements of a Halton quasirandom sequence.

HAMMERSLEY, a FORTRAN90 library which computes elements of a Hammersley quasirandom sequence.

HEX_GRID, a FORTRAN90 library which computes elements of a hexagonal grid dataset.

IHS, a FORTRAN90 library which computes elements of an improved distributed Latin hypercube dataset.

LATIN_CENTER, a FORTRAN90 library which computes elements of a Latin Hypercube dataset, choosing center points.

LATIN_EDGE, a FORTRAN90 library which computes elements of a Latin Hypercube dataset, choosing edge points.

LATIN_RANDOM, a FORTRAN90 library which computes elements of a Latin Hypercube dataset, choosing points at random.

LATTICE_RULE, a FORTRAN90 library which approximates multidimensional integrals using lattice rules.

LCVT, a FORTRAN90 library which computes a latinized Centroidal Voronoi Tessellation.

NIEDERREITER2, a FORTRAN90 library which computes elements of a Niederreiter quasirandom sequence with base 2.

NORMAL, a FORTRAN90 library which computes elements of a sequence of pseudorandom normally distributed values.

SOBOL, a FORTRAN90 library which computes elements of a Sobol quasirandom sequence.

TRIANGLE_GRID, a FORTRAN90 library which computes a triangular grid of points.

UNIFORM, a FORTRAN90 library which computes elements of a uniform pseudorandom sequence.

VAN_DER_CORPUT, a FORTRAN90 library which computes elements of a van der Corput quasirandom sequence.

List of Routines:

• BOX_01_CONTAINS_POINT_2D determines if a point is inside the unit box in 2D.
• BOX_CONTAINS_POINT_2D determines if a point is inside a box in 2D.
• COS_DEG returns the cosine of an angle given in degrees.
• GET_UNIT returns a free FORTRAN unit number.
• HEX_GRID_ANGLE_01 sets the points in an angled hex grid in the unit box.
• HEX_GRID_ANGLE_01_SIZE counts the points in an angled hex grid in the unit box.
• HEX_GRID_ANGLE_01_WRITE writes an angled hex grid dataset to a file.
• HEX_GRID_ANGLE sets the points in an angled hex grid in a box.
• HEX_GRID_ANGLE_SIZE counts the points in an angled hex grid in a box.
• HEX_GRID_ANGLE_WRITE writes an angled hex grid dataset in a box to a file.
• R8_MODP returns the nonnegative remainder of R8 division.
• R8_UNIFORM_01 returns a unit pseudorandom R8.
• R8MAT_TRANSPOSE_PRINT prints an R8MAT, transposed.
• R8MAT_TRANSPOSE_PRINT_SOME prints some of an R8MAT, transposed.
• SIN_DEG returns the sine of an angle given in degrees.
• TIMESTAMP prints the current YMDHMS date as a time stamp.
• TIMESTRING writes the current YMDHMS date into a string.

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

Last revised on 21 October 2006.