POV-Ray : Newsgroups : povray.programming : POV-Ray v.4 proposal Server Time
29 Jul 2024 02:31:22 EDT (-0400)
  POV-Ray v.4 proposal (Message 11 to 16 of 16)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Margus Ramst
Subject: Re: POV-Ray v.4 proposal
Date: 18 May 1999 12:02:30
Message: <37418106.0@news.povray.org>
This would be trivial to implement with macros. Especially when (if) the
Superpatch's #ifdef(Array[Elem]) function makes it into the official
version. Until then the size of the array would need to be specified.
For example, array rotate:

#macro ARot(Array,ArraySize,RotVect)
    #local C=0;
    #local NewArray=array[ArraySize]
    #while(C<ArraySize)
        #local NewArray[C]=vrotate(Array[C],RotVect);
        #local C=C+1;
   #end
   NewArray
#end

#declare Array1=array[N]{...}
#declare Array2=ARot(Array1,N,<XRot,YRot,ZRot>)

Margus

J. Grimbert wrote in message <3740210A.4E1BDC0E@atos-group.com>...
>
>What is needed is probably more something like array operator.
>After all, pov have :
> rotate and translate for objects
> vrotate and + for vectors
>
>We may probably get a nice enhancement with something like
> arotate and atranslate for array of vector
>
>#declare new_array = arotate(old_array, B );
>
>and
>#declare new_array = atranslate(old_array, B);
>
>BTW, we could also need some scaling:
>#declare new_array = ascale(old_array, B);
>


Post a reply to this message

From: Ron Parker
Subject: Re: POV-Ray v.4 proposal
Date: 18 May 1999 13:23:46
Message: <37419412.0@news.povray.org>
On Tue, 18 May 1999 17:59:48 +0300, Margus Ramst wrote:
>This would be trivial to implement with macros. Especially when (if) the
>Superpatch's #ifdef(Array[Elem]) function makes it into the official
>version. Until then the size of the array would need to be specified.

No need for the #ifdef patch.  In fact, it will fail if you try to
access past the end of the array anyway.  What you need is this, 
from the official POV 3.1:

  dimension_size( ARRAY_IDENTIFIER, FLOAT ) Returns the size of a given 
  dimension of a previously declared array identifier. Dimensions are 
  numbered left-to-right starting with 1. For example if you do 
  #declare MyArray=array[6][10] then dimension_size(MyArray,2) returns 
  the value 10. 

and your macro becomes:

#macro ARot(Array,RotVect)
    #local C=dimension_size(Array,1);
    #local NewArray=array[C]
    #while(C>0)
        #local C=C-1;
        #local NewArray[C]=vrotate(Array[C],RotVect);
   #end
   NewArray
#end

or, to transform an array "in place":

#macro AInPlaceRot(Array,RotVect)
    #local C=dimension_size(Array,1);
    #while(C>0)
        #local C=C-1;
        #declare Array[C]=vrotate(Array[C],RotVect);
   #end
#end


Post a reply to this message

From: Mikael Carneholm
Subject: Re: POV-Ray v.4 proposal
Date: 18 May 1999 14:28:06
Message: <3741A280.8BF5059D@ida.utb.hb.se>
Ron Parker wrote:

> No need for the #ifdef patch.

What if you do this:

#declare MyArray=array[3]
#declare MyArray[0]="A"
#declare MyArray[2]="C"

How do you check if MyArray[1] is declared...?

- Mikael.

-----------------------------------------------------------------
Mikael Carneholm
Dep. of Computer Science


http://www.studenter.hb.se/~arch
E-mail: sa9### [at] idautbhbse


Post a reply to this message

From: Ron Parker
Subject: Re: POV-Ray v.4 proposal
Date: 18 May 1999 14:39:10
Message: <3741a5be.0@news.povray.org>
On Tue, 18 May 1999 19:25:20 +0200, Mikael Carneholm wrote:
>Ron Parker wrote:
>
>> No need for the #ifdef patch.
>
>What if you do this:
>
>#declare MyArray=array[3]
>#declare MyArray[0]="A"
>#declare MyArray[2]="C"
>
>How do you check if MyArray[1] is declared...?

More importantly, how do you check if MyArray[0] is a vector?
I'm not saying it wouldn't help, but you don't need it just
to get the array size, as you seemed to imply.


Post a reply to this message

From: Margus Ramst
Subject: Re: POV-Ray v.4 proposal
Date: 18 May 1999 19:45:54
Message: <3741eda2.0@news.povray.org>
Hell and damnation!!!! I could swear I read all about float functions and
arrays, and never did I see these functions. Now they're there. To think how
much trouble this would've saved me in the past...
Oh well, thank you for pointing it out.

Margus

Ron Parker wrote in message <37419412.0@news.povray.org>...
>
>No need for the #ifdef patch.  In fact, it will fail if you try to
>access past the end of the array anyway.  What you need is this,
>from the official POV 3.1:
>
>  dimension_size( ARRAY_IDENTIFIER, FLOAT ) Returns the size of a given
>  dimension of a previously declared array identifier. Dimensions are
>  numbered left-to-right starting with 1. For example if you do
>  #declare MyArray=array[6][10] then dimension_size(MyArray,2) returns
>  the value 10.
>


Post a reply to this message

From: Margus Ramst
Subject: Re: POV-Ray v.4 proposal
Date: 18 May 1999 19:57:13
Message: <3741f049.0@news.povray.org>
To put things straight, #ifdef was my suggestion. I now see that it really
isn't necessary.
It should be up to the user to know that the manipulated array contains
vectors. Or values could be forced to vectors in the macro (value+<0,0,0> or
something similar).
Right now I can't think of a common situation where an intermittent array
element would be missing (it has never happened in the procedures I use with
arrays). But #ifdef could be used as a check here.

Margus

Ron Parker wrote in message <3741a5be.0@news.povray.org>...
>On Tue, 18 May 1999 19:25:20 +0200, Mikael Carneholm wrote:
>>Ron Parker wrote:
>>
>>> No need for the #ifdef patch.
>>
>>What if you do this:
>>
>>#declare MyArray=array[3]
>>#declare MyArray[0]="A"
>>#declare MyArray[2]="C"
>>
>>How do you check if MyArray[1] is declared...?
>
>More importantly, how do you check if MyArray[0] is a vector?
>I'm not saying it wouldn't help, but you don't need it just
>to get the array size, as you seemed to imply.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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