POV-Ray : Newsgroups : povray.general : Algorithm issues: what is better? : Re: Algorithm issues: what is better? Server Time
4 Aug 2024 16:14:06 EDT (-0400)
  Re: Algorithm issues: what is better?  
From: Tim Nikias v2 0
Date: 24 Mar 2003 16:52:55
Message: <3e7f7e37$1@news.povray.org>
Thanks for the reply.
Well, then it seems applying mod() directly is better:

#local _D=_DatSet[_X][_Z];
#declare _X=_X+mod(_D.u,dimension_size(_DatSet,1));
#declare _Z=_Z+_D.v;

vs

#if (_DatSet[_X][_Z].u>=dimension_size(_DatSet,1))
 #local
_D=_DatSet[_X][_Z]*v+mod(_DatSet[_X][_Z].u,dimension_size(_DatSet,1))*u;
#else
 #local _D=_DatSet[_X][_Z];
#end
#declare _X=_X+_D.u;
#declare _Z=_Z+_D.v;


I know, some stuff could be simplified (like getting the dimension_size
into its own variable instead of calling it several times), but the always
applied mod() looks cleaner. Is it more work to process the mod() in this
case, or the #if? Or, in this case, is it just not worth mentioning? I'm not
so sure if POV is faster at boolean logic or if the mod() is faster, and if
the amount of processing required for the #if statement in itself is
actually
more complex than just the mod()...

--
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: Tim### [at] gmxde

"Slime" wrote:

> > Is it better to apply mod() in every step, or use an #if in every
> > step in order to know if mod() should be applied? What is less
> > costly parsing-wise?
>
> It probably depends on the complexity of the if() condition, the
complexity
> of the mod()-related function, and and probability of the if() condition
> being true.
>
> if the if() condition is less complex than the mod()-related function, and
> the probability of the if() condition being true is low, then use the
if().
>
>  - Slime
> [ http://www.slimeland.com/ ]
>
>


Post a reply to this message

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