POV-Ray : Newsgroups : povray.general : 3.1 array bug? : Re: 3.1 array bug? Server Time
13 Aug 2024 17:31:03 EDT (-0400)
  Re: 3.1 array bug?  
From: John Wingfield
Date: 28 Jul 1998 09:07:31
Message: <35BDBEE7.2AEA836B@kcl.ac.uk>
I'm having the same problem.  I need to initialise a 3 dimensional array,
and I don't really want to resort to declaring each element individually.
I've been initialising using the method quoted below.  Is this the correct
method?

Thanks

John


PoD wrote:

> POV-Ray 3.1 beta seems to have trouble initialising arrays of more than
> 2 dimensions.  It appears that the 'most significant' dimension index in
> a 3D array is not incremented when reading the initialising data.
>
> Here's a script which demonstrates what I'm talking about.
>
> -----------------------------begin POV
> code-----------------------------------
> // This 3D array does not get initialised properly
> // Only the last row is read into the array
> // and the values are put where those in the first row should be ie.
> A[0][0..2][0..2]
> // it seems that the data are overwritten
> #declare A = array[3][3][3]
> {
>         {
>                 {0,1,2},{3,4,5},{6,7,8}
>         },
>         {
>                 {9,10,11},{12,13,14},{15,16,17}
>         },
>         {
>                 {18,19,20},{21,22,23},{24,25,26}
>         }
> }
>
> // uncomment the line below to initialise array
> //#declare Init = on;
> #ifdef(Init)
> #declare I = 0; #while(I < 27)
>         #declare X = mod(I,3);
>         #declare Y = mod(I/3,3);
>         #declare Z = mod(I/9,3);
>         #declare A[Z][Y][X] = I;
>         #declare I = I + 1;#end
> #end
>
> // Read the values and send them to the DEBUG stream
> #declare I = 0; #while(I < 27)
>         #declare X = mod(I,3);
>         #declare Y = mod(I/3,3);
>         #declare Z = mod(I/9,3);
>         #declare N = A[Z][Y][X];
>         #debug concat( "I = ",str(I,2,0),", N = ",str(N,2,0),"\n")
>         #declare I = I + 1;#end
> ------------------------------end POV
> code-----------------------------------
>
> Cheers, PoD.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.