|
|
Wasn't it Max Ulbrich who wrote:
>Hi,
>
>I try to get a sum over an expression that contains data of an array. I
>try to use a macro for this purpose and later call this in the function
>part of the isosurface. In the part where I try to extract the x, y and
>z coordinates from the macro arguments something goes wrong. Although I
>do not get an error message, the x coordinate seems always to be 1.
>It seems as if x gets evaluated before the call of the macro. Actually I
>would prefer to get this done just when the call happens. My guess is
>that macro isn't the right solution. Who can help me?
>Thanks,
>Max
What's happening is that "x" "y" and "z" have two completely different
meanings in POV syntax. At run time (e.g. inside a function{}) they can
be function parameters. At parse time (e.g. inside a #macro) they are
shorthand for the vectors <1,0,0> <0,1,0> <0,0,1>.
You seem to have already noticed that inside the macros they are vectors
(because you pick out individual values from these vectors using the
syntax "posx.x") which gives us a big clue that "x" here is just
shorthand for "<1,0,0>".
We can get round this confusion by changing the names of the function
parameters, like this:
#declare F=function(A,B,C){esum(A,B,C) }
isosurface{ function{ F(x,y,z) }...
and also replacing "posx.x" by "posx" inside the macro, since we're now
attempting to pass float parameters instead of vectors.
Which then gives is the real POV error that's causing your problems
This part of the documentation applies:
3.1.1.6.2 Functions and Macros
You can use macros in functions, but the macros will be called only
once when the function is defined, not every time the function is
called. You cannot pass function variables to the macros.
I.e. you can write
#declare F=function(A,B,C){A*B*C*esum(1,2,3)}
because the values of 1, 2 and 3 are available at parse time (when the
macro is evaluated) but you can't write
#declare F=function(A,B,C){esum(A,B,C)}
because A, B and C are only available at run time
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|