-
-
Save amalloy/1047993 to your computer and use it in GitHub Desktop.
Sierpinski Gasket code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn sierpinskisize | |
"Chooses a vertex from tri at random, returning the point halfway between | |
p and the vertex." | |
[p tri] | |
(let [v-num (rand-int 3) | |
vertex ((case v-num | |
0 :p1 | |
1 :p2 | |
2 :p3) tri) | |
halfway-point (fn [p1 p2] | |
(for [coord [:x :y :z]] | |
(/ (+ (coord pi) (coord p2)) 2)))] | |
(apply make-point (halfway-point vertex p)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment