Start building a visual representation of the 3d led cube

This commit is contained in:
Aaron Mueller 2014-07-08 22:06:08 +02:00
parent afc1c9fe78
commit 445380a444
2 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,7 @@
(defproject threedvis "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[scad-clj "0.2.1"]])

View file

@ -0,0 +1,36 @@
(ns threedvis.core
(:require [scad-clj.model :refer :all]
[scad-clj.scad :refer :all]))
(defn print-scad [shape]
(spit "threedvis.scad" (write-scad shape)))
(defn led []
(union
(color [0.5 0.5 2]
(difference
(union
(cylinder 10 20)
(translate [0 0 10] (sphere 10))
(translate [0 0 -8] (cylinder 13 4)))
(translate [0 13 -7] (cube 30 5 10))))
(color [0.3 0.3 0.3]
(union
(translate [0 5 -30] (cylinder 1.5 50))
(translate [7 5 -60] (rotate (/ pi 4) [0 -1 0] (cylinder 1.5 20))))
(translate [14 5 -122] (cylinder 1.5 110))
(union
(translate [0 -5 -10] (cylinder 1.5 15))
(translate [0 -44 -17] (rotate (/ pi 2) [1 0 0] (cylinder 1.5 80)))))))
(defn one-pos []
(union
(translate [0 0 0] (led))
(translate [0 0 100] (led))
(translate [0 0 200] (led))))
(print-scad
(union
(translate [0 0 0] (one-pos))
(translate [0 100 0] (one-pos))
(translate [0 200 0] (one-pos))))