Implementation finding the cartesian coordinates of a regular n-simplex
Follows
this description on wikipedia. Constructs a simplex with the specified corner-points. Assumes Simplex and Point-classes exist.
public static Simplex createRegularSimplex(int d){
double angle = -1.0/d;
Point[] ret = new Point[d+1];
for(int s=0;s<d+1;s++) ret[s] = new Point(new double[d]);
double tmp = 0;
for(int i=0;i<d;i++){
double nCoord = Math.sqrt(1-tmp);
ret[i].setCoord(i, nCoord);
double rCoord = (angle - tmp)/nCoord;
for(int s=i+1;s<d+1;s++)
ret[s].setCoord(i, rCoord);
tmp += rCoord*rCoord;
}
return new Simplex(ret);
}