diff --git a/src/diamant/geometry.clj b/src/diamant/geometry.clj index d8bcc6c..ee5c862 100644 --- a/src/diamant/geometry.clj +++ b/src/diamant/geometry.clj @@ -10,4 +10,25 @@ (map #(->> object (model/translate [radius 0 0]) - (model/rotate [0 0 (* angle %1)])))))) \ No newline at end of file + (model/rotate [0 0 (* angle %1)])))))) + +(defn tile-square + "Copy object on a square grid of given spacing" + [spacing count-x count-y object] + (->> + (for [x (range count-x) y (range count-y)] + (->> + object + (model/translate [(* x spacing) (* y spacing) 0]))))) + +(defn tile-hex + "Copy object on a hexagonal grid of given spacing" + [spacing count-x count-y object] + (let [t (/ spacing 1.73205080757)] + (->> + (for [x (range count-x) y (range count-y)] + (model/translate + [(+ (* x spacing) (if (odd? y) (/ spacing 2) 0)) + (* y t 1.5) + 0] + object)))))