POV-Ray : Newsgroups : povray.binaries.scene-files : Simulated urbanism macro scene: version 2013.04.08 Server Time
23 Nov 2024 11:03:08 EST (-0500)
  Simulated urbanism macro scene: version 2013.04.08 (Message 1 to 8 of 8)  
From: Thomas de Groot
Subject: Simulated urbanism macro scene: version 2013.04.08
Date: 8 Apr 2013 04:00:40
Message: <51627928@news.povray.org>
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


Post a reply to this message


Attachments:
Download 'windows-1252' (16 KB)

From: nimda
Subject: Re: Simulated urbanism macro scene: version 2013.04.08
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

From: Thomas de Groot
Subject: Re: Simulated urbanism macro scene: version 2013.04.08
Date: 8 Apr 2013 10:17:36
Message: <5162d180$1@news.povray.org>
On 8-4-2013 15:38, nimda wrote:
> 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.

Yes. However, in my code #for (Counter, 1, 10) with default step=1, the 
Counter only shows the numbers 1 to 9...
I am sure I am missing something obvious here :-(

>
> 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).

Of course, but there lies not my problem.

Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: Simulated urbanism macro scene: version 2013.04.08
Date: 8 Apr 2013 10:40:14
Message: <5162d6ce@news.povray.org>
On 8-4-2013 16:17, Thomas de Groot wrote:

> Yes. However, in my code #for (Counter, 1, 10) with default step=1, the
> Counter only shows the numbers 1 to 9...
> I am sure I am missing something obvious here :-(

More bizarre than that: #for(Counter, 1, Numbers) where Numbers=50  the 
last number shown is 49, but for all other values (as far as I have 
tested now) the result is correct. Have I met a freakish behaviour just 
by chance? Something to do with rounding effect?

Thomas


Post a reply to this message

From: nimda
Subject: Re: Simulated urbanism macro scene: version 2013.04.08
Date: 8 Apr 2013 15:00:01
Message: <web.516312fbe84780e6787874620@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:
> On 8-4-2013 16:17, Thomas de Groot wrote:
>
> > Yes. However, in my code #for (Counter, 1, 10) with default step=1, the
> > Counter only shows the numbers 1 to 9...
> > I am sure I am missing something obvious here :-(
>
> More bizarre than that: #for(Counter, 1, Numbers) where Numbers=50  the
> last number shown is 49, but for all other values (as far as I have
> tested now) the result is correct. Have I met a freakish behaviour just
> by chance? Something to do with rounding effect?
>
> Thomas

What messages do you get when you do the following:

#for (I, 1, 10)
#warning Str(I)
#end

Or does the Counter gets modified during the loop?

Marc


Post a reply to this message

From: clipka
Subject: Re: Simulated urbanism macro scene: version 2013.04.08
Date: 8 Apr 2013 17:57:18
Message: <51633d3e@news.povray.org>
Am 08.04.2013 16:40, schrieb Thomas de Groot:
> On 8-4-2013 16:17, Thomas de Groot wrote:
>
>> Yes. However, in my code #for (Counter, 1, 10) with default step=1, the
>> Counter only shows the numbers 1 to 9...
>> I am sure I am missing something obvious here :-(
>
> More bizarre than that: #for(Counter, 1, Numbers) where Numbers=50  the
> last number shown is 49, but for all other values (as far as I have
> tested now) the result is correct. Have I met a freakish behaviour just
> by chance? Something to do with rounding effect?

Can't confirm that one. Are you computing Numbers somehow? Maybe due to 
rounding effects you end up with Numbers = 49.9999 or some such.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Simulated urbanism macro scene: version 2013.04.08
Date: 9 Apr 2013 03:19:11
Message: <5163c0ef$1@news.povray.org>
To nimda and Clipka:

I got it! :-)

The #for() loop definitely does *not* work correctly for my particular 
case, while the #while() loop does. The reason is that Counter should 
only be incremented *if* the #inside() test is passed as negative (not 
inside object). With the #for() loop, Counter is *always* incremented 
whatever the result of the #inside() test.

Conclusion: I should use the #while() loop in this case as easiest 
coding procedure.

My first question about the different results in placing houses is now 
also answered. It derives from the above of course.

Thomas


Post a reply to this message

From: clipka
Subject: Re: Simulated urbanism macro scene: version 2013.04.08
Date: 9 Apr 2013 04:04:41
Message: <5163cb99@news.povray.org>
Am 09.04.2013 09:19, schrieb Thomas de Groot:
>
> I got it! :-)
>
> The #for() loop definitely does *not* work correctly for my particular
> case, while the #while() loop does. The reason is that Counter should
> only be incremented *if* the #inside() test is passed as negative (not
> inside object). With the #for() loop, Counter is *always* incremented
> whatever the result of the #inside() test.

Yeah, that /could/ make a difference ;-)


Post a reply to this message

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