The "Peano-Smith" curve PCS(t) in D dimensions is defined thus. Let the real number t have representation in "balanced ternary" (i.e. radix 3 with digit set {-1, 0, +1}) beginning with A as its most-significant trit, which is in the 3^k place for some integer k. Define ROT(x), where x is a D-dimensional vector, as the rotation-permutation of x, for example with D=3 we have ROT(x,y,z) = (y,z,x). PSC(t) := { compute A and k from t; s = t - A * 3^k; //chop off most-signif trit of t if(A==0){ s = -s; } v = ROT(PSC(s)); //recursive call; v[0,1,...,D-1] is D-dimensional real vector if(A==0){ v[0] = -v[0]; } v[0] = v[0] + A * Q * 3^(k/D); return v; } where Q is a scaling constant (I do not care what Q is, provided nonzero). It seems to me it is possible to implement this in O(1) arithmetic ops per trit via an un-recursivization of this code, assuming 3^(1/D) is pre-computed. (You avoid ever doing a ROT by instead walking indices mod D and keeping track of the sign change for each coordinate.) The "Peano-Smith curve" is based on the fact that a hyper-rectangle with sides 3^(k/D) for the kth side (k=1,2,3,...,D) can be divided, by trisecting the longest side, into 3 equally-scaled copies of the original shape. If D>=3 there is no simplex which can be divided, by bisecting longest edge, into 2 equally-scaled copies (perhaps mirrored) of original shape; but if D=2 such a simplex exists, namely 45-45-90 triangle. This leads to the Sierpinski curve in the plane, which has no higher dimensional analogue. -- Warren D. Smith http://RangeVoting.org <-- add your endorsement (by clicking "endorse" as 1st step)