0

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;
}
Community
  • 1
  • 1
  • 1
    The unit vectors (1,0,0...0), (0,1,0,...,0) etc in m+1 space form such a confguration of m+1 equidistant points. They all lie in the plane x[1]+x[2]+...+x[m+1]=1. So one only needs to rotate or Householder-reflect the normal of that plane into the last unit vector to get that configuration into m-space. – Lutz Lehmann Sep 14 '16 at 14:48

1 Answers1

0

You need regular simplex.
Wiki page contains information about coordinates of regular simplices vertices.

The main trick is based on the fact that angle between any pair of vectors from the simplex center to vertices is arrcos(-1/d) where d is space dimension (2d, 3d, 4d etc)

Example for 2D case:
Let's first vertice coordinate V2 = (x1,y1) = (0,1)
Dot product of (x2,y2) and (x3,y3) with V1 must be -1/2, so both x2 and x3 are equal to -1/2
y2 and y3 are Sqrt(3)/2 and -Sqrt(3)/2 - from distance=1 to coordinate origin

The last step - normalize coordinate to get distance 1 between vertices - just multiply all coordinates by coefficient C=Sqrt(d/(2*(d+1)))
(from theorem of cosines c^2+c^2+2*c*c/d=1)

For 2d-case C=Sqrt(3)/3, so simplex vertices are

(Sqrt(3)/3, 0)
(-Sqrt(3)/6, 1/2)
(-Sqrt(3)/6, -1/2)
MBo
  • 77,366
  • 5
  • 53
  • 86
  • I have found this https://people.sc.fsu.edu/~jburkardt/m_src/simplex_coordinates/simplex_coordinates.html maybe it's what I am searching for with code. What do you think? Will it generate m+1 equidistant (among them) points ? – vincenzodentamaro Sep 15 '16 at 10:26
  • Method 1 is equal to described one. It seems that method 2 works too. It is really very simple for implementation. – MBo Sep 15 '16 at 10:49