git.haldean.org plotter / b6aeb9b
tri monsters Haldean Brown 1 year, 6 months ago
1 changed file(s) with 19 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
33
44 (ql:quickload :alexandria)
55
6 (defun choose-edge-hlen () 1.0)
6 (defun choose-edge-hlen () (+ 10.0 (- (random 19.8) 9.9)))
77 (defun base-len (edge-hlen) (* (tan (* pi (/ 60 180))) edge-hlen))
88 (defun random-ortho (v)
99 "randomly pick and return one of the two unit vectors orthogonal to the given unit vector"
2929 )
3030 (add-tri s p1 p2 p3)))
3131
32 (defun base-state ()
33 (add-tri (make-state) '(-0.5 . 0) '(0.5 . 0) (cons 0 (base-len 0.5))))
32 (defun base-state (origin)
33 (add-tri (make-state)
34 (vec- origin '(10 . 0))
35 (vec+ origin '(10 . 0))
36 (vec+ origin (cons 0 (base-len 10)))))
3437
35 (defun make-tris ()
38 (defun make-tris (origin)
3639 (reduce
3740 (lambda (s ig) (new-tri s))
38 (loop for i from 0 to 10 collect i)
39 :initial-value (base-state)
41 (loop for i from 0 to (+ 1 (random 4)) collect i)
42 :initial-value (base-state origin)
4043 ))
4144
42 (defun tri-x.svg() (x.svg (state-polys (make-tris))))
45 (defun make-clusters ()
46 (reduce (lambda (polys ij)
47 (append polys
48 (state-polys (make-tris (cons (* 70 (1+ (car ij))) (* 70 (1+ (cdr ij))))))))
49 (gathering (loop for i from 0 to 4
50 do (loop for j from 0 to 4
51 do (gather (cons i j)))))
52 :initial-value nil))
53
54 (defun tri-x.svg() (x.svg (make-clusters)))