POV-Ray : Newsgroups : povray.advanced-users : Array irritation. : Re: Array irritation. Server Time
29 Jul 2024 22:30:01 EDT (-0400)
  Re: Array irritation.  
From: Michael Andrews
Date: 17 Oct 2000 14:25:20
Message: <39EC99EF.283EA738@reading.ac.uk>
ian mcdonald wrote:
> 
> Hello,
> 
> I am attempting to learn the use of Arrrays for positioning of objects.
> It works, a little.
> 
> I have a [3][10] array. I wish to use all data therein by counting down with
> while loops. I wish for the loop to first use all 10 values from 3, then all
> ten from 2 and lastly all 10 from 1.
> 
> I can't make code to do this. I am now very irritated.
> 
> The data in the array is controlled by two while loops that surround all of
> this; this part works.
> 
> It seems that no computer/programming language of any sort works as I think
> it should, I can't do as I wish with arrays, loops or etc.. Everything is
> too dependant.
> 
> My main problem is creation of data in a loop, storage of this data, and
> retrieval for usage outside the loops the data was generated with.
> 
> I'm not sure my sourcecode will help any, but I'll post it if needed.
> 
> Suggestions?
> 
> ian

// to declare the array
#declare MyArray = array[3][10] // remember :- indices [0..2][0..9]

// to initialise the array
#declare Index1 = 0; #while (Index1 < 3)
  #declare Index2 = 0; #while (index2 < 10)
    #declare MyAray[Index1][Index2] = Whatever_You_Want_To_Put;
  #declare Index2 = Index2 + 1; #end
#declare Index1 = Index1 + 1; #end

// to read the array as specified
#declare Index1 = 2; #while (Index1 >= 0)
  #declare Index2 = 9; #while (Index2 >= 0)
    #declare My_Retrieved_Value = My_Array[Index1][Index2];
  #declare Index2 = Index2 - 1; #end
#declare Index1 = Index1 - 1; #end

Hope this helps,
	Mike Andrews.


Post a reply to this message

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