tri monsters
Haldean Brown
3 years ago

3 | 3 | |

4 | 4 | (ql:quickload :alexandria) |

5 | 5 | |

6 | (defun choose-edge-hlen () 1.0) | |

6 | (defun choose-edge-hlen () (+ 10.0 (- (random 19.8) 9.9))) | |

7 | 7 | (defun base-len (edge-hlen) (* (tan (* pi (/ 60 180))) edge-hlen)) |

8 | 8 | (defun random-ortho (v) |

9 | 9 | "randomly pick and return one of the two unit vectors orthogonal to the given unit vector" |

29 | 29 | ) |

30 | 30 | (add-tri s p1 p2 p3))) |

31 | 31 | |

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))))) | |

34 | 37 | |

35 | (defun make-tris () | |

38 | (defun make-tris (origin) | |

36 | 39 | (reduce |

37 | 40 | (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) | |

40 | 43 | )) |

41 | 44 | |

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))) |