POV-Ray : Newsgroups : povray.advanced-users : Array Usage : Re: Array Usage Server Time
2 Nov 2024 13:20:10 EDT (-0400)
  Re: Array Usage  
From: Ken
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

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