|
![](/i/fill.gif) |
Jim Charter <jrc### [at] msn com> wrote:
> Haakon Meland Eriksen wrote:
> > I would like to do something like this
> >
> > *
> > **
> > ***
> > **
> > *
> >
> > and decrement the number of objects in one direction as the loops progress. How
> > can I do this correctly? This does not work.
> >
> > #declare IndexX = 0;
> >
> > #while (IndexX <= 9)
> > #declare EndZ = 9;
> > #declare IndexZ = 0;
> >
> > #while (IndexZ <= EndZ)
> >
> > sphere { <IndexX,1,IndexZ>, 0.1 texture {pigment{color Red}}}
> > #declare EndZ = EndZ - 1;
> > #declare IndexZ = IndexZ + 1;
> >
> > #end
> >
> > #declare IndexX = IndexX + 1;
> > #end
> >
> > Cheers,
> > Haakon
> >
> >
> >
> >
> #declare X = -9;
> #declare EndZ = -1;
>
> #while (X <= 9)
> #if ( X < 0 )
> #declare EndZ = EndZ + 1;
> #else
> #declare EndZ = EndZ - 1;
> #end
>
> #declare Z = 0;
> #while (Z <= EndZ)
> sphere { <X,1,Z>, 0.1 texture {pigment{color x}}}
> #declare Z = Z + 1;
> #end
>
> #declare X = X + 1;
> #end
Thanks, Jim!
My mathematician friends Per and Hung suggested something similiar, and Hung
even made me work it out while he had a cup of coffee, and I came up with these
// Number of X increases as Z increases by 1 is 2*1-1=1,2*2-1=3, 2*3-1=5,
2*4-1=7, 2*5-1=9 and so on.
/*
*****
***
*
*/
#declare IndexZ = 1;
#while (IndexZ <= 5)
#declare EndX = 2*IndexZ-1;
#declare IndexX = 1;
#while (IndexX <= EndX)
sphere { <IndexX,0,IndexZ>, 0.1 texture {pigment{color Red}}
translate <-IndexZ,0,0>
}
#declare IndexX = IndexX + 1;
#end
#declare IndexZ = IndexZ + 1;
#end
sphere {<0,0,0>, 0.1 pigment {color Green}}
sphere {<0,0,5>, 0.1 pigment {color Blue}}
// Number of X decrement when Z increases by 1 is 1 = 9, 2 = 7, 3 = 5, 4 = 3, 5
= 1
/*
*
***
*****
*/
#declare IndexZ = 1;
#while (IndexZ <= 5)
#declare EndX = 2*IndexZ-1;
#declare IndexX = 1;
#while (IndexX <= EndX)
sphere { <IndexX,0,IndexZ>, 0.1 texture {pigment{color Red}}
translate <-IndexZ,0,-(EndX-1/2)>
//translate x*10
}
#declare IndexX = IndexX + 1;
#end
#declare IndexZ = IndexZ + 1;
#end
I'll put up a new macro at http://far.no/fram/index.php?title=Tiles hopefully
before Monday.
Cheers,
Haakon
Post a reply to this message
|
![](/i/fill.gif) |