 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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] mediaone net
www.casdn.neu.edu/~dmiller
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Dennis Milller" <dhm### [at] mediaone net> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tom Melly wrote:
>
> They're recursive (?).
>
No, just nested.
Recursion would be a macro calling itself for example.
Christoph
--
Christoph Hormann <chr### [at] gmx de>
IsoWood include, radiosity tutorial, TransSkin and other
things on: http://www.schunter.etc.tu-bs.de/~chris/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <3ae8369d$1@news.povray.org>, "Dennis Milller"
<dhm### [at] mediaone net> 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] mac com, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tag povray org, http://tag.povray.org/
<><
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Ah, I see. So z is happening "inside" x in fact. That makes perfect sense.
Thanks very much.
D.
"Chris Huff" <chr### [at] mac com> wrote in message
news:chrishuff-155A75.11261926042001@news.povray.org...
> In article <3ae8369d$1@news.povray.org>, "Dennis Milller"
> <dhm### [at] mediaone net> 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] mac com, http://homepage.mac.com/chrishuff/
> TAG: chr### [at] tag povray org, http://tag.povray.org/
>
> <><
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Christoph Hormann" <chr### [at] gmx de> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |