From 445380a444522b96bfad84408590426786207853 Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Tue, 8 Jul 2014 22:06:08 +0200 Subject: [PATCH] Start building a visual representation of the 3d led cube --- doc/threedvis/project.clj | 7 ++++++ doc/threedvis/src/threedvis/core.clj | 36 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 doc/threedvis/project.clj create mode 100644 doc/threedvis/src/threedvis/core.clj diff --git a/doc/threedvis/project.clj b/doc/threedvis/project.clj new file mode 100644 index 0000000..8d0ac6e --- /dev/null +++ b/doc/threedvis/project.clj @@ -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"]]) diff --git a/doc/threedvis/src/threedvis/core.clj b/doc/threedvis/src/threedvis/core.clj new file mode 100644 index 0000000..7d9085d --- /dev/null +++ b/doc/threedvis/src/threedvis/core.clj @@ -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))))