**square_hex_grid**,
a FORTRAN90 code which
computes a hexagonally staggered grid of points
over the interior of a square in 2D.

For one set of routines, the hexagonal grid is defined in the unit square [0,1] x [0,1]. For a matching set of routines, the hexagonal grid is defined on a coordinate box [A,B] x [C,D].

All nodes of the grid lie on one of **LAYERS** horizontal lines.
The first of these lines is the X axis (for grids in the unit square)
or the line from (A,C) to (B,C), for grids in a coordinate box.
Each successive line is **HY** units higher.

On all the odd numbered lines, there are **NODES_PER_LAYER** points,
equally spaced from 0 to 1 or A to B, with a spacing of **HX**.

On the even numbered lines, there are **NODES_PER_LAYER**-1 points,
whose values are the midpoints of successive intervals on
an odd numbered line. (The grid is staggered).

In order to maintain the hexagonal structure, the following relationship
is required between **HX** and **HY**:

HY=HX* sqrt ( 3 ) / 2.

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

**square_hex_grid** is available in
a C++ version and
a Fortran90 version and
a MATLAB version and
an Octave version.

BALL_GRID, a FORTRAN90 library which computes a grid of points over the interior of a ball in 3D.

CIRCLE_ARC_GRID, a FORTRAN90 program which computes points equally spaced along a circular arc;

CUBE_GRID, a FORTRAN90 library which computes a grid of points over the interior of a cube in 3D.

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

DISK_GRID, a FORTRAN90 library which computes a grid of points over the interior of a disk in 2D.

ELLIPSE_GRID, a FORTRAN90 library which computes a grid of points over the interior of an ellipse in 2D.

ELLIPSOID_GRID, a FORTRAN90 library which computes a grid of points over the interior of an ellipsoid in 3D.

HYPERCUBE_GRID, a FORTRAN90 library which computes a grid of points over the interior of a hypercube in M dimensions.

LINE_GRID, a FORTRAN90 library which computes a grid of points over the interior of a line segment in 1D.

POLYGON_GRID, a FORTRAN90 library which generates a grid of points over the interior of a polygon in 2D.

PYRAMID_GRID, a FORTRAN90 library which computes a grid of points over the interior of the unit pyramid in 3D;

SIMPLEX_GRID, a FORTRAN90 library which generates a grid of points over the interior of a simplex in M dimensions.

SPHERE_CUBED_GRID, a FORTRAN90 library which uses the projection of a cube to create grids of points, lines, and quadrilaterals on the surface of the unit sphere in 3D.

SPHERE_FIBONACCI_GRID, a FORTRAN90 library which uses a Fibonacci spiral to create a grid of points on the surface of the unit sphere in 3D.

SPHERE_GRID, a FORTRAN90 library which provides a number of ways of generating grids of points, or of points and lines, or of points and lines and faces, on the surface of the unit sphere in 3D.

SPHERE_LLQ_GRID, a FORTRAN90 library which uses longitudes and latitudes to create grids of points, lines, and quadrilaterals on the surface of the unit sphere in 3D.

SPHERE_LLT_GRID, a FORTRAN90 library which uses longitudes and latitudes to create grids of points, lines, and triangles on the surface of the unit sphere in 3D.

TETRAHEDRON_GRID, a FORTRAN90 library which computes a grid of points over the interior of a tetrahedron in 3D.

TRIANGLE_GRID, a FORTRAN90 library which computes a grid of points over the interior of a triangle in 2D.

WEDGE_GRID, a FORTRAN90 library which computes a grid of points over the interior of the unit wedge in 3D.

- square_hex_grid.f90, the source code.
- square_hex_grid.sh, compiles the source code.