POV-Ray : Newsgroups : povray.advanced-users : It gets even weirder. : It gets even weirder. Server Time16 Apr 2024 16:39:32 EDT (-0400)
 It gets even weirder.
 From: Bald Eagle Date: 26 Aug 2018 21:10:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.5b834e5da4582253458c7afe0%40news.povray.org",
"dateCreated": "2018-08-27T01:10:00+00:00",
"datePublished": "2018-08-27T01:10:00+00:00",
"author": {
"@type": "Person",
"name": "Bald Eagle"
}
}
I broke POV-Ray.
AGAIN.

Stephen, I'm pouring Scotch in my coffee...   :|

#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

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

#end

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

#for (Phi, U1, U2, Phi_inc) // 0 to 2pi
#local U = ceil(Phi/Phi_inc);
#for (Theta, V1, V2, Theta_inc)
#local V = ceil(Theta/Theta_inc);
#local PatchArray[0][0] = 0;
#local PatchArray[0][3] = 0;
#local PatchArray[3][0] = 0;
#local PatchArray[3][3] = 0;
#debug concat ("U1 = ", str(U, 0, 3), ",   V1 = ", str(V, 0, 3), "\n")
#declare StitchedArray [U][V] = PatchArray;

#end
#end

#for (U, 0, Usize-1)
#for (V, 0, Vsize-1)
#debug concat ("U2 = ", str(U, 0, 0), ",   V2 = ", str(V, 0, 0), "\n")
#local Test = StitchedArray [U][V];
#local Test2 = Test;
#end

#end
```