|
![](/i/fill.gif) |
Wasn't it Chris S. who wrote:
>error: no matching } in sphere_sweep, < found instead
>
>/////
>
>#declare Rand01 = seed(34747);
>#macro Tree_Root(X,Y,Z,R,L,Next)
> #declare counter=0;
> sphere_sweep {
> linear_sphere_sweep,
> 10,
> #while(Next>0)
> <X,Y,Z>,R
> #declare R=R/1.05;
> #local X=X-rand(Rand01)*2;
> #local Y=Y-rand(Rand01);
> #local Z=Z-rand(Rand01)*2;
> #declare Next=Next-.1;
> #declare counter=counter+1;
> #end
> }
>#end
>union{
>Tree_Root(0,0,0,2,1,1)
>pigment{color rgb <1,0,0>}}
>
>//////
It's a rounding error.
If you subtract .1 from 1 10 times you get a number that's not quite
exactly zero, because floating point arithmetic is never exact. So,
after the tenth iteration "Next" turns out to be very slightly greater
than zero, so "#while(Next>0)" is still true, and the eleventh iteration
produces the error.
Dirty fix: #while(Next>0.01)
Clean fix: #while(counter<10)
This is a better fix because it will work even if you call the Tree_Root
macro with the sixth parameter not equal to 1.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
![](/i/fill.gif) |