**square_hex_grid**,
a C++ code which
computes a hexagonal 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.

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

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

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

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

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

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

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

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

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

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

SIMPLEX_GRID, a C++ library which generates a regular grid of points over the interior of an arbitrary simplex in M dimensions.

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

SPHERE_GRID, a C++ 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 C++ 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 C++ library which uses longitudes and latitudes to create grids of points, lines, and triangles on the surface of the unit sphere in 3D.

SQUARE_GRID, a C++ library which computes a grid of points over the interior of a square in 2D.

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

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

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

- square_hex_grid.cpp, the source code.
- square_hex_grid.sh, compiles the source code.
- square_hex_grid.hpp, the include file.