|
![](/i/fill.gif) |
Wasn't it The Ugly who wrote:
>I would like to make a macro that visualises mathematical functions.
>Something like this would be nice.
>
>
>
>
>#macro MyFunc(Length,Formula)
>
>#local N=0;
>
>#while (N<=Length)
>
>sphere { 0, 0.02
> pigment { rgb <N,0,N*-1+1> }
> translate <N,Formula,0>
> }
>
>#local N=N+0.1;
>
>#end
>
>#end
You've just made one tiny syntax error in that macro.
Here's a complete scene that works.
camera {location <5,0,-20> look_at <5,0,0> angle 30}
background {rgb 1}
light_source {<-30, 100, -30> color rgb 1}
#macro MyFunc(Length,Formula)
#local N=0;
#while (N<=Length)
sphere { 0, 0.02
pigment { rgb <N,0,N*-1+1> }
translate <N,Formula(N),0> // I changed this line
}
#local N=N+0.1;
#end
#end
// Call it with length and one-dimensional function
MyFunc(10, function(n){sin(n)} )
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
![](/i/fill.gif) |