|
 |
Hello all...:)
I am hoping this is the proper newsgroup (my first post,
at that.
I need a #while loop that places an object in a 2d grid
with say 5 objects in a row and 5 objects per column.
X X X X X
X X X X X
X X X X X
X X X X X
X X X X X
Essentially, I am placing a copy of an object 25 times
in a 5x5 grid. However, the code below does not work:
For the keen ones amongst you, I am trying to create a
hexagonally tiled floor with the hexagons rounded at the
edges and a small amount of grout between each
hexagon.
David Fontaine has helped me greatly in getting me to
this point, but getting the hexagons to tile correctly has
been a major headache. I suspect my "understanding"
of the #while - #end loops is not fully correct, although
I don't know where I am going wrong looking at code
and the help docs. :)
Any help is greatly appreciated. :)
Thanks!
Todd
tta### [at] netrelated com
#include "colors.inc"
camera {
location <0,10,0.05>
look_at <0,0,0>
rotate <0,0,0>}
light_source { <4,4,-6> color rgb <1,1,1>}
#declare Tile = union {
union{
intersection {
cylinder { <-.5,0,sqrt(3)/2>,<.5,0,sqrt(3)/2>,.1 }
plane { x,0 rotate 30.01*y }
plane { -x,0 rotate -30.01*y }
}
sphere{<.5,0,sqrt(3)/2>,.1}
}
union{
intersection {
cylinder { <-.5,0,sqrt(3)/2>,<.5,0,sqrt(3)/2>,.1 }
plane { x,0 rotate 30.01*y }
plane { -x,0 rotate -30.01*y }
rotate 60*y
}
sphere{<.5,0,sqrt(3)/2>,.1 rotate 60*y}
}
on{
intersection {
cylinder { <-.5,0,sqrt(3)/2>,<.5,0,sqrt(3)/2>,.1 }
plane { x,0 rotate 30.01*y }
plane { -x,0 rotate -30.01*y }
rotate 120*y
}
sphere{<.5,0,sqrt(3)/2>,.1 rotate 120*y}
}
union{
intersection {
cylinder { <-.5,0,sqrt(3)/2>,<.5,0,sqrt(3)/2>,.1 }
plane { x,0 rotate 30.01*y }
plane { -x,0 rotate -30.01*y }
rotate 180*y
}
sphere{<.5,0,sqrt(3)/2>
,.1 rotate 180*y}
}
union{
intersection {
cylinder { <-.5,0,sqrt(3)/2>,<.5,0,sqrt(3)/2>,.1 }
plane { x,0 rotate 30.01*y }
plane { -x,0 rotate -30.01*y }
rotate 240*y
}
sphere{<.5,0,sqrt(3)/2>,.1 rotate 240*y}
}
union{
intersection {
cylinder { <-.5,0,sqrt(3)/2>,<.5,0,sqrt(3)/2>,.1 }
plane { x,0 rotate 30.01*y }
plane { -x,0 rotate -30.01*y }
rotate 300*y
}
sphere{<.5,0,sqrt(3)/2>,.1 rotate 300*y}
}
prism { -.1,.1,7 <-1,0>,<-.5,sqrt(3)/2>,<.5,sqrt(3)/2>,
<1,0>,<.5,-sqrt(3)/2>,<-.5,-sqrt(3)/2>,<-1,0> }
pigment { color rgb<0,0,1> }
finish { ambient .6 metallic reflection .6}
}
#declare grout_size=.05;
#declare TileWidth=2;
#declare RoundEdgeWidth=.05;
#declare Count1=-25;
#declare Count2=-25;
#while (Count1<=25)
#while (Count2<=25)
object { Tile
translate
<Count1*(1.5*TileWidth+2*grout_size+2*RoundEdgeWidth),0,Count2*(sqrt(3)+2*gr
out_size+2*RoundEdgeWidth)>
}
#declare Count2=Count2+1;
#end
#declare Count1=Count1+1;
#end
union {
plane {y,0
pigment { color rgb<1,1,1> }
}
object
Tile
}
}
Post a reply to this message
|
 |
|
 |
On 3 Sep 2000 16:10:41 -0400, ingo wrote:
>Think about it with an absolute non-programmer mind.
>When I first encouterd a loop, it took men an hour to realize that I had
>to do the incrementing myself. I expected it to be automatic.
>It took me a day to figure out I had to reset the counter of the inner
>loop myself. For me it seemed very logical that once I had gone through
>the loop the counter would not exist anymore until the loop was enterd
>again.
In most languages this is the difference between a while loop and a for
loop. The while loop is repeated while a certain condition is true. The
for loop is repeated for a set of values.
For example, in
#local a = 0;
#while (a < 20)
...
#end
You can do everything with a inside the loop, as long as you stay below
20. You don't just have to increase it by 1 with every cycle. You can
increase it by 0.1, by a random value, you can decrease it again, or you
can compute it as a function of some other variable.
On the other hand, Pascal (for example) has a for loop:
var i: integer;
begin
i := 5;
for i := 1 to 20
do
println(i);
done
println(i); { ??? }
end;
will print the values from 1 to 20. No need to increment manually,
because the loop always increments the count by 1. In fact you are not
allowed to assign a new value to i inside the loop, and it isn't
specified what the println after the loop will print. 5, 20, or 21 would
be values you could expect (if you know a little bit about how a pascal
compiler works), but it could also be some completely random value.
So the for loop is simpler, but less flexible. Because you can always
rewrite a for loop as a while loop, but not vice versa, Povray only has
a while loop.
hp
--
_ | Peter J. Holzer | Nicht an Tueren mangelt es,
|_|_) | Sysadmin WSR | sondern an der Einrichtung (aka Content).
| | | hjp### [at] wsr ac at | -- Ale### [at] univie ac at
__/ | http://www.hjp.at/ | zum Thema Portale in at.linux
Post a reply to this message
|
 |