Suppose we have a set of points with the restriction that for each point all coordinates are non-negative, and the sum of the coordinates is 1. This limits the points lying in the 3-dimensional simplex, so it makes sense to try translating it back into 3-dimensional space for renderings.
The map I'm looking for will require extreme points (1,0,0,0), (0,1,0,0), (0,0,1,0) and (0,0,0, 1) to the vertices a "well-positioned" regular tetrahedron. In particular, the center of the tetrahedron will be at the origin, one vertex will lie on the z axis, one face parallel to the x, y plane, and one edge parallel to the x axis.
Here's a code that does a similar thing for points in three dimensions, but it doesn't seem obvious how to increase it to 4. Basically I am looking for the 4th equivalent of tosimplex functions (which takes 4 dimensions in 3) and it is inverse from simple
A = Sqrt [2/3] {Cos [#], Sin [#], Sqrt [1/2]} & / @
Table [Pi / 2 + 2 Pi / 3 + 2 k Pi / 3, {k, 0, 2}] // Transpose;
B = Inverse [A];
tosimplex [{x_, y_, z_}]: = Most [A. {x, y, z}];
fromsimplex [{u_, v_}]: = B. {u, v, Sqrt [1/3]};
(* checks *)
extreme = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
Graphics [Polygon [tosimplex / @ extreme]]
fromsimplex [tosimplex [#]] == # & / @ extreme Answer:
direct reformulation of the deinst answer in terms of matrices gives the following. (1 / sqrt [4] appears as the 4th coordinate, because this is the distance to the simplex center)
A = Transpose [{{- (1/2), - (1 / (2 Sqrt [3])), - (1 / (2 Sqrt [6])),
1 / Sqrt [4]}, {1/2, - (1 / (2 Sqrt [3])), - (1 / (2 Sqrt [6])),
1 / Sqrt [4]}, {0, - (1 / (2 Sqrt [3])) + Sqrt [3] / 2, - (1 / (2 Sqrt [6])),
1 / Sqrt [4]}, {0, 0, Sqrt [2/3] - 1 / (2 Sqrt [6]), 1 / Sqrt [4]}}];
B = Inverse [A];
tosimplex [{x_, y_, z_, w_}]: = Most [A. {x, y, z, w}];
fromsimplex [{t_, u_, v_}]: = B. {t, u, v, 1 / Sqrt [4]};
(* Checks *)
extreme = Table [Array [Boole [# == i] &, 4], {i, 1, 4}];
Graphics3D [Sphere [tosimplex [#], .1] & / @ extreme]
fromsimplex [tosimplex [#]] == # & / @ extreme