POV-Ray : Newsgroups : povray.general : #while loops and staggered offsets ? Server Time
5 Nov 2024 07:19:36 EST (-0500)
  #while loops and staggered offsets ? (Message 1 to 6 of 6)  
From: Ken
Subject: #while loops and staggered offsets ?
Date: 4 Nov 1998 16:50:09
Message: <3640CBD5.70F83EFB@pacbell.net>
Greetings people!

I can creat a 100 object matrix by using a while loop as follows:

#declare x1 =  0;
#while  (x1 < 10)
#declare z1 =  0;
#while  (z1 < 10)
object{Obj translate <x1,0,z1>}
#declare z1 = z1 + 1;
#end
#declare x1 = x1 + 1;
#end

How would I create the same sort of grid where evey other
row in the z direction is offset by 0.5 in the x direction.
My intention is easying the pain of placing shingles on a
roof where it is important that the cracks of overlapping
rows do not line up while back filling the spaces that would
be left by doing so.

Any suggestions ?

Ken Tyler


Post a reply to this message

From: Ron Parker
Subject: Re: #while loops and staggered offsets ?
Date: 4 Nov 1998 17:06:01
Message: <3640cfc9.0@news.povray.org>
On Wed, 04 Nov 1998 13:49:09 -0800, Ken <tyl### [at] pacbellnet> wrote:
>How would I create the same sort of grid where evey other
>row in the z direction is offset by 0.5 in the x direction.
>My intention is easying the pain of placing shingles on a
>roof where it is important that the cracks of overlapping
>rows do not line up while back filling the spaces that would
>be left by doing so.

//I switched your loops around so you won't have as many calculations.

#declare x2 =  0;
#declare z1 =  0;
#while  (z1 < 10)
  #declare x1 =  0;
  #while  (x1 < 10)
    object{Obj translate <x1+x2,0,z1>}
    #declare x1 = x1 + 1;
  #end
  #declare x2 = 0.5 - x2;
  #declare z1 = z1 + 1;
#end


Post a reply to this message

From: Ken
Subject: Re: #while loops and staggered offsets ?
Date: 4 Nov 1998 17:14:27
Message: <3640D188.6A14DB43@pacbell.net>
I'll try it out. Thank you Ron.

Ken Tyler


Ron Parker wrote:

> //I switched your loops around so you won't have as many calculations.
>
> #declare x2 =  0;
> #declare z1 =  0;
> #while  (z1 < 10)
>   #declare x1 =  0;
>   #while  (x1 < 10)
>     object{Obj translate <x1+x2,0,z1>}
>     #declare x1 = x1 + 1;
>   #end
>   #declare x2 = 0.5 - x2;
>   #declare z1 = z1 + 1;
> #end


Post a reply to this message

From: Ken
Subject: Re: #while loops and staggered offsets ?
Date: 4 Nov 1998 20:49:19
Message: <364103BC.FD928188@pacbell.net>
For my next trick....
How would I go about getting each horizontal row to rise
0.2 in the y direction. I attempted the following and ended
up with a slope that should be equivelant to -x -y to +x +y
instead of a uniform -x +x -y to -x +x +y. I hope that made
since.
Perhaps this is a good graphic example of what happened.

   /
  /
 /
/


#declare Obj = box{-1,1 scale<.9,.2,1.5>pigment{rgb 1}}

#declare x2 =  0;
#declare z1 =  0;
#while  (z1 < 10)
  #declare x1 =  0;
  #while  (x1 < 10)
    object{Obj translate <x1+x2,x1*.2,z1>}
    #declare x1 = x1 + 1;
  #end
  #declare x2 = 0.5 - x2;
  #declare z1 = z1 + 1;
#end

Thanks again.

Ken Tyler

Ron Parker wrote:

> On Wed, 04 Nov 1998 13:49:09 -0800, Ken <tyl### [at] pacbellnet> wrote:
> >How would I create the same sort of grid where evey other
> >row in the z direction is offset by 0.5 in the x direction.
> >My intention is easying the pain of placing shingles on a
> >roof where it is important that the cracks of overlapping
> >rows do not line up while back filling the spaces that would
> >be left by doing so.
>
> //I switched your loops around so you won't have as many calculations.
>
> #declare x2 =  0;
> #declare z1 =  0;
> #while  (z1 < 10)
>   #declare x1 =  0;
>   #while  (x1 < 10)
>     object{Obj translate <x1+x2,0,z1>}
>     #declare x1 = x1 + 1;
>   #end
>   #declare x2 = 0.5 - x2;
>   #declare z1 = z1 + 1;
> #end


Post a reply to this message

From: Margus Ramst
Subject: Re: #while loops and staggered offsets ?
Date: 5 Nov 1998 02:18:56
Message: <3641514E.3E5A0B81@peak.edu.ee>
x1 goes from 0 to 10 each row, that's why you get this effect when using it for
Y position. Try this:

#declare Obj = box{-1,1 scale<.9,.2,1.5>pigment{rgb 1}}
 
#declare x2 =  0;
#declare y1 =  0;
#declare z1 =  0;
#while  (z1 < 10)
	#declare x1 =  0;
	#while  (x1 < 10)
	object{Obj translate <x1+x2,y1,z1>}
	#declare x1 = x1 + 1;
#end
#declare x2 = 0.5 - x;
#declare y1 = y1 + .2
#declare z1 = z1 + 1;
#end


Post a reply to this message

From: Ken
Subject: Re: #while loops and staggered offsets ?
Date: 5 Nov 1998 02:21:03
Message: <364151A7.9B5E9B8E@pacbell.net>
Thank you very much.

Ken Tyler

Margus Ramst wrote:

> x1 goes from 0 to 10 each row, that's why you get this effect when using it for
> Y position. Try this:
>
> #declare Obj = box{-1,1 scale<.9,.2,1.5>pigment{rgb 1}}
>
> #declare x2 =  0;
> #declare y1 =  0;
> #declare z1 =  0;
> #while  (z1 < 10)
>         #declare x1 =  0;
>         #while  (x1 < 10)
>         object{Obj translate <x1+x2,y1,z1>}
>         #declare x1 = x1 + 1;
> #end
> #declare x2 = 0.5 - x;
> #declare y1 = y1 + .2
> #declare z1 = z1 + 1;
> #end


Post a reply to this message

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