POV-Ray : Newsgroups : povray.advanced-users : Colefax Spline Macro Server Time
31 Oct 2024 08:17:55 EDT (-0400)
  Colefax Spline Macro (Message 1 to 4 of 4)  
From: Russell Towle
Subject: Colefax Spline Macro
Date: 20 Mar 2008 11:00:01
Message: <web.47e289096402f3c9713ab470@news.povray.org>
I've been using Chris Colefax's wonderful spline macro.

However, I have a problem. When I try to fill the array of values using a #while
loop, a parse error is generated, "Insufficent number of initializers." Here is
what I am doing:

#declare N = 5;  #declare J = 1;
#declare MyPath = create_spline (
array[ N ]{
 #while( J<=5)
 <cos(2*pi*J/N), 1, sin(2*pi*J/N)>
 #declare J = J + 1;
 #end
},
spline_loop (no) + spline_tension (-1) + spline_sampling (2) +  spline_scale (5)
)

Why the error? How can I use a #while loop to make the values needed by
create_spline?

Thanks.


Post a reply to this message

From: Dan Byers
Subject: Re: Colefax Spline Macro
Date: 20 Mar 2008 14:05:01
Message: <web.47e2b4f3976b7b23a8d0b25a0@news.povray.org>
Looks like the problem is in the array declaration; if I declare the array using
that #while loop before I put it in create_spline(), it blows up on me, too.

// generates error
#local N = 5;
#local x = 1;
#declare my_array = array[ N ] {
  #while( x <= N )
  ...
  #local x = x + 1; #end
}

Probably have to do it the old fashioned way:

#declare my_array = array[ N ]
#local i = 0; #while( i < N )
   #declare my_array[ i ] = ....
#local i = i + 1; #end

I may be wrong.  It's happened before (more times than I care to remember)...

--
Dan
GoofyGraffix.com


Post a reply to this message

From: Thomas de Groot
Subject: Re: Colefax Spline Macro
Date: 25 Mar 2008 05:02:05
Message: <47e8cd9d$1@news.povray.org>
I think that if you use X instead of x, your problem will be solved. Small 
letter x is reserved I believe.

Thomas


Post a reply to this message

From: Alain
Subject: Re: Colefax Spline Macro
Date: 25 Mar 2008 09:21:50
Message: <47e90a7e$1@news.povray.org>
Dan Byers nous apporta ses lumieres en ce 2008/03/20 15:03:
> Looks like the problem is in the array declaration; if I declare the array using
> that #while loop before I put it in create_spline(), it blows up on me, too.
> 
> // generates error
> #local N = 5;
> #local x = 1;
> #declare my_array = array[ N ] {
>   #while( x <= N )
>   ...
>   #local x = x + 1; #end
> }
> 
> Probably have to do it the old fashioned way:
> 
> #declare my_array = array[ N ]
> #local i = 0; #while( i < N )
>    #declare my_array[ i ] = ....
> #local i = i + 1; #end
> 
> I may be wrong.  It's happened before (more times than I care to remember)...
> 
> --
> Dan
> GoofyGraffix.com
> 
> 
> 
> 
Guide line for the naming of user variables: Always start the variable name with 
an uper case letter. It prevent name conflicts with reserved words and 
predefined variables names. Those always start with a lower case leter.

Here, "x" is a predefined variable. You can't define your variables using that 
name. Use "X" instead. Even if "i" is not reserved, it's beter to use "I" as a 
variable name.

Reserved single leters variable names: t, u, v, x, y and z

-- 
Alain
-------------------------------------------------
You know you've been raytracing too long when whenever you write include, even 
in essays, etc, you always add a "#".


Post a reply to this message

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