POV-Ray : Newsgroups : povray.general : question Server Time
8 Aug 2024 01:18:28 EDT (-0400)
  question (Message 1 to 7 of 7)  
From: Dennis Milller
Subject: question
Date: 26 Apr 2001 10:54:21
Message: <3ae8369d$1@news.povray.org>
I came across this code and have on question. If the xcounter and zcounter
are identical, why can't they be interchanged in the translate statement?
The image changes dramtically if I substite "zcounter" for "xcounter" or
vice versa, yet the "declare statements seem to do exactly the same thing.
Any clues?
thanks much,
Dennis

camera {
 location <0,3,-3>
 look_at <2,0,3>
}

light_source {
 <100,50,-100>
 color rgb 1
}

#declare r1 = seed(13);
#declare xcounter = 0;
#while (xcounter < 50)
#declare zcounter = 0;
#while (zcounter < 50)
box {<-.25,-.25,-.25>, <.25,.25,.25>

 translate <xcounter,rand(r1),zcounter>   // rand(r1)
 pigment { color rgb <1,1,1> } finish {metallic}}

#declare zcounter = zcounter + 1;
#end
#declare xcounter = xcounter + 1;
#end
--
dhm### [at] mediaonenet
www.casdn.neu.edu/~dmiller


Post a reply to this message

From: Tom Melly
Subject: Re: question
Date: 26 Apr 2001 11:14:17
Message: <3ae83b49@news.povray.org>
"Dennis Milller" <dhm### [at] mediaonenet> wrote in message
news:3ae8369d$1@news.povray.org...

They're recursive (?).

The two "while" loops mean they increase at different rates. Additionally, z
repeats for each increment of x.

You can swap them, but you have to swap all references to them.


Post a reply to this message

From: Christoph Hormann
Subject: Re: question
Date: 26 Apr 2001 12:01:08
Message: <3AE84662.479188F9@gmx.de>
Tom Melly wrote:
> 
> They're recursive (?).
> 

No, just nested.

Recursion would be a macro calling itself for example.

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
IsoWood include, radiosity tutorial, TransSkin and other 
things on: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Chris Huff
Subject: Re: question
Date: 26 Apr 2001 12:28:54
Message: <chrishuff-155A75.11261926042001@news.povray.org>
In article <3ae8369d$1@news.povray.org>, "Dennis Milller" 
<dhm### [at] mediaonenet> wrote:

> I came across this code and have on question. If the xcounter and zcounter
> are identical, why can't they be interchanged in the translate statement?
> The image changes dramtically if I substite "zcounter" for "xcounter" or
> vice versa, yet the "declare statements seem to do exactly the same thing.

Because they are *not* identical. Indenting the code properly makes it 
clearer:

#declare xcounter = 0;
#while (xcounter < 50)
    #declare zcounter = 0;
    #while (zcounter < 50)
        ...
        #declare zcounter = zcounter + 1;
    #end

    #declare xcounter = xcounter + 1;
#end

The zcounter loop is completely independant of the xcounter loop, and 
loops from 0 to 49 *every time the xcounter loop goes through one loop*. 
The outer loop runs through 50 times, and for each loop the inner loop 
gets reset and runs through again.
This has the effect of zcounter going from 0 to 49 while xcounter = 0, 
then again while xcounter = 1, and so on. They start out and end at the 
same values, but change at different times and rates.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Arun Persaud
Subject: Re: question
Date: 26 Apr 2001 12:35:58
Message: <3AE84EEF.C9D3B87F@lbl.gov>
Hi,

Dennis Milller wrote:
> 
> I came across this code and have on question. If the xcounter and zcounter
> are identical, why can't they be interchanged in the translate statement?
> The image changes dramtically if I substite "zcounter" for "xcounter" or
> vice versa, yet the "declare statements seem to do exactly the same thing.
> Any clues?

> #declare r1 = seed(13);
> #declare xcounter = 0;
> #while (xcounter < 50)
> #declare zcounter = 0;
> #while (zcounter < 50)
> box {<-.25,-.25,-.25>, <.25,.25,.25>
> 
>  translate <xcounter,rand(r1),zcounter>   // rand(r1)
>  pigment { color rgb <1,1,1> } finish {metallic}}
> 
> #declare zcounter = zcounter + 1;
> #end
> #declare xcounter = xcounter + 1;
> #end

you can't interchange them, because of the call to the
random-function...
if you interchange the xcounter and zcounter in the translate statement,
you are going to mirror your image on the x=z plane.
(e.g. if you compare the boxes with xcounter==zcounter in the two images
you will notice that they didn't change).

HTH
	ARUN


Post a reply to this message

From: Dennis Milller
Subject: Re: question
Date: 26 Apr 2001 20:19:10
Message: <3ae8bafe@news.povray.org>
Ah, I see. So z is happening "inside" x in fact. That makes perfect sense.
Thanks very much.
D.

"Chris Huff" <chr### [at] maccom> wrote in message
news:chrishuff-155A75.11261926042001@news.povray.org...
> In article <3ae8369d$1@news.povray.org>, "Dennis Milller"
> <dhm### [at] mediaonenet> wrote:
>
> > I came across this code and have on question. If the xcounter and
zcounter
> > are identical, why can't they be interchanged in the translate
statement?
> > The image changes dramtically if I substite "zcounter" for "xcounter" or
> > vice versa, yet the "declare statements seem to do exactly the same
thing.
>
> Because they are *not* identical. Indenting the code properly makes it
> clearer:
>
> #declare xcounter = 0;
> #while (xcounter < 50)
>     #declare zcounter = 0;
>     #while (zcounter < 50)
>         ...
>         #declare zcounter = zcounter + 1;
>     #end
>
>     #declare xcounter = xcounter + 1;
> #end
>
> The zcounter loop is completely independant of the xcounter loop, and
> loops from 0 to 49 *every time the xcounter loop goes through one loop*.
> The outer loop runs through 50 times, and for each loop the inner loop
> gets reset and runs through again.
> This has the effect of zcounter going from 0 to 49 while xcounter = 0,
> then again while xcounter = 1, and so on. They start out and end at the
> same values, but change at different times and rates.
>
> --
> Christopher James Huff
> Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
> TAG: chr### [at] tagpovrayorg, http://tag.povray.org/
>
> <><


Post a reply to this message

From: Tom Melly
Subject: Re: question
Date: 27 Apr 2001 04:12:52
Message: <3ae92a04@news.povray.org>
"Christoph Hormann" <chr### [at] gmxde> wrote in message
news:3AE84662.479188F9@gmx.de...
>
>
> Tom Melly wrote:
> >
> > They're recursive (?).
>
> No, just nested.
>
> Recursion would be a macro calling itself for example.

Ah - I knew it was the wrong word (hence the "?") - thanks.


Post a reply to this message

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