Dear list,<div><br></div><div>I've been wondering whether what I was doing (building a naive village) made any sense at all. Of course anything that makes us smile has a use there and I've been trying to challenge myself to teach myself Scheme, but I couldn't escape the feeling that one could do most of the end result in Blender in less time. Now I have a exception to that. The problem was "fields". Fields here are any area contained by a fence and the problem was where to place fence-posts for (rectangular) fields of arbitrary sizes. The code I'm posting below is really rather simple from a scheming perspective, but I'm very happy with it as a take on 3d modelling where the computer gets to do all of the boring stuff, so I thought I'd share. It holds up for fields where one dimension is 0, fields with negative sizes make it muck up, but that should be ok.</div>
<div><br></div><div>Yours,</div><div>Kas.</div><div><br></div><div><div>(clear)</div><div><br></div><div>(with-state</div><div>    (colour (vector 0 1 0))</div><div>    (scale 10)</div><div>    (build-plane))</div><div><br>
</div><div><br></div><div><br></div><div>(define wood_col (vector .5 .5 0))</div><div><br></div><div>(define (build-post height)</div><div>    (with-state</div><div>        (rotate (vector 90 0 0))</div><div>        (scale (vector .05 height .05))</div>
<div>        (colour wood_col)</div><div>        (build-cylinder 2 10)))</div><div><br></div><div><br></div><div><br></div><div>(define (build-fence length)</div><div>    (with-state</div><div>        (with-state</div><div>
            (colour wood_col)</div><div>            (rotate (vector  90 0 0))</div><div>            (translate (vector (/ length 2) .4 0))</div><div>            (scale (vector length .1 1))</div><div>            (build-plane)</div>
<div>            (translate (vector 0 -2 0))</div><div>            (build-plane))</div><div><br></div><div>        (let ((nmbr_of_posts (floor (/ length .7))))</div><div>        (cond ((zero? nmbr_of_posts) (set! nmbr_of_posts 1)))</div>
<div>        (for* ((x (in-range 0 nmbr_of_posts)))</div><div>            (translate (vector (/ length nmbr_of_posts) 0 0))</div><div>            (build-post .5)))))</div><div><br></div><div>(define (build-field x y)</div>
<div>    (with-state</div><div>        (translate (vector (- 0 (/ x 2)) (- 0 (/ y 2)) 0))</div><div>        (build-fence x)</div><div>        (translate (vector x 0 0))</div><div>        (rotate (vector 0 0 90))</div><div>
        (build-fence y)</div><div>        (translate (vector y 0 0))</div><div>        (rotate (vector 0 0 90))</div><div>        (build-fence x)</div><div>        (translate (vector x 0 0))</div><div>        (rotate (vector 0 0 90))</div>
<div>        (build-fence y)))</div><div><br></div><div>(build-field 2 3)</div></div>