Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/diamant/geometry.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,25 @@
(map #(->>
object
(model/translate [radius 0 0])
(model/rotate [0 0 (* angle %1)]))))))
(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)))))