1
$\begingroup$

I got an $N$-dimensional cuboid ($N>1$) with different edge lengths. How can I convert the position of a point into a number, so it's unique and "dense"?

For example, the edge sizes of a 4-dimensional cuboid are:

$$(20, 3, 5, 6)$$

Now the edge lengths can take up these values:

$$0..19, 0..2, 0..4, 0..5$$

Here I have a point, for example: $$(14, 3, 1, 3)$$ How can I convert this to a single, unique number (let's call it index)?

Criteria for the conversion:

1) The space for these indexes should be "dense" (every number between $0$ and $1799$ should represent a coordinate)
2) Two different coordinates should never translate to the same index.
3) All indexes will be between $0$ and $20\cdot 3 \cdot 5\cdot 6 - 1 = 1799$.

We can assume that all numbers are integers.

$\endgroup$
5
  • 1
    $\begingroup$ Are the points only integer coordinates? $\endgroup$ Oct 26, 2017 at 16:44
  • $\begingroup$ @frogeyedpeas yes $\endgroup$
    – sydd
    Oct 26, 2017 at 16:46
  • $\begingroup$ Let $M$ be an integer greater than all your edge lengths. Then let $(c_1, c_2, c_3, c_4)$ be a point we have a unique number $M^3 (c_1) + M^2 (c_2) + M(c_3) + c_4$ we can identify it with $\endgroup$ Oct 26, 2017 at 16:48
  • $\begingroup$ @frogeyedpeas That does not satisfy criteria #2 and #3. $\endgroup$
    – sydd
    Oct 26, 2017 at 17:10
  • $\begingroup$ Ah, I missed those $\endgroup$ Oct 26, 2017 at 17:10

2 Answers 2

3
$\begingroup$

You can just use the way computers store arrays. Take $(i,j,m,n)$ to $i+20j+20\cdot 3m + 20\cdot 3 \cdot 5n$

$\endgroup$
2
  • $\begingroup$ Yep, I am looking for something like this...Just dont see why its correct. $\endgroup$
    – sydd
    Oct 26, 2017 at 17:57
  • $\begingroup$ Try it by hand for three dimensions, say $2 \times 3 \times 4$ and you will see. It is just the reverse of the dictionary order. $n$ is the most important coordinate, then $m$ and so on. $\endgroup$ Oct 26, 2017 at 18:05
1
$\begingroup$

Each lattice point belonging to your cuboid is encoded as an integer quadruple $$(x_1,x_2,x_3,x_4)\in[0..20]\times[0..3]\times[0..5]\times[0..6]\ .$$ Since there are $21\cdot4\cdot6\cdot 7=3528>1800$ admissible quadruples there is no bijective numbering of these quadruples using only the numbers in $[0..1800]$.

$\endgroup$
1
  • $\begingroup$ Oops sorry the example is not clear. The edge coordinates in the example are between ´0..19, 0..2, 0..4, 0..5´, so their product is 1800. $\endgroup$
    – sydd
    Oct 26, 2017 at 17:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .