POV-Ray : Newsgroups : povray.advanced-users : Array Usage Server Time
30 Jul 2024 10:25:22 EDT (-0400)
  Array Usage (Message 1 to 5 of 5)  
From: Ken
Subject: Array Usage
Date: 1 Aug 1999 18:17:33
Message: <37A4C6D4.2DE07985@pacbell.net>
I posted some source in povray.binaries.scene-files today in a thread
titled "Connect the Dots Macro example".

If any of you code warriors out there are interested in looking at this
example and suggesting an easier way of passing the points to the macro
I would be glad to listen. I have doubts the second array was necessary
but it was the only way I could come up with using the macro in it's
current form.

Thanks,

-- 
Ken Tyler
  
mailto://tylereng@pacbell.net
http://home.pacbell.net/tylereng/links.htm


Post a reply to this message

From: Nieminen Mika
Subject: Re: Array Usage
Date: 2 Aug 1999 03:41:27
Message: <37a54ba7@news.povray.org>
Ken <tyl### [at] pacbellnet> wrote:
: If any of you code warriors out there are interested in looking at this
: example and suggesting an easier way of passing the points to the macro
: I would be glad to listen. I have doubts the second array was necessary
: but it was the only way I could come up with using the macro in it's
: current form.

  I didn't quite understand what exactly is the problem.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Ken
Subject: Re: Array Usage
Date: 2 Aug 1999 07:10:51
Message: <37A57C07.5529BC9F@pacbell.net>
Nieminen Mika wrote:
> 
> Ken <tyl### [at] pacbellnet> wrote:
> : If any of you code warriors out there are interested in looking at this
> : example and suggesting an easier way of passing the points to the macro
> : I would be glad to listen. I have doubts the second array was necessary
> : but it was the only way I could come up with using the macro in it's
> : current form.
> 
>   I didn't quite understand what exactly is the problem.

  There is really not so much a problem as there is a possible inefficient
method being used. The cone connect macro requires four inputs eg:

#declare Connect = 
macro( start_point, first_radius, end_point, second_radius )

The array I am using is a 2d array with 73 data entries eg:

#declare     Bnum = 73;
#declare B_spline =
array [Bnum][2] {
{0.0000,  0.3750},
{0.0070,  0.3750},
{0.0060,  0.3750},
{0.0208,  0.3750},
...

When passing the data stored in the array to the macro I cannot simply use
the data from one array because I end up with the start point and end point
of the cone in the same place which causes an illegal operation in pov.
To avoid this I made a second array nearly identical to the first with
the exception that the first line of data was removed so I had different
start points and end points eg:


#declare     Bnum = 73;
#declare B_spline =
array [Bnum][2] {
{0.0000,  0.3750},
{0.0070,  0.3750},
{0.0060,  0.3750},
{0.0208,  0.3750},
...


#declare     Cnum = 72;
#declare C_spline =
array [Cnum][2] {
{0.0070,  0.3750}, // this is the second data point of array above
{0.0060,  0.3750},
{0.0208,  0.3750},
{0.0473,  0.3743},
...

  #declare Connected_Spheres =
 union{
  #declare ab=0;
   #while (ab<Cnum)
    object {
   Connect (
            <B_spline[ab][0], B_spline[ab][1], 0>, 0.1,
            <C_spline[ab][0], C_spline[ab][1], 0>, 0.1 )
           }
   #declare ab = ab + 1;
  #end     }

The first array is also being used to position the spheres which represent
the start and end points for the connnect macro eg:

  #declare Connect_These_Spheres =
 union{
  #declare a=0;
   #while (a<Bnum)
    sphere {<B_spline[a][0],B_spline[a][1],0>,.01 }
  #declare a = a + 1;
 #end }

  So my question is if there is a way to use only one array instead of having
to duplicate the data by using a second array which is nearly identical to the
first minus the first data entry in the second array. If it sounds confusing
it is because I am confused or I am simply doing it the right way to begin
with :)

-- 
Ken Tyler
  
mailto://tylereng@pacbell.net
http://home.pacbell.net/tylereng/links.htm


Post a reply to this message

From: Nieminen Mika
Subject: Re: Array Usage
Date: 2 Aug 1999 08:07:43
Message: <37a58a0f@news.povray.org>
Perhaps the problem was too simple to a programmer like me to see it.

: To avoid this I made a second array nearly identical to the first with
: the exception that the first line of data was removed so I had different
: start points and end points

:    Connect (
:             <B_spline[ab][0], B_spline[ab][1], 0>, 0.1,
:             <C_spline[ab][0], C_spline[ab][1], 0>, 0.1 )

  Can't you just do it this way:

   Connect (
            <B_spline[ab][0], B_spline[ab][1], 0>, 0.1,
            <B_spline[ab+1][0], B_spline[ab+1][1], 0>, 0.1 )

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Ken
Subject: Re: Array Usage
Date: 2 Aug 1999 09:01:34
Message: <37A595FB.ED0808E3@pacbell.net>
Nieminen Mika wrote:
> 
>   Perhaps the problem was too simple to a programmer like me to see it.
> 
> : To avoid this I made a second array nearly identical to the first with
> : the exception that the first line of data was removed so I had different
> : start points and end points
> 
> :    Connect (
> :             <B_spline[ab][0], B_spline[ab][1], 0>, 0.1,
> :             <C_spline[ab][0], C_spline[ab][1], 0>, 0.1 )
> 
>   Can't you just do it this way:
> 
>    Connect (
>             <B_spline[ab][0], B_spline[ab][1], 0>, 0.1,
>             <B_spline[ab+1][0], B_spline[ab+1][1], 0>, 0.1 )

Of course I could and it works exaclty as I would expect it to. :}

You know I had tried something similar but in the wrong part of the script:

Connect (
            <B_spline[ab][0  ], B_spline[ab][1  ], 0>, 0.01,
            <B_spline[ab][0+1], B_spline[ab][1+1], 0>, 0.01 )
    }

Which issues a subscript out of range error. I had the right idea just the
wrong method.

Thanks Warp,

-- 
Ken Tyler
  
mailto://tylereng@pacbell.net
http://home.pacbell.net/tylereng/links.htm


Post a reply to this message

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