POV-Ray : Newsgroups : povray.advanced-users : <no subject> : Re: <no subject> Server Time
19 May 2024 22:59:23 EDT (-0400)
  Re: <no subject>  
From: Leroy
Date: 4 Jul 2023 14:20:00
Message: <web.64a461c46f92e856f47dfe88f712fc00@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> So, I had some experiments I wanted to try, but I need to make some functions
> that are based on other functions.
> In order to vary what base function I use, I have to do that with a macro, which
> seems to work fine, but I seem to be missing something, either in the creation
> syntax or the invocation syntax.
>
>
> #declare Zero = function (N) {0}
> #declare One = function (N) {1}
>
>
> #macro MakeFunction (Function)
>  function {Function (0) + 1}
> #end
>
> #declare Two = MakeFunction (One);
>
> #debug concat( "Zero = ", str (Zero (10), 0, 3), "\n")
> #debug concat( "One = ", str (One (10), 0, 3), "\n")
>
> #declare Val = Two (10);
>
> #debug concat( "Two = ", str (Val, 0, 3), "\n")
>
> That gets me:
>
> Parse Error: Expected 'numeric expression', ) found instead
>
> I have yet to find a way around that.  Though I could swear that I've done
> something similar to this before....
>
Here's a macro that will do what you want maybe.
It returns a function of a function

#macro Sf_Inv(F1) //inverse ground values
  function(x,z){1-F1(x,z)}
#end

use like this:

#declare F1=function(x,z){what ever}
#declare FncA=function(x,z){Sf_Inv(F1)}
#declare B=FncA(6,7);

I took this off a whole list of functions I was playing with a while back.
With this basic syntax you can put togather several functions and values to get
some interesting and hopeful useful functions.
Have Fun!


Post a reply to this message

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