|
![](/i/fill.gif) |
On 20.01.10 00:33, makc wrote:
> Hello all, could you please advice on following problem. For example, I have two
> functions
>
> #declare frac = function (x) {
> x - floor (x)
> }
>
> #declare menger = function (x, order) {
> floor (3*frac(x*pow(3,order))) - floor (3*frac(x*pow(3,order))/2)*2
> }
>
> In procedural language like C++ to avoid recalculation of frac/pow I would write
> in 2nd function
>
> double tmp = frac(x*pow(3,order));
> return floor (3*tmp) - floor (3*tmp/2)*2;
>
> But how do I explain this to pov?
You don't need a second function to declare a variable. While it is probably
the easiest to read, if you really want you can reuse the sum or prod
functions. In the documentation, i.e. at
<http://www.povray.org/documentation/view/3.6.1/231/> you can find a few
examples. The trick here is of course to reuse the iteration variable.
Thorsten
Post a reply to this message
|
![](/i/fill.gif) |