(define generate
(lambda (sz iter pos dir)
(let ((scale 0.4) (px 1) (nx 2) (py 3) (ny 4) (pz 5) (nz 6))
(if (> iter 0)
(let ((ofs (+ (* sz scale) sz)) (new-scale (* sz scale)))
(sphere sz pos)
(if (not (= dir nx))
(generate new-scale (- iter 1) (map + pos (list ofs 0 0)) px))
(if (not (= dir px))
(generate new-scale (- iter 1) (map + pos (list (- ofs) 0 0)) nx))
(if (not (= dir ny))
(generate new-scale (- iter 1) (map + pos (list 0 ofs 0)) py))
(if (not (= dir py))
(generate new-scale (- iter 1) (map + pos (list 0 (- ofs) 0)) ny))
(if (not (= dir nz))
(generate new-scale (- iter 1) (map + pos (list 0 0 ofs)) pz))
(if (not (= dir pz))
(generate new-scale (- iter 1) (map + pos (list 0 0 (- ofs))) nz)))))))
(define sphere
(lambda (sz pos)
(display "s\t")
(for-each (lambda (x) (display x) (display " ")) pos)
(display "\t")
(display sz)
(display "\t0.25 0.25 0.25 50.0\t0.65")
(newline)))
(generate 1.0 5 `(0 0 0) 0)
(display "s 0 -10002.25 0 10000 0.2 0.35 0.5 80.0 0.4") (newline)
(display "s 0 10100.00 0 10000 0.5 0.2 0.1 40.0 0.0") (newline)
(display "l -50 68 -50") (newline)
(display "l 40 40 150") (newline)
(display "c -9 8 -17 45 0 -1 0")
(newline)