POV-Ray : Newsgroups : povray.general : optimisation of functions - how to? : Re: optimisation of functions - how to? Server Time
30 Jul 2024 02:13:35 EDT (-0400)
  Re: optimisation of functions - how to?  
From: Tor Olav Kristensen
Date: 19 Jan 2010 20:30:00
Message: <web.4b565c5a6e27db37d6291f840@news.povray.org>
"makc" <mak### [at] gmailspamcom> 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
> }
....
> But how do I explain this to pov?
>
> Ok, in this particular case I could use intermediate function
>
> #declare menger2 = function (tmp) {
>    floor (3*tmp) - floor (3*tmp/2)*2
> }
>
> #declare menger = function (x, order) {
>    menger2(frac(x*pow(3,order)))
> }
>
> but
>
> 1) not sure if this can be done for arbitrary combination

Neither do I.

I can't remember having seen a function where this way of doing it is
not possible.

But if you or anyone else can come up with a good challenge, then
please post it.


> 2) wont stacking functions like that actually slow things down

I have mostly experienced speed-ups.
But sometimes extra functions calls is not worth simple recalculations.

--
Tor Olav
http://subcube.com


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.