POV-Ray : Newsgroups : povray.advanced-users : Problems with splines Server Time
1 Nov 2024 03:15:49 EDT (-0400)
  Problems with splines (Message 1 to 3 of 3)  
From: SvenM
Subject: Problems with splines
Date: 27 May 2008 13:55:00
Message: <web.483c4aa5ca01857b257872660@news.povray.org>
Hi,

I'm trying to create a function that gets some values by a spline. But when I'm
trying to render the scene, the following error occurs:

"Expected 'operand', spline identifier found instead"

The simplest scene in which I found this error is something like that:

// First of all declare a spline - a circle made of 8 points with cubic spline
// I don't have any problems with this spline in other scenes
#declare SPL =
  spline {
    cubic_spline


    #declare SPLI=-1/8;
    #while (SPLI<=1+1/8)
    SPLI, <sin(2*pi*SPLI),0,cos(2*pi*SPLI)>
    #declare SPLI=SPLI+1/8;
    #end
  }


// now declare a function that calculates the average (arithmetic mean) of the
// x-values of the spline. "Exactness" says how many points I want to use.

 #declare xAverage=function(Exactness) {
 sum(i,0,Exactness,
     SPL(i/Exactness).x  // here the error occurs
    )
/(Exactness+1)
}


// end of file

Where is my mistake? Could you please help me? Is the sum the reason?
I'm using POV-Ray 3.7 (the beta version).

Thanks,
Sven


Post a reply to this message

From: Blue Herring
Subject: Re: Problems with splines
Date: 27 May 2008 15:07:00
Message: <483c5bd4$1@news.povray.org>
SvenM wrote:
> Hi,
> 
> I'm trying to create a function that gets some values by a spline. But when I'm
> trying to render the scene, the following error occurs:
> 
> "Expected 'operand', spline identifier found instead"
> 
> The simplest scene in which I found this error is something like that:
> 
> // First of all declare a spline - a circle made of 8 points with cubic spline
> // I don't have any problems with this spline in other scenes
> #declare SPL =
>   spline {
>     cubic_spline
> 
> 
>     #declare SPLI=-1/8;
>     #while (SPLI<=1+1/8)
>     SPLI, <sin(2*pi*SPLI),0,cos(2*pi*SPLI)>
>     #declare SPLI=SPLI+1/8;
>     #end
>   }
> 
> 
> // now declare a function that calculates the average (arithmetic mean) of the
> // x-values of the spline. "Exactness" says how many points I want to use.
> 
>  #declare xAverage=function(Exactness) {
>  sum(i,0,Exactness,
>      SPL(i/Exactness).x  // here the error occurs
>     )
> /(Exactness+1)
> }
> 
> 
> // end of file
> 
> Where is my mistake? Could you please help me? Is the sum the reason?
> I'm using POV-Ray 3.7 (the beta version).

Hi,
   Functions are restricted to what they can have inside of them, as 
they are able to be evaluated at render time.  However, I believe 
there's an easy fix for you.  Try creating a function from your spline 
and call that instead:

#declare SPL_F =
   function {
     spline { SPL }
   }

or

#declare SPL_F =
   function {
     spline {
       cubic_spline

       #declare SPLI=-1/8;
       #while (SPLI<=1+1/8)
       SPLI, <sin(2*pi*SPLI),0,cos(2*pi*SPLI)>
       #declare SPLI=SPLI+1/8;
       #end
     }
   }


-- 
-The Mildly Infamous Blue Herring


Post a reply to this message

From: SvenM
Subject: Re: Problems with splines
Date: 27 May 2008 15:20:00
Message: <web.483c5e2a4798a3da257872660@news.povray.org>
> Hi,
>    Functions are restricted to what they can have inside of them, as
> they are able to be evaluated at render time.  However, I believe
> there's an easy fix for you.  Try creating a function from your spline
> and call that instead:
>
> #declare SPL_F =
>    function {
>      spline { SPL }
>    }
>
> or
>
> #declare SPL_F =
>    function {
>      spline {
>        cubic_spline
>
>        #declare SPLI=-1/8;
>        #while (SPLI<=1+1/8)
>        SPLI, <sin(2*pi*SPLI),0,cos(2*pi*SPLI)>
>        #declare SPLI=SPLI+1/8;
>        #end
>      }
>    }
>

Thank you very much! It seems to work. IMHO it's a little bit confusing that
function{} doesn't allow to call a spline, but it CAN be a spline itself...

Yours, Sven


Post a reply to this message

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