|
![](/i/fill.gif) |
Jaap Frank <jjf### [at] xs4all nl> wrote in message
news:3f116f7b$1@news.povray.org...
> Maybe this is already known, but it might be handy for someone.
>
> If you want a very high dimensional array, this can be done.
> Further you can extract a peace of an array.
>
> // --------- Start of code ----------------------------------------
> #declare A = array[2][2][2]
> #declare B = array[2][2][2]
> #declare C = array[2][2][2]
> // Connect the arrays
> #declare B[0][0][0] = C
> #declare A[0][0][0] = B
> // Initiate something
> #declare A[0][0][0][0][0][0][0][0][0]=0.345;
> // Extract a piece
> #declare D = A[0][0][0][0][0][0]
This is basically what I did for my Architecture IRTC entry
http://www.irtc.org/ftp/pub/stills/2003-04-30/rows_rg.jpg ) except I did it
the hard way of coding everything in line;
#declare A= array [some_variable]
{
array [another_array[0]] {...array data...},
array [another_array[1]] {...array data...},
array [another_array[2]] {...array data...}
}
I never thought to pre-declare the arrays and connect them like you did.
Your way looks like it has a lot more flexibility. I ended up with around
15 large complex arrays. By pre-declaring the smaller arays I could have
probably built a lot of them on the fly using loops and reading the data
from a file. Thanks for the input, I'll definitely remember that next time
I need to do something similar!
>
> Amazingly POV does not get confused!!
No, but I sure did! It took me most of the two months of the round figuring
out what needed to get where!
> This way it is also possible to put different things into one total array.
> In one subarray you can put objects and in other subarrays some
> different kind of variables.
> So you can build your own multi variable type array.
Yes, and the arrays can be different sizes, while a normal multi-dimensional
array all dimensions have to be the same. Another advantage (and the main
reason I did it this way!) is you can then pass one dimension of the array
to a macro, since in a normal multi-dimensional array POV does not permit
referencing only one dimension.
This isn't allowed;
#declare Objects = array [n][m] {...n+m stuff...}
MyMacro( Objects[n] )
While this is;
#declare Objects = array [n]{...n arrays...}
MyMacro( Objects[n] )
The POV master gurus probably already know this, but for a mere mortal like
myself this was a major breakthru!
Thanks for adding your .02!
RG
Post a reply to this message
|
![](/i/fill.gif) |