# Thread: Three Dimensional Array Calculation/Formula

1. ## Three Dimensional Array Calculation/Formula

i'm needing to calculate how many elements are remaining in an array from a particular point. i figured out a way to do this with a two dimensional array:

Code:
```0,0     0,1     0,2
1,0     1,1    1,2
2,0     2,1     2,2(a)

2,2
-0,1
-----
2(b),1(c)

2(b) * (2(a) + 1) = 6(d)

6(d) + 1(c) = 7
```
so 7 spots from 0,1 to 2,2.

i can't figure out a formula that would work for 3+ dimensional arrays, however.

Code:
```0,0,0     0,0,1     0,0,2     0,0,3
0,1,0     0,1,1     0,1,2     0,1,3
1,0,0     1,1,1     1,1,2     1,1,3```
say from 0,0,2 to 1,1,3 - for example.

any suggestions? i'm assuming there's a formula out there somewhere, i just don't know what it is.

2. I posted a working formula in your other post.

3. i just figured one out, and it's pretty similar...

Code:
```2(a), 2(b), 3(c)
0(x), 1(y), 0(z)

((b * c) * ((a - 1) - x)) + (c * (b - 1) - y) + (c - 1) - z = n

so....

((2 * 3) * ((2 - 1) - 0)) + (3 * (2 - 1) - 1) + (3 - 1) - 0 = n
( 6    *        1)        +       0        +             2      = 8```

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•