POV-Ray : Newsgroups : povray.general : Array Problem : Re: Array Problem Server Time
2 Aug 2024 02:25:49 EDT (-0400)
  Re: Array Problem  
From: Tim Nikias
Date: 4 Feb 2005 05:55:44
Message: <420354b0@news.povray.org>
> #macro tilenum(num)
>
> #while (num<0 & num>Size)
> #if(num>Size)
> (num-Size)
> #end
> #if(num<Size)
> (num+Size)
> #end
> #end
>
> #end

I guess the problem is in the above quoted macro. I've often found that it
is better to do it like this:

#macro tilenum(num)
#local Temp=num;
#while (Temp<0 & Temp>Size)
#if (Temp>Size) #local Temp=Temp-Size; #end
#if (Temp<0) #local Temp=Temp+Size; #end
#end
Temp
#end

This way, a local value get's returned. I'm not sure if your code is
altogether correct, as your running a whilte-loop and evaluating it by hand
would come up with something like
"(num-Size)(num-Size)..." or "(num+Size)(num+Size)..." depending if num is
smaller than 0 or larger than Size.

I haven't tested it, but the idea is generally to use a local variable and
return that instead of returning a value inside any kind of loop or if.

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

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