POV-Ray : Newsgroups : povray.advanced-users : It gets even weirder. : Re: It gets even weirder. Server Time
23 Apr 2024 13:15:10 EDT (-0400)
  Re: It gets even weirder.  
From: Bald Eagle
Date: 27 Aug 2018 10:05:01
Message: <web.5b8404ec29c104f2458c7afe0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> PEBCAK Error.
>
> Don't be fooled: The /first/ loop with debug output (recognizable by
> printing 3 decimals) /always/ goes to 13 and 36, respectively.
>
> Or rather, it would if it could.

Christoph,
I do very much respect you, and fully acknowledge and admit that there are
frequently instances where I jump the gun on things, or totally miss what's
happening.

If I'm missing something, then I still can't see it, and I'd like to know how a
#for loop using (12-1)=11 as an endpoint, and yet it runs to 13, or (36-1)=35,
and yet it runs to 36 - is possible.

Beyond the final #end statement, the counter should be final+step.  Within the
loop, it should be start to end inclusive (according to the docs)

It would be most helpful if you could point to right where the error is, and
say, "look - it's right HERE"  otherwise I'm just wasting a lot of time.

Because I've run it another 5 times with all sorts of other #debug statements,
and the behaviour doesn't make any sense, given what my mind is seeing.


So the question is - what is YOUR mind seeing, and can you demonstrate to me
that it's actually occurring - and WHY.


=========================================================


#version 3.7;
global_settings {assumed_gamma 1.0}

#declare U1 = 0;
#declare U2 = tau;
#declare V1 = 0;
#declare V2 = tau;
#declare   Phi_inc = (tau/360)*30;
#declare Theta_inc = (tau/360)*10;

#declare Usize = (U2-U1)/Phi_inc;
#declare Vsize = (V2-V1)/Theta_inc;

// Run this as-is, and U goes to 11, and V goes to 35

// NOW

// change The line below to Usize+1, and U goes to 11, and V goes to 36 !!!  :O

// How can a variable NOT USED in defining the range of a #for loop change the
behaviour of the loop!
//  In BOTH variables!
//  Usize is never redefined!   W   T   H

 #debug concat ("Usize = ", str(Usize, 0, 3), ",   Vsize = ", str(Vsize, 0, 3),
"\n")

#declare StitchedArray = array[Usize+2][Vsize+2];  // <----- Try it!
#for (U, 0, Usize-1)
 #for (V, 0, Vsize-1)
  #declare StitchedArray [U][V] = array[4][4];
 #end

#end

#declare PatchArray = array [4][4];

#for (Phi, U1, U2, Phi_inc) // 0 to 2pi
 #declare U = ceil(Phi/Phi_inc);
 #for (Theta, V1, V2, Theta_inc)
  #declare V = ceil(Theta/Theta_inc);
  #for (Row, 0, 3)
   #for (Col, 0, 3)
    #declare PatchArray[Row][Col] = <0, 0, 0>;
   #end
  #end
  #debug concat ("U1 = (", str(U, 2, 0), "/", str(Usize, 2, 0), "),   V1 = (",
str(V, 2, 0), "/", str(Vsize, 2, 0), ")    ")
  //#declare StitchedArray [U][V][0][0] = PatchArray[0][0];

 #end
#end

#debug "\n\n\n"

#for (U, 0, Usize-1)
 #for (V, 0, Vsize-1)
  #debug concat ("U2 = (", str(U, 2, 0), "/", str(Usize, 2, 0), "),   V2 = (",
str(V, 2, 0), "/", str(Vsize, 2, 0), ")    ")
  //#declare Test = StitchedArray [U][V][0][0];
  //#declare Test1 = Test;
  //#declare Test2 = Test[0][0];
 #end

#end

#error "end"

//#debug concat(vstr(3, StitchedArray [U][V][0][0], ", ", 0, 3), "\n")


Post a reply to this message

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