|
![](/i/fill.gif) |
The Ugly wrote:
> #macro MyFunc(Length,Formula)
>
> <SNIP>
>
> But as you might see this is of little use.
> If this is to become usefull you have to be able to use it like this:
>
> MyFunc(N*N)
>
> In other words, you will have to be able to refere to the local N
> when you call it, but it hasnt been defined yet. If you try to define
> it before you call the macro it will calculate the value before passing
> it into the macro.
>
> Do I make any sense?
No, you do not. Your MyFunc macro takes two parameters. What is 'N*N' in
MyFunc(N*N)? Are you trying to pass this as a 'Length' or a 'Formula'?
Looks like your 'Formula' just returns a 'y' value, so this might get
you started:
#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> // this line is changed
}
#local N=N+0.1;
#end
#end
MyFunc ( 10, function(x){x*x} )
// or try
// union{ MyFunc( 10, function(x){sin(x)} ) translate <-5,-3,0>}
// union{ MyFunc( 10, function(x){cos(x)} ) translate <-5,0,0>}
// union{ MyFunc( 10, function(x){sin(cos(x))} ) translate <-5,3,0>}
camera {
location <0,0,-10>
look_at 0
}
-Shay
Post a reply to this message
|
![](/i/fill.gif) |