POV-Ray : Newsgroups : povray.general : Linked Arrays Server Time
29 Jul 2024 16:19:24 EDT (-0400)
  Linked Arrays (Message 1 to 9 of 9)  
From: Leroy Whetstone
Subject: Linked Arrays
Date: 2 May 2011 14:35:37
Message: <4DBEF925.30905@joplin.com>
I've been playing around with arrays(ver 3.6). You know how POV 
handles arrays, one type of element per array. (float, vector, color, 
...)I do a lot of animation. So some times I have several arrays that 
are linked to one object. I usually made the arrays for each POV project 
and handled the arrays individually.
  I thought 'Why can't POV be more C++ like and use classes?' Well it 
can't! I won't complain It's one great rendering tool!
  But I can make a POV scrip that can produce a set of arrays that are 
linked by name and use macros that treat those arrays as one virtual 
array. I'm sure the idea isn't new.
  Before I give the completed version to the POV community. What macros 
would you like to be there?
  I have: Put, Get, Trade, Copy, Sort, so far.
   Put - Put values in virtual array
   Get - Get values from virtual array
   Trade - Trade one virtual array element with another
   Copy -  Copy  one virtual array element with another
   Sort -  This lets you choose an array to use to
           sort the rest of the virtual array. The
           array you chose must have float values in it.
           Final arrangement is from lowest to highest.
I'll put a copy of LinkMaker in P.B utilities
Your comments and suggestions are welcomed.


Post a reply to this message

From: Darren New
Subject: Re: Linked Arrays
Date: 2 May 2011 14:37:10
Message: <4dbef9d6$1@news.povray.org>
On 5/2/2011 11:34, Leroy Whetstone wrote:
> Trade - Trade one virtual array element with another

The usual term for this is "Swap", if I understand what you're saying. It's 
probably better to stick with the common terms.

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

From: Leroy Whetstone
Subject: Re: Linked Arrays
Date: 2 May 2011 14:46:00
Message: <4DBEFB94.2090702@joplin.com>
Darren New wrote:
> On 5/2/2011 11:34, Leroy Whetstone wrote:
> 
>> Trade - Trade one virtual array element with another
> 
> 
> The usual term for this is "Swap", if I understand what you're saying. 
> It's probably better to stick with the common terms.
> 

  Your right. When I'm working good, I rarely think along those lines.


Post a reply to this message

From: Warp
Subject: Re: Linked Arrays
Date: 3 May 2011 11:24:00
Message: <4dc01e10@news.povray.org>
Leroy Whetstone <lrw### [at] joplincom> wrote:
>    Sort -  This lets you choose an array to use to
>            sort the rest of the virtual array. The
>            array you chose must have float values in it.
>            Final arrangement is from lowest to highest.

  The standard arrays.inc already provides a Sort_Array() macro.

http://wiki.povray.org/content/Documentation:Reference_Section_7#arrays.inc

-- 
                                                          - Warp


Post a reply to this message

From: Leroy Whetstone
Subject: Re: Linked Arrays
Date: 3 May 2011 16:36:15
Message: <4DC066EA.8080508@joplin.com>
Warp wrote:
>   The standard arrays.inc already provides a Sort_Array() macro.
> 
> http://wiki.povray.org/content/Documentation:Reference_Section_7#arrays.inc
> 

True, but it does one array! It doesn't move associated arrays with it. 
My idea is you have a group of arrays linked so if you sort using one of 
them all the others are also move around. The Sort_Array() macro could 
be modified to do so. You would have to rewrite it for every time the 
number of arrays you have changed. I basically do that rewrite for ya.
  What I had in mind is you put the Master name and all the sub names 
into 'Linker' and it would make all the arrays and macros you need.
  As an example I want a 50 element array of Robots. I'd use 'Robot' as 
the Master and subs of 'Color', 'Location' and 'Active'. 'Linker' will 
make this:

   #declare RoBot_Color=array[50];
   #declare RoBot_Location=array[50];
   #declare RoBot_Active=array[50];
  #macro RoBot_Put(Element,ColorV,LocationV,ActiveV)...
  #macro RoBot_Get(Element,ColorV,LocationV,ActiveV)...
  #macro RoBot_Swap(Element1,Element2)...
  #macro RoBot_Copy(Element1,Element2)...
  #macro RoBot_Sort(Array)...

Now all I have to do is fill up the arrays and do something with them.
The macros will only work with the 3 arrays. Now back to 'Sort' the way 
I it is now I didn't use the Sort_Array() from 'arrays.inc'. I made an 
simpler one that was easier to write to file.


Post a reply to this message

From: Warp
Subject: Re: Linked Arrays
Date: 3 May 2011 17:00:20
Message: <4dc06ce4@news.povray.org>
Leroy Whetstone <lrw### [at] joplincom> wrote:

> Warp wrote:
> >   The standard arrays.inc already provides a Sort_Array() macro.
> > 
> > http://wiki.povray.org/content/Documentation:Reference_Section_7#arrays.inc
> > 

> True, but it does one array! It doesn't move associated arrays with it. 
> My idea is you have a group of arrays linked so if you sort using one of 
> them all the others are also move around. The Sort_Array() macro could 
> be modified to do so. You would have to rewrite it for every time the 
> number of arrays you have changed.

  You don't need to rewrite it. You simply implement your own comparison
and swapping macros (Sort_Compare() and Sort_Swap_Data()) to perform those
operations.

-- 
                                                          - Warp


Post a reply to this message

From: Le Forgeron
Subject: Re: Linked Arrays
Date: 4 May 2011 03:26:02
Message: <4dc0ff8a$1@news.povray.org>
Le 03/05/2011 23:00, Warp a écrit :
> Leroy Whetstone <lrw### [at] joplincom> wrote:
> 
>> Warp wrote:
>>>   The standard arrays.inc already provides a Sort_Array() macro.
>>>
>>> http://wiki.povray.org/content/Documentation:Reference_Section_7#arrays.inc
>>>
> 
>> True, but it does one array! It doesn't move associated arrays with it. 
>> My idea is you have a group of arrays linked so if you sort using one of 
>> them all the others are also move around. The Sort_Array() macro could 
>> be modified to do so. You would have to rewrite it for every time the 
>> number of arrays you have changed.
> 
>   You don't need to rewrite it. You simply implement your own comparison
> and swapping macros (Sort_Compare() and Sort_Swap_Data()) to perform those
> operations.
> 
Why sorting the other arrays if you can use explicit indirection instead ?

Let's A[] be the array to be sorted, and B[], C[], D[]... the associated
data.

You can of course re-order/swap items in A, and then swap also B, C, ...

Or you can leave A as it is, and compute an ordering array XOX[] of integer.

So that accessing the first element is no more A[0], B[0],... but
A[XOX[0]], B[XOX[0]]

The best data are the data that do not move. The order is in the eye of
the user.


Post a reply to this message

From: Leroy Whetstone
Subject: Re: Linked Arrays
Date: 4 May 2011 10:47:39
Message: <4DC166B4.4000603@joplin.com>
Le_Forgeron wrote:
> Le 03/05/2011 23:00, Warp a écrit :
> 
>>Leroy Whetstone <lrw### [at] joplincom> wrote:
>>
>>
>>>Warp wrote:
>>>
>>>>  The standard arrays.inc already provides a Sort_Array() macro.
>>>>
>>>>http://wiki.povray.org/content/Documentation:Reference_Section_7#arrays.inc
>>>>
>>>
>>>True, but it does one array! It doesn't move associated arrays with it. 
>>>My idea is you have a group of arrays linked so if you sort using one of 
>>>them all the others are also move around. The Sort_Array() macro could 
>>>be modified to do so. You would have to rewrite it for every time the 
>>>number of arrays you have changed.
>>
>>  You don't need to rewrite it. You simply implement your own comparison
>>and swapping macros (Sort_Compare() and Sort_Swap_Data()) to perform those
>>operations.
>>
> 
> Why sorting the other arrays if you can use explicit indirection instead ?
> 
> Let's A[] be the array to be sorted, and B[], C[], D[]... the associated
> data.
> 
> You can of course re-order/swap items in A, and then swap also B, C, ...
> 
> Or you can leave A as it is, and compute an ordering array XOX[] of integer.
> 
> So that accessing the first element is no more A[0], B[0],... but
> A[XOX[0]], B[XOX[0]]
> 
> The best data are the data that do not move. The order is in the eye of
> the user.
> 
True I've use that before when dealing with a very large data set.


Post a reply to this message

From: Leroy Whetstone
Subject: Re: Linked Arrays
Date: 4 May 2011 11:09:17
Message: <4DC16BC6.3040501@joplin.com>
Warp wrote:
>   You don't need to rewrite it. You simply implement your own comparison
> and swapping macros (Sort_Compare() and Sort_Swap_Data()) to perform those
> operations.
> 

You right about that. I went through arrays.inc again, what you say is 
true, And it wouldn't be that hard to write to file. Maybe my 
reluctance was 'KISS' (Keep It Simple Stupid). I get a little antsy when 
code isn't all in one place. A lot of times if I need an item from an 
include file I just copy it and place it where needed.

  But what do you think of linked arrays?


Post a reply to this message

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