**simplex_coordinates**,
a C++ code which
computes the Cartesian coordinates of the vertices of a regular
simplex in M dimensions.

Note that the unit simplex, formed by the origin and the M unit coordinate axes, is not a regular simplex, because some sides have length 1 while other sides have length sqrt(2).

There is a straightforward but tedious method for computing these coordinates, coded in SIMPLEX_COORDINATES1, based on the idea of selecting the first coordinate to be (1,0,0,...0), and noting that the dot product with vectors 2 through N+1 must be -1/N, which means the first row and first column of the coordinate matrix are done. We can then move to entry (2,2), assume the coordinates below it are 0, and set its value by requiring that the sum of the squares of the (2,1) and (2,2) entries must be 1. Setting the (2,2) entry then allows us to determine the rest of row 2 by the same dot product criterion, and we proceed in this way til we have completed the matrix.

A simpler algorithm, in SIMPLEX_COORDINATES2, notes that the identity matrix will almost work for the first N vertices. Choose the last vertex by assuming all its entries are equal to some constant A, and that its distance from any other vertex must be sqrt ( 2 ). This determines that (A-1)^2 + (N-1)*A^2 = 2, from which we get the value of A as (1-sqrt(N+1))/N. To clean things up, we compute the centroid C of these vertices, and recenter the simplex around the origin. Then we determine the distance S of one vertex to the origin, and rescale so that this becomes 1. The coding is simpler, and there is much less chance for the accumulation of numerical error. Plus I thought of this one myself.

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

**simplex_coordinates** is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version and
a Python version.

ASA299, a C++ code which computes the lattice points in an M-dimensional simplex; this is Applied Statistics Algorithm 299;

GEOMETRY, a C++ code which performs geometric calculations in 2, 3 and M-dimensional space.

RANDOM_DATA, a C++ code which generates sample points for various probability distributions, spatial dimensions, and geometries, including the M-dimensional simplex.

SIMPLEX_GM_RULE, a C++ code which defines Grundmann-Moeller rules for quadrature over a triangle, tetrahedron, or general M-dimensional simplex.

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

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