|
|
clipka <ano### [at] anonymousorg> wrote:
> Am 20.12.2010 07:49, schrieb TheBigH:
> > Why does this not work? It complains that I need to initialize X and Y before I
> > call them in the macro Fracp, but since I am passing them as parameters to the
> > function Gridd this would obviously be inappropriate. I have also tried changing
> > the macro into another function, but that doesn't work either.
> >
> >
> > #declare thick=0.05;
> > #macro Fracp(A)
> > A-floor(A)
> > #end
> > #declare Gridd = function( X, Y ) {
> > #if ( Fracp(X)<thick | Fracp(X)>(1-thick) | Fracp(Y)<thick | Fracp(Y)>(1-thick)
> > )
> > 1
> > #else
> > 0
> > #end
> > }
>
> Note that "#" statements are always evaluated at parsing time, even when
> used in a function. Therefore, "#if" statements cannot be used to
> perform tests inside functions at run-time.
>
> You will need to use the "select" function to have the condition
> evaluated each time the function is called.
I see, thank for the heads up. I'm beginning to see that many things that are
straightforward and logical in other programming languages require awkward
contortions in POV-ray. Of course I could just do something like
#declare Gridd = function(X,Y) {
(( X-floor(X)<thick )|(X-floor(X)>(1-thick))|( Y-floor(Y)<thick
)|(Y-floor(Y)>(1-thick)))
}
because the function I want only takes the values zero and one, but if I ever
want other values, or more than two different values, I need proper selection of
cases. And I would definitely have preferred a nice orderly succession of #ifs
to the horror of nested selects. Oh well.
Post a reply to this message
|
|