Collinearity problem dealt with, some unit tests written.
This commit is contained in:
parent
f92e17c5e8
commit
b6e618695e
40
docs/cloverage/coverage.css
Normal file
40
docs/cloverage/coverage.css
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
.covered {
|
||||||
|
font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
|
||||||
|
background-color: #558B55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.not-covered {
|
||||||
|
font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partial {
|
||||||
|
font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
|
||||||
|
background-color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
.not-tracked {
|
||||||
|
font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.blank {
|
||||||
|
font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.with-bar {
|
||||||
|
width: 250px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.with-number {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.ns-name {
|
||||||
|
min-width: 150px;
|
||||||
|
padding-right: 25px;
|
||||||
|
}
|
149
docs/cloverage/index.html
Normal file
149
docs/cloverage/index.html
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link rel="stylesheet" href="./coverage.css"/>
|
||||||
|
<title>Coverage Summary</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<thead><tr>
|
||||||
|
<td class="ns-name"> Namespace </td>
|
||||||
|
<td class="with-bar"> Forms </td>
|
||||||
|
<td class="with-number">Forms %</td>
|
||||||
|
<td class="with-bar"> Lines </td>
|
||||||
|
<td class="with-number">Lines %</td>
|
||||||
|
<td class="with-number">Total</td><td class="with-number">Blank</td><td class="with-number">Instrumented</td>
|
||||||
|
</tr></thead>
|
||||||
|
<tr>
|
||||||
|
<td><a href="walkmap/core.clj.html">walkmap.core</a></td><td class="with-bar"><div class="covered"
|
||||||
|
style="width:12.244897959183673%;
|
||||||
|
float:left;"> 6 </div><div class="not-covered"
|
||||||
|
style="width:87.75510204081633%;
|
||||||
|
float:left;"> 43 </div></td>
|
||||||
|
<td class="with-number">12.24 %</td>
|
||||||
|
<td class="with-bar"><div class="covered"
|
||||||
|
style="width:38.46153846153846%;
|
||||||
|
float:left;"> 5 </div><div class="not-covered"
|
||||||
|
style="width:61.53846153846154%;
|
||||||
|
float:left;"> 8 </div></td>
|
||||||
|
<td class="with-number">38.46 %</td>
|
||||||
|
<td class="with-number">44</td><td class="with-number">6</td><td class="with-number">13</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="walkmap/edge.clj.html">walkmap.edge</a></td><td class="with-bar"><div class="covered"
|
||||||
|
style="width:69.38775510204081%;
|
||||||
|
float:left;"> 136 </div><div class="not-covered"
|
||||||
|
style="width:30.612244897959183%;
|
||||||
|
float:left;"> 60 </div></td>
|
||||||
|
<td class="with-number">69.39 %</td>
|
||||||
|
<td class="with-bar"><div class="covered"
|
||||||
|
style="width:70.0%;
|
||||||
|
float:left;"> 35 </div><div class="partial"
|
||||||
|
style="width:2.0%;
|
||||||
|
float:left;"> 1 </div><div class="not-covered"
|
||||||
|
style="width:28.0%;
|
||||||
|
float:left;"> 14 </div></td>
|
||||||
|
<td class="with-number">72.00 %</td>
|
||||||
|
<td class="with-number">82</td><td class="with-number">7</td><td class="with-number">50</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="walkmap/geometry.clj.html">walkmap.geometry</a></td><td class="with-bar"><div class="covered"
|
||||||
|
style="width:1.6260162601626016%;
|
||||||
|
float:left;"> 2 </div><div class="not-covered"
|
||||||
|
style="width:98.3739837398374%;
|
||||||
|
float:left;"> 121 </div></td>
|
||||||
|
<td class="with-number">1.63 %</td>
|
||||||
|
<td class="with-bar"><div class="covered"
|
||||||
|
style="width:15.384615384615385%;
|
||||||
|
float:left;"> 2 </div><div class="not-covered"
|
||||||
|
style="width:84.61538461538461%;
|
||||||
|
float:left;"> 11 </div></td>
|
||||||
|
<td class="with-number">15.38 %</td>
|
||||||
|
<td class="with-number">24</td><td class="with-number">3</td><td class="with-number">13</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="walkmap/path.clj.html">walkmap.path</a></td><td class="with-bar"><div class="covered"
|
||||||
|
style="width:5.555555555555555%;
|
||||||
|
float:left;"> 3 </div><div class="not-covered"
|
||||||
|
style="width:94.44444444444444%;
|
||||||
|
float:left;"> 51 </div></td>
|
||||||
|
<td class="with-number">5.56 %</td>
|
||||||
|
<td class="with-bar"><div class="covered"
|
||||||
|
style="width:23.076923076923077%;
|
||||||
|
float:left;"> 3 </div><div class="not-covered"
|
||||||
|
style="width:76.92307692307692%;
|
||||||
|
float:left;"> 10 </div></td>
|
||||||
|
<td class="with-number">23.08 %</td>
|
||||||
|
<td class="with-number">30</td><td class="with-number">4</td><td class="with-number">13</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="walkmap/polygon.clj.html">walkmap.polygon</a></td><td class="with-bar"><div class="covered"
|
||||||
|
style="width:7.407407407407407%;
|
||||||
|
float:left;"> 2 </div><div class="not-covered"
|
||||||
|
style="width:92.5925925925926%;
|
||||||
|
float:left;"> 25 </div></td>
|
||||||
|
<td class="with-number">7.41 %</td>
|
||||||
|
<td class="with-bar"><div class="covered"
|
||||||
|
style="width:25.0%;
|
||||||
|
float:left;"> 2 </div><div class="not-covered"
|
||||||
|
style="width:75.0%;
|
||||||
|
float:left;"> 6 </div></td>
|
||||||
|
<td class="with-number">25.00 %</td>
|
||||||
|
<td class="with-number">17</td><td class="with-number">3</td><td class="with-number">8</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="walkmap/stl.clj.html">walkmap.stl</a></td><td class="with-bar"><div class="covered"
|
||||||
|
style="width:17.228464419475657%;
|
||||||
|
float:left;"> 46 </div><div class="not-covered"
|
||||||
|
style="width:82.77153558052434%;
|
||||||
|
float:left;"> 221 </div></td>
|
||||||
|
<td class="with-number">17.23 %</td>
|
||||||
|
<td class="with-bar"><div class="covered"
|
||||||
|
style="width:28.125%;
|
||||||
|
float:left;"> 18 </div><div class="not-covered"
|
||||||
|
style="width:71.875%;
|
||||||
|
float:left;"> 46 </div></td>
|
||||||
|
<td class="with-number">28.13 %</td>
|
||||||
|
<td class="with-number">126</td><td class="with-number">12</td><td class="with-number">64</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="walkmap/svg.clj.html">walkmap.svg</a></td><td class="with-bar"><div class="covered"
|
||||||
|
style="width:2.8776978417266186%;
|
||||||
|
float:left;"> 4 </div><div class="not-covered"
|
||||||
|
style="width:97.12230215827338%;
|
||||||
|
float:left;"> 135 </div></td>
|
||||||
|
<td class="with-number">2.88 %</td>
|
||||||
|
<td class="with-bar"><div class="covered"
|
||||||
|
style="width:8.571428571428571%;
|
||||||
|
float:left;"> 3 </div><div class="not-covered"
|
||||||
|
style="width:91.42857142857143%;
|
||||||
|
float:left;"> 32 </div></td>
|
||||||
|
<td class="with-number">8.57 %</td>
|
||||||
|
<td class="with-number">50</td><td class="with-number">2</td><td class="with-number">35</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="walkmap/vertex.clj.html">walkmap.vertex</a></td><td class="with-bar"><div class="covered"
|
||||||
|
style="width:72.94117647058823%;
|
||||||
|
float:left;"> 62 </div><div class="not-covered"
|
||||||
|
style="width:27.058823529411764%;
|
||||||
|
float:left;"> 23 </div></td>
|
||||||
|
<td class="with-number">72.94 %</td>
|
||||||
|
<td class="with-bar"><div class="covered"
|
||||||
|
style="width:63.63636363636363%;
|
||||||
|
float:left;"> 14 </div><div class="partial"
|
||||||
|
style="width:13.636363636363637%;
|
||||||
|
float:left;"> 3 </div><div class="not-covered"
|
||||||
|
style="width:22.727272727272727%;
|
||||||
|
float:left;"> 5 </div></td>
|
||||||
|
<td class="with-number">77.27 %</td>
|
||||||
|
<td class="with-number">43</td><td class="with-number">5</td><td class="with-number">22</td>
|
||||||
|
</tr>
|
||||||
|
<tr><td>Totals:</td>
|
||||||
|
<td class="with-bar"></td>
|
||||||
|
<td class="with-number">27.77 %</td>
|
||||||
|
<td class="with-bar"></td>
|
||||||
|
<td class="with-number">39.45 %</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
140
docs/cloverage/walkmap/core.clj.html
Normal file
140
docs/cloverage/walkmap/core.clj.html
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link rel="stylesheet" href="../coverage.css"/> <title> walkmap/core.clj </title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
001 (ns walkmap.core
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
002 "At this stage, primarily utility functions dealing with stereolithography
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
003 (STL) files. Not a stable API yet!"
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
004 (:require [clojure.java.io :as io :refer [file output-stream input-stream]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
005 [clojure.string :as s]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
006 [hiccup.core :refer [html]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
007 [me.raynes.fs :as fs]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
008 [taoensso.timbre :as l :refer [info error spy]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
009 [walkmap.stl :refer [decode-binary-stl]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
010 [walkmap.svg :refer [stl->svg]]))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
011
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
012 (def ^:dynamic *sea-level*
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
013 "The sea level on heightmaps we're currently handling. If characters are to
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
014 be able to swin in the sea, we must model the sea bottom, so we need
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
015 heightmaps which cover at least the continental shelf. However, the sea
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
016 bottom is not walkable territory and can be culled from walkmaps.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
017
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
018 **Note** must be a floating point number. `(= 0 0.0)` returns `false`!"
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
019 0.0)
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
020
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
021 (defn ocean?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
022 "Of a `facet`, is the altitude of every vertice equal to `*sea-level*`?"
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
023 [facet]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
024 (every?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
025 #(= % *sea-level*)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
026 (map :z (:vertices facet))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
027
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
028 (defn cull-ocean-facets
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
029 "Ye cannae walk on water. Remove all facets from this `stl` structure which
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
030 are at sea level."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
031 [stl]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 10 forms covered">
|
||||||
|
032 (assoc stl :facets (remove ocean? (:facets stl))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
033
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
034 (defn binary-stl-file->svg
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
035 "Given only an `in-filename`, parse the indicated file, expected to be
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
036 binary STL, and return an equivalent SVG structure. Given both `in-filename`
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
037 and `out-filename`, as side-effect write the SVG to the indicated output file."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
038 ([in-filename]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 7 forms covered">
|
||||||
|
039 (stl->svg (cull-ocean-facets (decode-binary-stl in-filename))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
040 ([in-filename out-filename]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
041 (let [s (binary-stl-file->svg in-filename)]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 8 forms covered">
|
||||||
|
042 (spit out-filename (html s))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
043 s)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
044
|
||||||
|
</span><br/>
|
||||||
|
</body>
|
||||||
|
</html>
|
254
docs/cloverage/walkmap/edge.clj.html
Normal file
254
docs/cloverage/walkmap/edge.clj.html
Normal file
|
@ -0,0 +1,254 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link rel="stylesheet" href="../coverage.css"/> <title> walkmap/edge.clj </title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
001 (ns walkmap.edge
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
002 "Essentially the specification for things we shall consider to be an edge.
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
003 An edge is a line segment having just a start and an end, with no intervening
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
004 nodes."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
005 (:require [clojure.math.numeric-tower :as m]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
006 [walkmap.path :refer [path? polygon->path]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
007 [walkmap.polygon :refer [polygon?]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
008 [walkmap.vertex :refer [ensure3d vertex?]]))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
009
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
010 (defn edge?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
011 "True if `o` satisfies the conditions for a path. A path shall be a map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
012 having the keys `:start` and `:end`, such that the values of each of those
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
013 keys shall be a vertex."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
014 [o]
|
||||||
|
</span><br/>
|
||||||
|
<span class="partial" title="8 out of 9 forms covered">
|
||||||
|
015 (and
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
016 (map? o)
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
017 (vertex? (:start o))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
018 (vertex? (:end o))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
019
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
020 (defn path->edges
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
021 "if `o` is a path, a polygon, or a sequence of vertices, return a sequence of
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
022 edges representing that path, polygon or sequence."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
023 [o]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
024 (cond
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
025 (seq? o)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
026 (when
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
027 (and
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
028 (vertex? (first o))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
029 (vertex? (first (rest o))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
030 (cons
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
031 {:start (first o)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
032 :end (first (rest o))}
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
033 (path->edges (rest o))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
034 (path? o)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
035 (path->edges (:nodes o))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
036 (polygon? o)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
037 (path->edges (polygon->path o))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
038
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
039 (defn length
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
040 "Return the length of the edge `e`."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
041 [e]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
|
042 (let [start (ensure3d (:start e))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
043 end (ensure3d (:end e))]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
044 (m/sqrt
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
045 (reduce
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
046 +
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
047 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="11 out of 11 forms covered">
|
||||||
|
048 #(m/expt (- (% end) (% start)) 2)
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
049 [:x :y :z])))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
050
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
051 (defn unit-vector
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
052 "Return an vertex parallel to `e` starting from the coordinate origin. Two
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
053 edges which are parallel will have the same unit vector."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
054 [e]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="14 out of 14 forms covered">
|
||||||
|
055 (let [e' {:start (ensure3d (:start e)) :end (ensure3d (:end e))}
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
056 l (length e')]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
057 (reduce
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
058 merge
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
059 {}
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
060 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
061 (fn [k]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="17 out of 17 forms covered">
|
||||||
|
062 {k (/ (- (k (:end e')) (k (:start e'))) l)})
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
063 [:x :y :z]))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
064
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
065 (defn parallel?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
066 "True if all `edges` passed are parallel with one another."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
067 ;; TODO: this bears being wary about, dealing with floating point arithmetic.
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
068 ;; Keep an eye out for spurious errors.
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
069 [& edges]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
070 (let [uvs (map unit-vector edges)]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
071 (every?
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
|
072 #(= % (first uvs))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
073 (rest uvs))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
074
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
075 (defn collinear?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
076 "True if edges `e1` and `e2` are collinear with one another."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
077 [e1 e2]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
078 (parallel?
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
079 e1
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
080 e2
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="9 out of 9 forms covered">
|
||||||
|
081 {:start (:start e1) :end (:start e2)}))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
082
|
||||||
|
</span><br/>
|
||||||
|
</body>
|
||||||
|
</html>
|
80
docs/cloverage/walkmap/geometry.clj.html
Normal file
80
docs/cloverage/walkmap/geometry.clj.html
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link rel="stylesheet" href="../coverage.css"/> <title> walkmap/geometry.clj </title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
001 (ns walkmap.geometry
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
002 (:require [clojure.math.combinatorics :as combo]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
003 [clojure.math.numeric-tower :as m]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
004 [walkmap.edge :as e]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
005 [walkmap.path :refer [path? polygon->path]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
006 [walkmap.polygon :refer [polygon?]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
007 [walkmap.vertex :as v]))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
008
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
009 (defn on?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
010 "True if the vertex `v` is on the edge `e`."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
011 [e v]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
012 (let [p (v/ensure3d (:start e))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
013 q (v/ensure3d v)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
014 r (v/ensure3d (:end e))]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 25 forms covered">
|
||||||
|
015 (and
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
016 (e/collinear? p q r)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 13 forms covered">
|
||||||
|
017 (<= (:x q) (max (:x p) (:x r)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 13 forms covered">
|
||||||
|
018 (>= (:x q) (min (:x p) (:x r)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 13 forms covered">
|
||||||
|
019 (<= (:y q) (max (:y p) (:y r)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 13 forms covered">
|
||||||
|
020 (>= (:y q) (min (:y p) (:y r)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 13 forms covered">
|
||||||
|
021 (<= (:z q) (max (:z p) (:z r)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 12 forms covered">
|
||||||
|
022 (>= (:z q) (min (:z p) (:z r))))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
023
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
024
|
||||||
|
</span><br/>
|
||||||
|
</body>
|
||||||
|
</html>
|
98
docs/cloverage/walkmap/path.clj.html
Normal file
98
docs/cloverage/walkmap/path.clj.html
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link rel="stylesheet" href="../coverage.css"/> <title> walkmap/path.clj </title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
001 (ns walkmap.path
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
002 "Essentially the specification for things we shall consider to be path."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
003 (:require [walkmap.polygon :refer [polygon?]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
004 [walkmap.vertex :refer [vertex?]]))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
005
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
006 (defn path?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
007 "True if `o` satisfies the conditions for a path. A path shall be a map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
008 having the key `:nodes`, whose value shall be a sequence of vertices as
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
009 defined in `walkmap.vertex`."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
010 [o]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
011 (let
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
012 [v (:nodes o)]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 9 forms covered">
|
||||||
|
013 (and
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
014 (seq? v)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
015 (> (count v) 2)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
016 (every? vertex? v))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
017
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
018 (defn polygon->path
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
019 "If `o` is a polygon, return an equivalent path. What's different about
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
020 a path is that in polygons there is an implicit edge between the first
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
021 vertex and the last. In paths, there isn't, so we need to add that
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
022 edge explicitly.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
023
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
024 If `o` is not a polygon, will throw an exception."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
025 [o]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
026 (if
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
027 (polygon? o)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 19 forms covered">
|
||||||
|
028 (assoc (dissoc o :vertices) :nodes (concat (:vertices o) (list (first (:vertices o)))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
029 (throw (Exception. "Not a polygon!"))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
030
|
||||||
|
</span><br/>
|
||||||
|
</body>
|
||||||
|
</html>
|
59
docs/cloverage/walkmap/polygon.clj.html
Normal file
59
docs/cloverage/walkmap/polygon.clj.html
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link rel="stylesheet" href="../coverage.css"/> <title> walkmap/polygon.clj </title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
001 (ns walkmap.polygon
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
002 "Essentially the specification for things we shall consider to be polygons."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
003 (:require [walkmap.vertex :refer [vertex?]]))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
004
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
005 (defn polygon?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
006 "True if `o` satisfies the conditions for a polygon. A polygon shall be a
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
007 map which has a value for the key `:vertices`, where that value is a sequence
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
008 of vertices."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
009 [o]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
010 (let
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
011 [v (:vertices o)]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 9 forms covered">
|
||||||
|
012 (and
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
013 (seq? v)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
014 (> (count v) 2)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
015 (every? vertex? v))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
016
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
017
|
||||||
|
</span><br/>
|
||||||
|
</body>
|
||||||
|
</html>
|
386
docs/cloverage/walkmap/stl.clj.html
Normal file
386
docs/cloverage/walkmap/stl.clj.html
Normal file
|
@ -0,0 +1,386 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link rel="stylesheet" href="../coverage.css"/> <title> walkmap/stl.clj </title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
001 (ns walkmap.stl
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
002 "Utility functions dealing with stereolithography (STL) files. Not a stable API yet!"
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
003 (:require [clojure.java.io :as io :refer [file output-stream input-stream]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
004 [clojure.string :as s]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
005 [me.raynes.fs :as fs]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
006 [org.clojars.smee.binary.core :as b]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
007 [taoensso.timbre :as l :refer [info error spy]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
008 [walkmap.polygon :refer [polygon?]])
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
009 (:import org.clojars.smee.binary.core.BinaryIO
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
010 java.io.DataInput))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
011
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
012 (defn stl?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
013 "True if `o` is recogniseable as an STL structure. An STL structure must
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
014 have a key `:facets`, whose value must be a sequence of polygons; and
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
015 may have a key `:header` whose value should be a string, and/or a key
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
016 `:count`, whose value should be a positive integer.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
017
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
018 If `verify-count?` is passed and is not `false`, verify that the value of
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
019 the `:count` header is equal to the number of facets."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
020 ([o]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
021 (stl? o false))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
022 ([o verify-count?]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 22 forms covered">
|
||||||
|
023 (and
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
024 (map? o)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
025 (:facets o)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
026 (every? polygon? (:facets o))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 10 forms covered">
|
||||||
|
027 (if (:header o) (string? (:header o)) true)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 10 forms covered">
|
||||||
|
028 (if (:count o) (integer? (:count o)) true)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 11 forms covered">
|
||||||
|
029 (if verify-count? (= (:count o) (count (:facets o))) true))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
030
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
031 (def vect
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
032 "A codec for vectors within a binary STL file."
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="8 out of 8 forms covered">
|
||||||
|
033 (b/ordered-map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
034 :x :float-le
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
035 :y :float-le
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
036 :z :float-le))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
037
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
038 (def facet
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
039 "A codec for a facet (triangle) within a binary STL file."
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
|
040 (b/ordered-map
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
041 :normal vect
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
042 :vertices [vect vect vect]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
043 :abc :ushort-le))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
044
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
045 (def binary-stl
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
046 "A codec for binary STL files"
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="6 out of 6 forms covered">
|
||||||
|
047 (b/ordered-map
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
048 :header (b/string "ISO-8859-1" :length 80) ;; for the time being we neither know nor care what's in this.
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
049 :count :uint-le
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
050 :facets (b/repeated facet)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
051
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
052 (defn decode-binary-stl
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
053 "Parse a binary STL file from this `filename` and return an STL structure
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
054 representing its contents.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
055
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
056 **NOTE** that we've no way of verifying that the input file is binary STL
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
057 data, if it is not this will run but will return garbage."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
058 [filename]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
059 (let [in (io/input-stream filename)]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
060 (b/decode binary-stl in)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
061
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
062 (defn- vect->str [prefix v]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 16 forms covered">
|
||||||
|
063 (str prefix " " (:x v) " " (:y v) " " (:z v) "\n"))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
064
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
065 (defn- facet2str [tri]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
066 (str
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
067 (vect->str "facet normal" (:normal tri))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
068 "outer loop\n"
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
069 (apply str
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
070 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
071 #(vect->str "vertex" %)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
072 (:vertices tri)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
073 "endloop\nendfacet\n"))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
074
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
075 (defn stl->ascii
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
076 "Return as a string an ASCII rendering of the `stl` structure."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
077 ([stl]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
078 (stl->ascii stl "unknown"))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
079 ([stl solidname]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
080 (str
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
081 "solid "
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
082 solidname
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
083 (s/trim (:header stl))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
084 "\n"
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
085 (apply
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
086 str
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
087 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
088 facet2str
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
089 (:facets stl)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
090 "endsolid "
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
091 solidname
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
092 "\n")))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
093
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
094 (defn write-ascii-stl
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
095 "Write an `stl` structure as read by `decode-binary-stl` to this
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
096 `filename` as ASCII encoded STL."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
097 ([filename stl]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
098 (let [b (fs/base-name filename true)]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
099 (write-ascii-stl
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
100 filename stl
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 15 forms covered">
|
||||||
|
101 (subs b 0 (or (s/index-of b ".") (count b))))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
102 ([filename stl solidname]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 16 forms covered">
|
||||||
|
103 (l/debug "Solid name is " solidname)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
104 (spit
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
105 filename
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
106 (stl->ascii stl solidname))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
107
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
108 (defn binary-stl-to-ascii
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
109 "Convert the binary STL file indicated by `in-filename`, and write it to
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
110 `out-filename`, if specified; otherwise, to a file with the same basename
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
111 as `in-filename` but the extension `.ascii.stl`."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
112 ([in-filename]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
113 (let [[_ ext] (fs/split-ext in-filename)]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
114 (binary-stl-to-ascii
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
115 in-filename
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
116 (str
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
117 (subs
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
118 in-filename
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
119 0
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
120 (or
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
121 (s/last-index-of in-filename ".")
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
122 (count in-filename)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
123 ".ascii"
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
124 ext))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
125 ([in-filename out-filename]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 6 forms covered">
|
||||||
|
126 (write-ascii-stl out-filename (decode-binary-stl in-filename))))
|
||||||
|
</span><br/>
|
||||||
|
</body>
|
||||||
|
</html>
|
158
docs/cloverage/walkmap/svg.clj.html
Normal file
158
docs/cloverage/walkmap/svg.clj.html
Normal file
|
@ -0,0 +1,158 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link rel="stylesheet" href="../coverage.css"/> <title> walkmap/svg.clj </title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
001 (ns walkmap.svg
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
002 "Utility functions for writing stereolithography (STL) files (and possibly,
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
003 later, other geometry files of interest to us) as scalable vector graphics
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
004 (SVG)."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
005 (:require [clojure.string :as s]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
006 [taoensso.timbre :as l :refer [info error spy]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
007 [walkmap.polygon :refer [polygon?]]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
008 [walkmap.vertex :refer [vertex?]]))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
009
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
010 (defn- facet->svg-poly
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
011 [facet]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
012 [:polygon
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 20 forms covered">
|
||||||
|
013 {:points (s/join " " (map #(str (:x %) "," (:y %)) (:vertices facet)))}])
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
014
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
015 (defn stl->svg
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
016 "Convert this in-memory `stl` structure, as read by `decode-binary-stl`, into
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
017 an in-memory hiccup representation of SVG structure, and return it."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
018 [stl]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
019 (let [minx (reduce
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
020 min
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
021 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 9 forms covered">
|
||||||
|
022 #(reduce min (map :x (:vertices %)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
023 (:facets stl)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
024 maxx (reduce
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
025 max
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
026 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 9 forms covered">
|
||||||
|
027 #(reduce max (map :x (:vertices %)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
028 (:facets stl)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
029 miny (reduce
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
030 min
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
031 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 9 forms covered">
|
||||||
|
032 #(reduce min (map :y (:vertices %)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
033 (:facets stl)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
034 maxy (reduce
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
035 max
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
036 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 9 forms covered">
|
||||||
|
037 #(reduce max (map :y (:vertices %)))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
038 (:facets stl)))]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
039 [:svg
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 8 forms covered">
|
||||||
|
040 {:xmlns "http://www.w3.org/2000/svg"
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
041 :version "1.2"
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
042 :width (- maxx minx)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 4 forms covered">
|
||||||
|
043 :height (- maxy miny)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 11 forms covered">
|
||||||
|
044 :viewBox (s/join " " (map str [minx miny maxx maxy]))}
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
045 (vec
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
046 (cons
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
047 :g
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 2 forms covered">
|
||||||
|
048 (map
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
049 facet->svg-poly
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
050 (:facets stl))))]))
|
||||||
|
</span><br/>
|
||||||
|
</body>
|
||||||
|
</html>
|
137
docs/cloverage/walkmap/vertex.clj.html
Normal file
137
docs/cloverage/walkmap/vertex.clj.html
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link rel="stylesheet" href="../coverage.css"/> <title> walkmap/vertex.clj </title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
001 (ns walkmap.vertex
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
002 "Essentially the specification for things we shall consider to be vertices.")
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
003
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
004 (defn vertex?
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
005 "True if `o` satisfies the conditions for a vertex. That is, essentially,
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
006 that it must rerpresent a two- or three- dimensional vector. A vertex is
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
007 shall be a map having at least the keys `:x` and `:y`, where the value of
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
008 those keys is a number. If the key `:z` is also present, its value must also
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
009 be a number.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
010
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
011 The name `vector?` was not used as that would clash with a function of that
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
012 name in `clojure.core` whose semantics are entirely different."
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
013 [o]
|
||||||
|
</span><br/>
|
||||||
|
<span class="partial" title="15 out of 17 forms covered">
|
||||||
|
014 (and
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="3 out of 3 forms covered">
|
||||||
|
015 (map? o)
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
016 (number? (:x o))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="5 out of 5 forms covered">
|
||||||
|
017 (number? (:y o))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="9 out of 9 forms covered">
|
||||||
|
018 (or (nil? (:z o)) (number? (:z o)))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
019
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
020 (def ensure3d
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
021 "Given a vertex `o`, if `o` has a `:z` value, just return `o`; otherwise
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
022 return a vertex like `o` but having thie `dflt` value as the value of its
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
023 `:z` key, or zero as the value of its `:z` key if `dflt` is not specified.
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
024
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
025 If `o` is not a vertex, throws an exception."
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
026 (memoize
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
027 (fn
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
028 ([o]
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
029 (ensure3d o 0.0))
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
030 ([o dflt]
|
||||||
|
</span><br/>
|
||||||
|
<span class="partial" title="2 out of 3 forms covered">
|
||||||
|
031 (cond
|
||||||
|
</span><br/>
|
||||||
|
<span class="partial" title="5 out of 8 forms covered">
|
||||||
|
032 (not (vertex? o)) (throw (Exception. "Not a vertex!"))
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="4 out of 4 forms covered">
|
||||||
|
033 (:z o) o
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
034 :else (assoc o :z dflt))))))
|
||||||
|
</span><br/>
|
||||||
|
<span class="blank" title="0 out of 0 forms covered">
|
||||||
|
035
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
036 (def ensure2d
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||||
|
037 "If `o` is a vertex, set its `:z` value to zero; else throw an exception."
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="2 out of 2 forms covered">
|
||||||
|
038 (memoize
|
||||||
|
</span><br/>
|
||||||
|
<span class="covered" title="1 out of 1 forms covered">
|
||||||
|
039 (fn [o]
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 1 forms covered">
|
||||||
|
040 (if
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
041 (vertex? o)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 5 forms covered">
|
||||||
|
042 (assoc o :z 0.0)
|
||||||
|
</span><br/>
|
||||||
|
<span class="not-covered" title="0 out of 3 forms covered">
|
||||||
|
043 (throw (Exception. "Not a vertex!"))))))
|
||||||
|
</span><br/>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -2,9 +2,10 @@
|
||||||
"Essentially the specification for things we shall consider to be an edge.
|
"Essentially the specification for things we shall consider to be an edge.
|
||||||
An edge is a line segment having just a start and an end, with no intervening
|
An edge is a line segment having just a start and an end, with no intervening
|
||||||
nodes."
|
nodes."
|
||||||
(:require [walkmap.path :refer [path? polygon->path]]
|
(:require [clojure.math.numeric-tower :as m]
|
||||||
|
[walkmap.path :refer [path? polygon->path]]
|
||||||
[walkmap.polygon :refer [polygon?]]
|
[walkmap.polygon :refer [polygon?]]
|
||||||
[walkmap.vertex :refer [vertex?]]))
|
[walkmap.vertex :refer [ensure3d vertex?]]))
|
||||||
|
|
||||||
(defn edge?
|
(defn edge?
|
||||||
"True if `o` satisfies the conditions for a path. A path shall be a map
|
"True if `o` satisfies the conditions for a path. A path shall be a map
|
||||||
|
@ -35,3 +36,47 @@
|
||||||
(polygon? o)
|
(polygon? o)
|
||||||
(path->edges (polygon->path o))))
|
(path->edges (polygon->path o))))
|
||||||
|
|
||||||
|
(defn length
|
||||||
|
"Return the length of the edge `e`."
|
||||||
|
[e]
|
||||||
|
(let [start (ensure3d (:start e))
|
||||||
|
end (ensure3d (:end e))]
|
||||||
|
(m/sqrt
|
||||||
|
(reduce
|
||||||
|
+
|
||||||
|
(map
|
||||||
|
#(m/expt (- (% end) (% start)) 2)
|
||||||
|
[:x :y :z])))))
|
||||||
|
|
||||||
|
(defn unit-vector
|
||||||
|
"Return an vertex parallel to `e` starting from the coordinate origin. Two
|
||||||
|
edges which are parallel will have the same unit vector."
|
||||||
|
[e]
|
||||||
|
(let [e' {:start (ensure3d (:start e)) :end (ensure3d (:end e))}
|
||||||
|
l (length e')]
|
||||||
|
(reduce
|
||||||
|
merge
|
||||||
|
{}
|
||||||
|
(map
|
||||||
|
(fn [k]
|
||||||
|
{k (/ (- (k (:end e')) (k (:start e'))) l)})
|
||||||
|
[:x :y :z]))))
|
||||||
|
|
||||||
|
(defn parallel?
|
||||||
|
"True if all `edges` passed are parallel with one another."
|
||||||
|
;; TODO: this bears being wary about, dealing with floating point arithmetic.
|
||||||
|
;; Keep an eye out for spurious errors.
|
||||||
|
[& edges]
|
||||||
|
(let [uvs (map unit-vector edges)]
|
||||||
|
(every?
|
||||||
|
#(= % (first uvs))
|
||||||
|
(rest uvs))))
|
||||||
|
|
||||||
|
(defn collinear?
|
||||||
|
"True if edges `e1` and `e2` are collinear with one another."
|
||||||
|
[e1 e2]
|
||||||
|
(parallel?
|
||||||
|
e1
|
||||||
|
e2
|
||||||
|
{:start (:start e1) :end (:start e2)}))
|
||||||
|
|
||||||
|
|
|
@ -1,52 +1,19 @@
|
||||||
(ns walkmap.geometry
|
(ns walkmap.geometry
|
||||||
(:require [clojure.math.combinatorics :as combo]
|
(:require [clojure.math.combinatorics :as combo]
|
||||||
[clojure.math.numeric-tower :as m]
|
[clojure.math.numeric-tower :as m]
|
||||||
[walkmap.edge :as edge]
|
[walkmap.edge :as e]
|
||||||
[walkmap.path :refer [path? polygon->path]]
|
[walkmap.path :refer [path? polygon->path]]
|
||||||
[walkmap.polygon :refer [polygon?]]
|
[walkmap.polygon :refer [polygon?]]
|
||||||
[walkmap.vertex :as vertex]))
|
[walkmap.vertex :as v]))
|
||||||
|
|
||||||
(defn collinear?
|
|
||||||
"True if these vertices `v1`, `v2`, `v3` are colinear; false otherwise."
|
|
||||||
;; This is failing...
|
|
||||||
;; see http://www.ambrsoft.com/TrigoCalc/Line3D/LineColinear.htm
|
|
||||||
[v1 v2 v3]
|
|
||||||
(let [a (m/sqrt (+ (- (:x v2) (:x v1)) (- (:y v2) (:y v1)) (- (:z v2) (:z v1))))
|
|
||||||
b (m/sqrt (+ (- (:x v3) (:x v1)) (- (:y v3) (:y v1)) (- (:z v3) (:z v1))))
|
|
||||||
c (m/sqrt (+ (- (:x v3) (:x v2)) (- (:y v3) (:y v2)) (- (:z v3) (:z v2))))]
|
|
||||||
(not
|
|
||||||
(and
|
|
||||||
(> (+ a b) c)
|
|
||||||
(> (+ a c) b)
|
|
||||||
(> (+ b c) a)))))
|
|
||||||
|
|
||||||
;; (collinear? {:x 0 :y 0 :z 0} {:x 1 :y 1 :z 1} {:x 7 :y 7 :z 7})
|
|
||||||
;; (collinear? {:x 0 :y 0 :z 0} {:x 1 :y 2 :z 1} {:x 7 :y 7 :z 7})
|
|
||||||
;; (collinear? {:x 0 :y 0 :z 0} {:x 0 :y 2 :z 0} {:x 0 :y 3 :z 0})
|
|
||||||
|
|
||||||
;; (def v1 {:x 0 :y 0 :z 0})
|
|
||||||
;; (def v2 {:x 0 :y 2 :z 0})
|
|
||||||
;; (def v3 {:x 0 :y 7 :z 0})
|
|
||||||
|
|
||||||
;; (def a (m/sqrt (+ (- (:x v2) (:x v1)) (- (:y v2) (:y v1)) (- (:z v2) (:z v1)))))
|
|
||||||
;; a
|
|
||||||
;; (def b (m/sqrt (+ (- (:x v3) (:x v1)) (- (:y v3) (:y v1)) (- (:z v3) (:z v1)))))
|
|
||||||
;; b
|
|
||||||
;; (def c (m/sqrt (+ (- (:x v3) (:x v2)) (- (:y v3) (:y v2)) (- (:z v3) (:z v2)))))
|
|
||||||
;; c
|
|
||||||
|
|
||||||
;; (> (+ b c) a)
|
|
||||||
;; (> (+ a c) b)
|
|
||||||
;; (> (+ a c) c)
|
|
||||||
|
|
||||||
(defn on?
|
(defn on?
|
||||||
"True if the vertex `v` is on the edge `e`."
|
"True if the vertex `v` is on the edge `e`."
|
||||||
[e v]
|
[e v]
|
||||||
(let [p (vertex/ensure3d (:start e))
|
(let [p (v/ensure3d (:start e))
|
||||||
q (vertex/ensure3d v)
|
q (v/ensure3d v)
|
||||||
r (vertex/ensure3d (:end e))]
|
r (v/ensure3d (:end e))]
|
||||||
(and
|
(and
|
||||||
(collinear? p q r)
|
(e/collinear? p q r)
|
||||||
(<= (:x q) (max (:x p) (:x r)))
|
(<= (:x q) (max (:x p) (:x r)))
|
||||||
(>= (:x q) (min (:x p) (:x r)))
|
(>= (:x q) (min (:x p) (:x r)))
|
||||||
(<= (:y q) (max (:y p) (:y r)))
|
(<= (:y q) (max (:y p) (:y r)))
|
||||||
|
|
|
@ -17,24 +17,27 @@
|
||||||
(number? (:y o))
|
(number? (:y o))
|
||||||
(or (nil? (:z o)) (number? (:z o)))))
|
(or (nil? (:z o)) (number? (:z o)))))
|
||||||
|
|
||||||
(defn ensure3d
|
(def ensure3d
|
||||||
"Given a vertex `o`, if `o` has a `:z` value, just return `o`; otherwise
|
"Given a vertex `o`, if `o` has a `:z` value, just return `o`; otherwise
|
||||||
return a vertex like `o` but having thie `dflt` value as the value of its
|
return a vertex like `o` but having thie `dflt` value as the value of its
|
||||||
`:z` key, or zero as the value of its `:z` key if `dflt` is not specified.
|
`:z` key, or zero as the value of its `:z` key if `dflt` is not specified.
|
||||||
|
|
||||||
If `o` is not a vertex, throws an exception."
|
If `o` is not a vertex, throws an exception."
|
||||||
|
(memoize
|
||||||
|
(fn
|
||||||
([o]
|
([o]
|
||||||
(ensure3d o 0.0))
|
(ensure3d o 0.0))
|
||||||
([o dflt]
|
([o dflt]
|
||||||
(cond
|
(cond
|
||||||
(not (vertex? o)) (throw (Exception. "Not a vertex!"))
|
(not (vertex? o)) (throw (Exception. "Not a vertex!"))
|
||||||
(:z o) o
|
(:z o) o
|
||||||
:else (assoc o :z dflt))))
|
:else (assoc o :z dflt))))))
|
||||||
|
|
||||||
(defn ensure2d
|
(def ensure2d
|
||||||
"If `o` is a vertex, set its `:z` value to zero; else throw an exception."
|
"If `o` is a vertex, set its `:z` value to zero; else throw an exception."
|
||||||
[o]
|
(memoize
|
||||||
|
(fn [o]
|
||||||
(if
|
(if
|
||||||
(vertex? o)
|
(vertex? o)
|
||||||
(assoc o :z 0.0)
|
(assoc o :z 0.0)
|
||||||
(throw (Exception. "Not a vertex!"))))
|
(throw (Exception. "Not a vertex!"))))))
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
(:require [clojure.test :refer :all]
|
(:require [clojure.test :refer :all]
|
||||||
[walkmap.core :refer :all]))
|
[walkmap.core :refer :all]))
|
||||||
|
|
||||||
(deftest a-test
|
;; (deftest a-test
|
||||||
(testing "FIXME, I fail."
|
;; (testing "FIXME, I fail."
|
||||||
(is (= 0 1))))
|
;; (is (= 0 1))))
|
||||||
|
|
46
test/walkmap/edge_test.clj
Normal file
46
test/walkmap/edge_test.clj
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
(ns walkmap.edge-test
|
||||||
|
(:require [clojure.test :refer :all]
|
||||||
|
[walkmap.edge :refer :all]))
|
||||||
|
|
||||||
|
(deftest edge-test
|
||||||
|
(testing "identification of edges."
|
||||||
|
(is (edge? {:start {:x 0.0 :y 0.0 :z 0.0} :end {:x 3 :y 4 :z 0.0}}) "It is.")
|
||||||
|
(is (not (edge? {:start {:y 0.0 :z 0.0} :end {:x 3 :y 4 :z 0.0}})) "Start lacks :x key")
|
||||||
|
(is (not (edge? {:start {:x nil :y 0.0 :z 0.0} :end {:x 3 :y 4 :z 0.0}})) "Start lacks :x value")
|
||||||
|
(is (not (edge? {:begin {:x nil :y 0.0 :z 0.0} :end {:x 3 :y 4 :z 0.0}})) "Lacks start key")
|
||||||
|
(is (not (edge? {:start {:x nil :y 0.0 :z 0.0} :finish {:x 3 :y 4 :z 0.0}})) "Lacks end key")
|
||||||
|
(is (not (edge? {:start {:x "zero" :y 0.0 :z 0.0} :end {:x 3 :y 4 :z 0.0}})) "Value of x in start is not a number")
|
||||||
|
))
|
||||||
|
|
||||||
|
(deftest length-test
|
||||||
|
(testing "length of an edge"
|
||||||
|
(is (= (length {:start {:x 0.0 :y 0.0 :z 0.0} :end {:x 3.0 :y 4.0 :z 0.0}}) 5.0))))
|
||||||
|
|
||||||
|
(deftest unit-vector-test
|
||||||
|
(testing "deriving the unit vector"
|
||||||
|
(is (=
|
||||||
|
(unit-vector {:start {:x 0.0 :y 0.0 :z 0.0} :end {:x 3 :y 4 :z 0.0}})
|
||||||
|
{:x 0.6, :y 0.8, :z 0.0}))
|
||||||
|
(is (=
|
||||||
|
(unit-vector {:start {:x 1.0 :y 2.0 :z 3.5} :end {:x 4.0 :y 6.0 :z 3.5}})
|
||||||
|
{:x 0.6, :y 0.8, :z 0.0}))))
|
||||||
|
|
||||||
|
(deftest parallel-test
|
||||||
|
(testing "parallelism"
|
||||||
|
(is (parallel? {:start {:x 0.0 :y 0.0 :z 0.0} :end {:x 3 :y 4 :z 0.0}}
|
||||||
|
{:start {:x 1.0 :y 2.0 :z 3.5} :end {:x 4.0 :y 6.0 :z 3.5}})
|
||||||
|
"Should be")
|
||||||
|
(is (not
|
||||||
|
(parallel? {:start {:x 0.0 :y 0.0 :z 0.0} :end {:x 3 :y 4 :z 0.0}}
|
||||||
|
{:start {:x 1.0 :y 2.0 :z 3.5} :end {:x 4.0 :y 6.0 :z 3.49}}))
|
||||||
|
"Should not be!")))
|
||||||
|
|
||||||
|
(deftest collinear-test
|
||||||
|
(testing "collinearity"
|
||||||
|
(is (collinear? {:start {:x 0.0 :y 0.0 :z 0.0} :end {:x 3.0 :y 4.0 :z 0.0}}
|
||||||
|
{:start {:x 3.0 :y 4.0 :z 0.0} :end {:x 9.0 :y 12.0 :z 0.0}})
|
||||||
|
"Should be")
|
||||||
|
(is (not
|
||||||
|
(collinear? {:start {:x 0.0 :y 0.0 :z 0.0} :end {:x 3 :y 4 :z 0.0}}
|
||||||
|
{:start {:x 1.0 :y 2.0 :z 3.5} :end {:x 4.0 :y 6.0 :z 3.5}}))
|
||||||
|
"Should not be!")))
|
Loading…
Reference in a new issue