Having a generic m-dimensional space I need to calculate the m+1 coordinates which are all equidistant among them.
Let's say that a 2D space can handle maximum 3 equidistant points (equilateral triangle created by 3 vertexes all equidistant among them) and so on.. generically speaking we can represent m equidistant vertexes in a m-1 dimensional space.
The distance between vertexes is the unit distance (1), for the simple 2D case the distance between 3 vertexes is 1.
I read about this Equidistant points across a cube but my request is different and has only one (big) constraint instead of two.
Every programming language is good enough, I need a suggestion to generalize the logic.
Thank you all.
Edit ----------- The Solution is the following (n are dimensions):
static double[] simplex_coordinates2 ( int n )
{
double a;
double c;
int i;
int j;
double s;
double[] x;
x = r8mat_zero_new ( n, n + 1 );
for ( i = 0; i < n; i++ )
{
x[i+i*n] = 1.0;
}
a = ( 1.0 - Math.sqrt ( 1.0 + ( double ) ( n ) ) ) / ( double ) ( n );
for ( i = 0; i < n; i++ )
{
x[i+n*n] = a;
}
//
// Now adjust coordinates so the centroid is at zero.
//
for ( i = 0; i < n; i++ )
{
c = 0.0;
for ( j = 0; j < n + 1; j++ )
{
c = c + x[i+j*n];
}
c = c / ( double ) ( n + 1 );
for ( j = 0; j < n + 1; j++ )
{
x[i+j*n] = x[i+j*n] - c;
}
}
//
// Now scale so each column has norm 1.
//
s = 0.0;
for ( i = 0; i < n; i++ )
{
s = s + x[i+0*n] * x[i+0*n];
}
s = Math.sqrt ( s );
for ( j = 0; j < n + 1; j++ )
{
for ( i = 0; i < n; i++ )
{
x[i+j*n] = x[i+j*n] / s;
}
}
return x;
}
static double[] r8mat_zero_new ( int m, int n )
{
double[] a;
int i;
int j;
a = new double[m*n];
for ( j = 0; j < n; j++ )
{
for ( i = 0; i < m; i++ )
{
a[i+j*m] = 0.0;
}
}
return a;
}