POV-Ray : Newsgroups : povray.general : Array of points for use with bicubic patch Server Time
29 Jul 2024 18:17:36 EDT (-0400)
  Array of points for use with bicubic patch (Message 6 to 15 of 15)  
<<< Previous 5 Messages Goto Initial 10 Messages
From: Tor Olav Kristensen
Subject: Re: Array of points for use with bicubic patch
Date: 26 Apr 2011 21:30:01
Message: <web.4db76e442d1676e4c734aecd0@news.povray.org>
"D103" <nomail@nomail> wrote:
> Le_Forgeron <jgr### [at] freefr> wrote:
> >
> > Have you read
> >
> > >
http://wiki.povray.org/content/Documentation:Tutorial_Section_3#Bicubic_Patch_Object
> >
> > ?
> Yes, I have, and with previous patches I used a similar method, but I'm trying
> to find an easier way to control and change the points, for example, all the
> points along a certain axis etc.
> >
> > The corner of each grid should match. (aka, duplicate them)
> > The control points along the jointing line should also.
> >
> > Do you really want to manage the 16 points of patch with 0-15, or use a
> > double index 0-3,0-3 instead ?
> >
> > (array[n][4][4])
> >
> > Or even simpler to understand: array[n][m][4][4]
> > n height
> > m width (as number of patch)
>
> Hadn't thought of that, thanks.
>
> Supposing I set up such an array, could I use it like this:
>
>
> #declare P1 = 1;
> #declare P2 = 1;
> #while(P1<=4&P2<=4)
>   bicubic_patch {
>     type 1 u_steps 5 v_steps 5
>     BPatchPoints[1][1][P1][P2]
>   }
>   bicubic_patch {
>     type 1 u_steps 5 v_steps 5
>     BPatchPoints[2][2][P1][P2]
>   }
>   bicubic_patch {
>     type 1 u_steps 5 v_steps 5
>     BPatchPoints[2][2][P1][P2]
>   }
>   bicubic_patch {
>     type 1 u_steps 5 v_steps 5
>     BPatchPoints[2][2][P1][P2]
>   }
>   #declare P1=P1+1;
>   #if (P1=4)
>     #declare P2=P2+1;
>     #declare P1=1;
>   #end
> #end
>
> Something tells me this isn't going to work, but I think that's the general idea
> there.

Have a look at the code below.

Tor Olav

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.6;

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare PatchesInWidth = 2;
#declare PatchesInHeight = 2;

#declare PatchPoints =
  array[PatchesInHeight][PatchesInWidth][4][4] {
    {
      {
        { < 0,  0,  0>, < 1,  0,  0>, < 2,  0,  0>, < 3,  0,  0> },
        { < 0,  0,  1>, < 1,  1,  1>, < 2,  1,  1>, < 3,  0,  1> },
        { < 0,  0,  2>, < 1,  1,  2>, < 2,  1,  2>, < 3,  0,  2> },
        { < 0,  0,  3>, < 1,  0,  3>, < 2,  0,  3>, < 3,  0,  3> }
      },
      {
        { < 3,  0,  0>, < 4,  0,  0>, < 5,  0,  0>, < 6,  0,  0> },
        { < 3,  0,  1>, < 4, -1,  1>, < 5, -1,  1>, < 6,  0,  1> },
        { < 3,  0,  2>, < 4, -1,  2>, < 5, -1,  2>, < 6,  0,  2> },
        { < 3,  0,  3>, < 4,  0,  3>, < 5,  0,  3>, < 6,  0,  3> }
      }
    },
    {
      {
        { < 0,  0,  3>, < 1,  0,  3>, < 2,  0,  3>, < 3,  0,  3> },
        { < 0,  0,  4>, < 1, -1,  4>, < 2, -1,  4>, < 3,  0,  4> },
        { < 0,  0,  5>, < 1, -1,  5>, < 2, -1,  5>, < 3,  0,  5> },
        { < 0,  0,  6>, < 1,  0,  6>, < 2,  0,  6>, < 3,  0,  6> }
      },
      {
        { < 3,  0,  3>, < 4,  0,  3>, < 5,  0,  3>, < 6,  0,  3> },
        { < 3,  0,  4>, < 4,  1,  4>, < 5,  1,  4>, < 6,  0,  4> },
        { < 3,  0,  5>, < 4,  1,  5>, < 5,  1,  5>, < 6,  0,  5> },
        { < 3,  0,  6>, < 4,  0,  6>, < 5,  0,  6>, < 6,  0,  6> }
      }
    }
  }



#declare PatchTextures =

  array[PatchesInHeight][PatchesInWidth] {
    {

      texture {
        pigment {
          checker
          color rgbf <1.0, 1.0, 1.0, 0.6>
          color rgbf <0.0, 0.0, 0.0, 0.6>

        }
      },
      texture {
        pigment {
          checker
          color rgbf <0.7, 0.0, 0.0, 0.6>
          color rgbf <1.0, 1.0, 1.0, 0.6>
        }
      }
    },
    {
      texture {
        pigment {
          checker
          color rgbf <0.0, 0.7, 0.0, 0.6>
          color rgbf <1.0, 1.0, 1.0, 0.6>
        }
      },
      texture {
        pigment {
          checker
          color rgbf <1.0, 1.0, 1.0, 0.6>
          color rgbf <0.0, 0.0, 0.7, 0.6>
        }
      }
    }
  }

#declare CntH = 0;
#while (CntH < PatchesInHeight)
  #declare CntW = 0;
  #while (CntW < PatchesInWidth)

    bicubic_patch {
      type 1
      flatness 0.001
      u_steps 4
      v_steps 4
      uv_vectors
        <0, 0>
        <1, 0>
        <1, 1>
        <0, 1>

      #declare I = 0;
      #while (I < 4)
        #declare J = 0;
        #while (J < 4)
          PatchPoints[CntH][CntW][I][J]
          #declare J = J + 1;
        #end // while
        #declare I = I + 1;
      #end // while

      uv_mapping
        texture {
          PatchTextures[CntH][CntW]
          scale 1/3
        }
    }

    #declare CntW = CntW + 1;
  #end // while
  #declare CntH = CntH + 1;
#end // while

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

background {
  color rgb 0.5*<1, 1, 1>
}

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

light_source {
  500*<1,  1, -1>
  color rgb <1, 1, 1>
  shadowless
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

From: D103
Subject: Re: Array of points for use with bicubic patch
Date: 27 Apr 2011 08:05:00
Message: <web.4db805432d1676e49f865aaa0@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
>
> Have a look at the code below.
>
> Tor Olav
>
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
>
> #version 3.6;
>
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
>
> #declare PatchesInWidth = 2;
> #declare PatchesInHeight = 2;
>
> #declare PatchPoints =
>   array[PatchesInHeight][PatchesInWidth][4][4] {
>     {
>       {
>         { < 0,  0,  0>, < 1,  0,  0>, < 2,  0,  0>, < 3,  0,  0> },
>         { < 0,  0,  1>, < 1,  1,  1>, < 2,  1,  1>, < 3,  0,  1> },
>         { < 0,  0,  2>, < 1,  1,  2>, < 2,  1,  2>, < 3,  0,  2> },
>         { < 0,  0,  3>, < 1,  0,  3>, < 2,  0,  3>, < 3,  0,  3> }
>       },
>       {
>         { < 3,  0,  0>, < 4,  0,  0>, < 5,  0,  0>, < 6,  0,  0> },
>         { < 3,  0,  1>, < 4, -1,  1>, < 5, -1,  1>, < 6,  0,  1> },
>         { < 3,  0,  2>, < 4, -1,  2>, < 5, -1,  2>, < 6,  0,  2> },
>         { < 3,  0,  3>, < 4,  0,  3>, < 5,  0,  3>, < 6,  0,  3> }
>       }
>     },
>     {
>       {
>         { < 0,  0,  3>, < 1,  0,  3>, < 2,  0,  3>, < 3,  0,  3> },
>         { < 0,  0,  4>, < 1, -1,  4>, < 2, -1,  4>, < 3,  0,  4> },
>         { < 0,  0,  5>, < 1, -1,  5>, < 2, -1,  5>, < 3,  0,  5> },
>         { < 0,  0,  6>, < 1,  0,  6>, < 2,  0,  6>, < 3,  0,  6> }
>       },
>       {
>         { < 3,  0,  3>, < 4,  0,  3>, < 5,  0,  3>, < 6,  0,  3> },
>         { < 3,  0,  4>, < 4,  1,  4>, < 5,  1,  4>, < 6,  0,  4> },
>         { < 3,  0,  5>, < 4,  1,  5>, < 5,  1,  5>, < 6,  0,  5> },
>         { < 3,  0,  6>, < 4,  0,  6>, < 5,  0,  6>, < 6,  0,  6> }
>       }
>     }
>   }
>
>
>
> #declare PatchTextures =
>
>   array[PatchesInHeight][PatchesInWidth] {
>     {
>
>       texture {
>         pigment {
>           checker
>           color rgbf <1.0, 1.0, 1.0, 0.6>
>           color rgbf <0.0, 0.0, 0.0, 0.6>
>
>         }
>       },
>       texture {
>         pigment {
>           checker
>           color rgbf <0.7, 0.0, 0.0, 0.6>
>           color rgbf <1.0, 1.0, 1.0, 0.6>
>         }
>       }
>     },
>     {
>       texture {
>         pigment {
>           checker
>           color rgbf <0.0, 0.7, 0.0, 0.6>
>           color rgbf <1.0, 1.0, 1.0, 0.6>
>         }
>       },
>       texture {
>         pigment {
>           checker
>           color rgbf <1.0, 1.0, 1.0, 0.6>
>           color rgbf <0.0, 0.0, 0.7, 0.6>
>         }
>       }
>     }
>   }
>
> #declare CntH = 0;
> #while (CntH < PatchesInHeight)
>   #declare CntW = 0;
>   #while (CntW < PatchesInWidth)
>
>     bicubic_patch {
>       type 1
>       flatness 0.001
>       u_steps 4
>       v_steps 4
>       uv_vectors
>         <0, 0>
>         <1, 0>
>         <1, 1>
>         <0, 1>
>
>       #declare I = 0;
>       #while (I < 4)
>         #declare J = 0;
>         #while (J < 4)
>           PatchPoints[CntH][CntW][I][J]
>           #declare J = J + 1;
>         #end // while
>         #declare I = I + 1;
>       #end // while
>
>       uv_mapping
>         texture {
>           PatchTextures[CntH][CntW]
>           scale 1/3
>         }
>     }
>
>     #declare CntW = CntW + 1;
>   #end // while
>   #declare CntH = CntH + 1;
> #end // while
>
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
>
> background {
>   color rgb 0.5*<1, 1, 1>
> }
>
> camera {
>   location <3, 6, -3>
>   look_at <3, 0, 3>
> }
>
> light_source {
>   500*<1,  1, -1>
>   color rgb <1, 1, 1>
>   shadowless
> }
>
> // ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

That's great! Took me a while to understand the nested loops though.
Thank you very much.

The other reason I posted was to ask if there was a way to reduce the process of
creating the vectors for the patches to a while loop or nested loops.

Call me lazy, but I'm always looking for shorter/easier ways to do things. :)

D103


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Array of points for use with bicubic patch
Date: 27 Apr 2011 09:20:00
Message: <web.4db816822d1676e447ba06bb0@news.povray.org>
"D103" <nomail@nomail> wrote:
....
> The other reason I posted was to ask if there was a way to reduce the process of
> creating the vectors for the patches to a while loop or nested loops.
>
> Call me lazy, but I'm always looking for shorter/easier ways to do things. :)

Coding in order to being able to be lazy later is a good thing.
Being lazy while coding is a bad thing.

- And yes, there are ways to do what you want.

Perhaps these 2 images will give you some hints or ideas:

http://home.online.no/~t-o-k/POV-Ray_Images/Bezier_Patches_Stitched.jpg
http://home.online.no/~t-o-k/POV-Ray_Images/Bezier_Patches_Stitched_.jpg

--
Tor Olav
http://subcube.com


Post a reply to this message

From: D103
Subject: Re: Array of points for use with bicubic patch
Date: 3 May 2011 08:40:00
Message: <web.4dbff7222d1676e4dd10c23d0@news.povray.org>
"D103" <nomail@nomail> wrote:
.....
> The other reason I posted was to ask if there was a way to reduce the process of
> creating the vectors for the patches to a while loop or nested loops.
.....
>
> D103

After some experimentation, I have come up with these loops.
The idea is of course, to replace the sphere with an array or to place the loops
within an array, whatever is necessary.

#declare X1=-1.5;  //in the scene file these are equal to the v_length of the
appropriate values.
#declare Z1=-1.5;
#declare Cnt=0;

#while(X1<=1.5)
  #while(Z1<=1.5)
    #if(Cnt>=15)
      #debug "Cnt = illegal value.\n"
    #else
      #debug "Cnt is within legal range.\n"
    #end
    //#declare Pts[Cnt]=<X1, 0, Z1>;
    sphere { 0, 0.1 pigment { White } translate <X1, 0, Z1> }
    #declare Z1=Z1+1;
    #declare Cnt=Cnt+1;
  #end

For some reason, when I run this in POV-Ray, it only creates one sphere, (or
else several spheres in the same location), and when the sphere is replace with
an array, the first point is generated alright, but on the second loop, it
produces an error message: "attempt to access uninitialized array element".
  #declare X1=X1+1;
  #declare Z1=-1.5;
#end

If someone could point out the problem(s), I would be very grateful.

Thanks,
D103


Post a reply to this message

From: Warp
Subject: Re: Array of points for use with bicubic patch
Date: 3 May 2011 11:20:04
Message: <4dc01d24@news.povray.org>
D103 <nomail@nomail> wrote:
> #declare X1=-1.5;  //in the scene file these are equal to the v_length of the
> appropriate values.
> #declare Z1=-1.5;
> #declare Cnt=0;

> #while(X1<=1.5)
>   #while(Z1<=1.5)
>     #if(Cnt>=15)
>       #debug "Cnt = illegal value.\n"
>     #else
>       #debug "Cnt is within legal range.\n"
>     #end
>     //#declare Pts[Cnt]=<X1, 0, Z1>;
>     sphere { 0, 0.1 pigment { White } translate <X1, 0, Z1> }
>     #declare Z1=Z1+1;
>     #declare Cnt=Cnt+1;
>   #end
>   #declare X1=X1+1;
>   #declare Z1=-1.5;
> #end

  You seem to have very complicated ways of performing nested loops.
What's wrong with the traditional way of doing nested loops? In other
words:

#declare Cnt = 0;
#declare X1 = -1.5;
#while(X1 <= 1.5)
  #declare Z1 = -1.5;
  #while(Z1 <= 1.5)

    ...

    #declare Z1 = Z1 + 1;
    #declare Cnt = Cnt + 1;
  #end
  #declare X1 = X1 + 1;
#end

-- 
                                                          - Warp


Post a reply to this message

From: D103
Subject: Re: Array of points for use with bicubic patch
Date: 5 May 2011 09:00:01
Message: <web.4dc29e162d1676e45ae2687f0@news.povray.org>
"D103" <nomail@nomail> wrote:
> #declare X1=-1.5;  //in the scene file these are equal to the v_length of the
> appropriate values.
> #declare Z1=-1.5;
> #declare Cnt=0;
>
> #while(X1<=1.5)
>   #while(Z1<=1.5)
>     #if(Cnt>=15)
>       #debug "Cnt = illegal value.\n"
>     #else
>       #debug "Cnt is within legal range.\n"
>     #end
>     //#declare Pts[Cnt]=<X1, 0, Z1>;
>     sphere { 0, 0.1 pigment { White } translate <X1, 0, Z1> }
>     #declare Z1=Z1+1;
>     #declare Cnt=Cnt+1;
>   #end
>
> For some reason, when I run this in POV-Ray, it only creates one sphere, (or
> else several spheres in the same location), and when the sphere is replace with
> an array, the first point is generated alright, but on the second loop, it
> produces an error message: "attempt to access uninitialized array element".
>   #declare X1=X1+1;
>   #declare Z1=-1.5;
> #end

Not quite sure what went wrong there, but this seems to have fixed it:

#declare S1 = seed(7);
#declare S2 = seed(rand(S1)*10);

#macro RandColour(Col)
  colour Col+(<rand(S1), rand(S1), rand(S1)>-0.5)
  #if (1<(Col.gray))
    #local Col=Col-(<rand(S2), rand(S2), rand(S2)>);
    #else
      #if (0>(Col.gray))
      #local Col=Col+(<rand(S2), rand(S2), rand(S2)>);
    #end
  #end
#end

(thought I might as well post this macro, in case someone wants it)

#declare S3=seed(3);
#declare Cnt=0;
#declare X=-1.5;
#declare Z=-1.5;

#declare Pts = array[16];
#while(X<=1.5)
  #while(Z<=1.5)
    #if(Cnt>15)
      #debug "Cnt = illegal value.\n"
    #else
      #debug "Cnt is within legal range.\n"
    #end
    #declare Y=sin(X*4)/2;
    #declare Pts[Cnt]=<X, Y, Z>;
    #declare Z=Z+1;
    #declare Cnt=Cnt+1;
  #end
  #declare X=X+1;
  #declare Z=-1.5;
#end

bicubic_patch {
  type 1 u_steps 3 v_steps 3
  #declare C=0;
  #while(C<=15)
    Pts[C]
    #declare C=C+1;
  #end
  pigment {
    ripples colour_map {
      #declare Ind = 0;
      #declare Num = 50;
      #declare Rand = rand(S3);
      #while(Ind<=Num)
        #if(Rand<(1/3))
          [Ind/Num RandColour(Yellow) ]
        #end
        #if(Rand>(1/3)&Rand<(2/3))
          [Ind/Num RandColour(Cyan) ]
        #end
        #if(Rand>(2/3)&Rand<(1))
          [Ind/Num RandColour(Magenta) ]
        #end
      #declare Ind = Ind + 1;
      #end
    }
  }
}

Perhaps someone can shed some light on what's going on?

Thanks,
D103


Post a reply to this message

From: D103
Subject: Re: Array of points for use with bicubic patch
Date: 5 May 2011 09:05:00
Message: <web.4dc2a00d2d1676e45ae2687f0@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> D103 <nomail@nomail> wrote:
> > #declare X1=-1.5;  //in the scene file these are equal to the v_length of the
> > appropriate values.
> > #declare Z1=-1.5;
> > #declare Cnt=0;
>
> > #while(X1<=1.5)
> >   #while(Z1<=1.5)
> >     #if(Cnt>=15)
> >       #debug "Cnt = illegal value.\n"
> >     #else
> >       #debug "Cnt is within legal range.\n"
> >     #end
> >     //#declare Pts[Cnt]=<X1, 0, Z1>;
> >     sphere { 0, 0.1 pigment { White } translate <X1, 0, Z1> }
> >     #declare Z1=Z1+1;
> >     #declare Cnt=Cnt+1;
> >   #end
> >   #declare X1=X1+1;
> >   #declare Z1=-1.5;
> > #end
>
>   You seem to have very complicated ways of performing nested loops.
> What's wrong with the traditional way of doing nested loops? In other
> words:
>
> #declare Cnt = 0;
> #declare X1 = -1.5;
> #while(X1 <= 1.5)
>   #declare Z1 = -1.5;
>   #while(Z1 <= 1.5)
>
>     ...
>
>     #declare Z1 = Z1 + 1;
>     #declare Cnt = Cnt + 1;
>   #end
>   #declare X1 = X1 + 1;
> #end
>
> --
>                                                           - Warp

Sorry, afraid I'm in the dark here. Perhaps you could explain in a bit more
detail? I've read the help files on nested loops, maybe there's something I
missed or misunderstood.

Thank you very much.

D103


Post a reply to this message

From: Warp
Subject: Re: Array of points for use with bicubic patch
Date: 5 May 2011 12:33:47
Message: <4dc2d16b@news.povray.org>
D103 <nomail@nomail> wrote:
> > #declare Cnt = 0;
> > #declare X1 = -1.5;
> > #while(X1 <= 1.5)
> >   #declare Z1 = -1.5;
> >   #while(Z1 <= 1.5)
> >
> >     ...
> >
> >     #declare Z1 = Z1 + 1;
> >     #declare Cnt = Cnt + 1;
> >   #end
> >   #declare X1 = X1 + 1;
> > #end
> >
> > --
> >                                                           - Warp

> Sorry, afraid I'm in the dark here. Perhaps you could explain in a bit more
> detail? I've read the help files on nested loops, maybe there's something I
> missed or misunderstood.

  I just can't understand why you insist in writing nested loops in such
complicated ways rather than using the simpler approach, as shown above.

-- 
                                                          - Warp


Post a reply to this message

From: Alain
Subject: Re: Array of points for use with bicubic patch
Date: 5 May 2011 14:18:53
Message: <4dc2ea0d@news.povray.org>

> Warp<war### [at] tagpovrayorg>  wrote:
>> D103<nomail@nomail>  wrote:
>>> #declare X1=-1.5;  //in the scene file these are equal to the v_length of the
>>> appropriate values.
>>> #declare Z1=-1.5;
>>> #declare Cnt=0;
>>
>>> #while(X1<=1.5)
>>>    #while(Z1<=1.5)
>>>      #if(Cnt>=15)
>>>        #debug "Cnt = illegal value.\n"
>>>      #else
>>>        #debug "Cnt is within legal range.\n"
>>>      #end
>>>      //#declare Pts[Cnt]=<X1, 0, Z1>;
>>>      sphere { 0, 0.1 pigment { White } translate<X1, 0, Z1>  }
>>>      #declare Z1=Z1+1;
>>>      #declare Cnt=Cnt+1;
>>>    #end
>>>    #declare X1=X1+1;
>>>    #declare Z1=-1.5;
>>> #end
>>
>>    You seem to have very complicated ways of performing nested loops.
>> What's wrong with the traditional way of doing nested loops? In other
>> words:
>>
>> #declare Cnt = 0;
>> #declare X1 = -1.5;
>> #while(X1<= 1.5)
>>    #declare Z1 = -1.5;
>>    #while(Z1<= 1.5)
>>
>>      ...
>>
>>      #declare Z1 = Z1 + 1;
>>      #declare Cnt = Cnt + 1;
>>    #end
>>    #declare X1 = X1 + 1;
>> #end
>>
>> --
>>                                                            - Warp
>
> Sorry, afraid I'm in the dark here. Perhaps you could explain in a bit more
> detail? I've read the help files on nested loops, maybe there's something I
> missed or misunderstood.
>
> Thank you very much.
>
> D103
>
>

When making nested loops, it's normaly beter to initiate any inner loop 
counter just before it's #while statement.

You initiate your counter first outside the outer loop. Then, you 
reinitiate that counter for the next iteration after the #end of the 
loop and after you increment the outer loop's counter.

The usual way is:
Initiate the outer loop's counter.
Start the outer loop.
possibly do some stuff.

Initiate the iner loop's counter.
Start the inner loop.
Do the iner loop's stuf and counter incrementation.
Close the iner loop.

possibly do some other outer loop stuff.
Increment the outer loop's counter.
Close the outer loop.

This is much cleaner as the iner loop is initiated just before the place 
where it's used.
You only need to initialise the iner loop in one place.
You can use a #local variable for the iner loop instead of one that is 
global. It reduces the risks of name collision and undesirable side effects.



Alain


Post a reply to this message

From: D103
Subject: Re: Array of points for use with bicubic patch
Date: 6 May 2011 09:45:01
Message: <web.4dc3fa362d1676e45ae2687f0@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:
.....
>
> When making nested loops, it's normaly beter to initiate any inner loop
> counter just before it's #while statement.
>
> You initiate your counter first outside the outer loop. Then, you
> reinitiate that counter for the next iteration after the #end of the
> loop and after you increment the outer loop's counter.
>
> The usual way is:
> Initiate the outer loop's counter.
> Start the outer loop.
> possibly do some stuff.
>
> Initiate the iner loop's counter.
> Start the inner loop.
> Do the iner loop's stuf and counter incrementation.
> Close the iner loop.
>
> possibly do some other outer loop stuff.
> Increment the outer loop's counter.
> Close the outer loop.
>
> This is much cleaner as the iner loop is initiated just before the place
> where it's used.
> You only need to initialise the iner loop in one place.
> You can use a #local variable for the iner loop instead of one that is
> global. It reduces the risks of name collision and undesirable side effects.
>
>
>
> Alain

Ah. I don't know why I didn't understand before.
Oh well, better late than never.

Thanks guys,
D103


Post a reply to this message

<<< Previous 5 Messages Goto Initial 10 Messages

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