POV-Ray : Newsgroups : povray.binaries.scene-files : Simulated urbanism macro scene: version 2013.04.08 : Re: Simulated urbanism macro scene: version 2013.04.08 Server Time
27 Apr 2024 12:17:24 EDT (-0400)
  Re: Simulated urbanism macro scene: version 2013.04.08  
From: nimda
Date: 8 Apr 2013 09:40:01
Message: <web.5162c800e84780e6787874620@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:
> I made a number of code improvements to the macros, following
> Christian's advice.
>
> In the Orientation() macro I also changed the #while() loop into a
> #for() loop.
>
> I have a major question though.
>
> If, in the Urbanism() macro, I change the #while() into a #for() loop, I
> get a different end result! IMO this should not be the case as no
> changes whatsoever are made to any random parameter. You can test this
> yourself by:
>
> 1) change the line:
>    #while (Counter < Numbers)
> into:
>    #for (Counter, 1, Numbers)
>
> and 2) comment out the line: #local Counter = Counter + 1;
>
> A second question follows from the docs about the #for() loop (my italics):
> [quote]
> A new #for loop construct is now available for simple loops incrementing
> Identifier from Start to End /(inclusive)/ with the given Step size. The
> default Step size is +1.0.
> [/quote]
>
> However, in the code and setting Verbose=on, #for() goes till End-1.
>
> Probably my skull thickness but any idea?
>
> Thomas

IMHO the #for loop goes to the end value if reaches it e.g.:
#for (I, 1, 10)
#warning Str(I)
#end
will show all the numbers from 1 up to 10, but  :
#for (I, 1, 10, 2)
#warning Str(I)
#end
will only show 1, 3, 5, 7, 9 because the 11 that follows is greater than 10.

On the other hand a #while (I<10) statement will only show the numbers up to 9
because the symbol "<" means *strictly* smaller than. If you want 10 to show up
you should use #while (I<=10).

regards,

Marc


Post a reply to this message

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