|
![](/i/fill.gif) |
Hmmm...Your for loops looks like c-syntax to me.
Would you suggest that one allowed similar things
to be allowed in a for-loop declaration in the
POV-language that one allows in C?
E.g. initialize several variables, call other
functions/macros within the declaration itself etc. ?
If not, then I my opinion is that one should
choose another syntax for the for-loop that doesn't
make the users believe that the same rules applies
as in C.
And: Wouldn't it be better that the control
variable(s) in a for-loop is local to the for-loop?
Tor Olav
mailto:tor### [at] hotmail com
http://www.crosswinds.net/~tok/tokrays.html
Chris Huff wrote:
>
> In article <38C816BE.35E35A1C@hotmail.com>, Tor Olav Kristensen
> <tor### [at] hotmail com> wrote:
>
> > But what if the loop control variable is a vector that is shared
> > between several nested loops? (See my example macro below.)
> >
> > Would this be possible with nested for-loops?
>
> It would be possible, but not necessarily the best way to do it.
> Something like this:
>
> #macro ObjectSplit(Thing, Point1, Point2, nnv)
> // Cuts an object into several "box"-parts
> // Result is returned in an array of such parts
>
> //#local nnv = <nx, ny, nz>;
> #local ThingArray = array[nnv.x][nnv.y][nnv.z]
> #local dPoint = (Point2 - Point1)/nnv;
>
> #for(Cntv = <0,0,0>; Cntv.z < nnv.z; Cntv.z += 1)
> #for(Cntv.y = 0; Cntv.y < nnv.y; Cntv.y += 1)
> #for(Cntv.x = 0; Cntv.x < nnv.x; Cntv.x += 1)
> #local ThingArray[Cntv.x][Cntv.y][Cntv.z] =
> intersection {
> object { Thing }
> box { Point1 + dPoint*Cntv, Point1 + dPoint*(Cntv+Unitv) }
> }
> #end // for
> #end // for
> #end // for
>
> ThingArray
>
> #end // macro ObjectSplit
>
> --
> Chris Huff
> e-mail: chr### [at] yahoo com
> Web page: http://chrishuff.dhs.org/
Post a reply to this message
|
![](/i/fill.gif) |