Kibitsing, cleanup.
There's a problem here that both kibit and cloverage are reporting an unterminated file, but all tests run.
This commit is contained in:
parent
819aa0fbc4
commit
c7469051f4
|
@ -1,9 +0,0 @@
|
||||||
(ns walkmap.core
|
|
||||||
"This namespace mostly gets used as a scratchpad for ideas which haven't yet
|
|
||||||
solidified."
|
|
||||||
(:require [clojure.java.io :as io :refer [file output-stream input-stream]]
|
|
||||||
[clojure.string :as s]
|
|
||||||
[hiccup.core :refer [html]]
|
|
||||||
[me.raynes.fs :as fs]
|
|
||||||
[taoensso.timbre :as l :refer [info error spy]]))
|
|
||||||
|
|
|
@ -122,19 +122,6 @@
|
||||||
(> (minimaxd e1 :y max) (minimaxd e2 :y min))
|
(> (minimaxd e1 :y max) (minimaxd e2 :y min))
|
||||||
(< (minimaxd e1 :y min) (minimaxd e2 :y max)))))
|
(< (minimaxd e1 :y min) (minimaxd e2 :y max)))))
|
||||||
|
|
||||||
;; Don't think I need this.
|
|
||||||
;; (defn orientation
|
|
||||||
;; "Determine whether the ordered sequence of vertices `p`, `q` and `r` run
|
|
||||||
;; clockwise, collinear or anticlockwise in the x,y plane."
|
|
||||||
;; [p q r]
|
|
||||||
;; (let [v (- (* (- (:y q) (:y p)) (- (:x r) (:x q)))
|
|
||||||
;; (* (- (:x q) (:x p)) (- (:y r) (:y q))))]
|
|
||||||
;; (cond
|
|
||||||
;; (zero? v) :collinear
|
|
||||||
;; (pos? v) :clockwise
|
|
||||||
;; :else
|
|
||||||
;; :anticlockwise)))
|
|
||||||
|
|
||||||
(defn intersection2d
|
(defn intersection2d
|
||||||
"The probability of two lines intersecting in 3d space is low, and actually
|
"The probability of two lines intersecting in 3d space is low, and actually
|
||||||
that is mostly not something we're interested in. We're interested in
|
that is mostly not something we're interested in. We're interested in
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
(ns walkmap.geometry
|
|
||||||
(:require [clojure.math.combinatorics :as combo]
|
|
||||||
[clojure.math.numeric-tower :as m]))
|
|
||||||
|
|
||||||
(defn =ish
|
|
||||||
"True if numbers `n1`, `n2` are roughly equal; that is to say, equal to
|
|
||||||
within `tolerance` (defaults to one part in a million)."
|
|
||||||
([n1 n2]
|
|
||||||
(if (and (number? n1) (number? n2))
|
|
||||||
(let [m (m/abs (min n1 n2))
|
|
||||||
t (if (zero? m) 0.000001 (* 0.000001 m))]
|
|
||||||
(=ish n1 n2 t))
|
|
||||||
(= n1 n2)))
|
|
||||||
([n1 n2 tolerance]
|
|
||||||
(if (and (number? n1) (number? n2))
|
|
||||||
(< (m/abs (- n1 n2)) tolerance)
|
|
||||||
(= n1 n2))))
|
|
|
@ -9,7 +9,6 @@
|
||||||
[clojure.zip :as z]
|
[clojure.zip :as z]
|
||||||
[taoensso.timbre :as l]
|
[taoensso.timbre :as l]
|
||||||
[walkmap.path :refer [path]]
|
[walkmap.path :refer [path]]
|
||||||
;; [walkmap.polygon :refer [polygon]]
|
|
||||||
[walkmap.tag :refer [tag]]
|
[walkmap.tag :refer [tag]]
|
||||||
[walkmap.utils :refer [kind-type truncate]]
|
[walkmap.utils :refer [kind-type truncate]]
|
||||||
[walkmap.vertex :refer [vertex vertex?]]))
|
[walkmap.vertex :refer [vertex vertex?]]))
|
||||||
|
@ -59,7 +58,7 @@
|
||||||
representing the line (`l`, `L`) and move (`m`, `M`) commands in
|
representing the line (`l`, `L`) and move (`m`, `M`) commands in
|
||||||
that path."
|
that path."
|
||||||
[elt]
|
[elt]
|
||||||
(if (= (-> elt :tag) :path)
|
(if (= (:tag elt) :path)
|
||||||
(let [vs (command-string->vertices (-> elt :attrs :d))
|
(let [vs (command-string->vertices (-> elt :attrs :d))
|
||||||
p (when-not (empty? vs) (apply path vs))]
|
p (when-not (empty? vs) (apply path vs))]
|
||||||
(if (and p (-> elt :attrs :class))
|
(if (and p (-> elt :attrs :class))
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
:facets (canonicalise (:facets o) map-kind))
|
:facets (canonicalise (:facets o) map-kind))
|
||||||
;; if it has :vertices it's a polygon, but it may not yet conform to
|
;; if it has :vertices it's a polygon, but it may not yet conform to
|
||||||
;; `polygon?`
|
;; `polygon?`
|
||||||
(:vertices o) (gradient
|
(:vertices o) (let [f (gradient
|
||||||
(centre
|
(centre
|
||||||
(tag
|
(tag
|
||||||
(assoc o
|
(assoc o
|
||||||
|
@ -87,8 +87,13 @@
|
||||||
(:walkmap.id/id o)
|
(:walkmap.id/id o)
|
||||||
(keyword (gensym "poly")))
|
(keyword (gensym "poly")))
|
||||||
:kind :polygon
|
:kind :polygon
|
||||||
:vertices (canonicalise (:vertices o) map-kind))
|
:vertices (canonicalise
|
||||||
:facet map-kind)))
|
(:vertices o)
|
||||||
|
map-kind))
|
||||||
|
:facet map-kind)))]
|
||||||
|
(if (o/ocean? f)
|
||||||
|
(tag f :ocean :no-traversal)
|
||||||
|
f))
|
||||||
;; if it has a value for :x it's a vertex, but it may not yet conform
|
;; if it has a value for :x it's a vertex, but it may not yet conform
|
||||||
;; to `vertex?`; it should also be scaled using the scale-vertex, if any.
|
;; to `vertex?`; it should also be scaled using the scale-vertex, if any.
|
||||||
(:x o) (let [c (v/canonicalise o)]
|
(:x o) (let [c (v/canonicalise o)]
|
||||||
|
@ -141,7 +146,7 @@
|
||||||
(str
|
(str
|
||||||
(vect->str "facet normal" (:normal tri))
|
(vect->str "facet normal" (:normal tri))
|
||||||
"outer loop\n"
|
"outer loop\n"
|
||||||
(apply str
|
(s/join
|
||||||
(map
|
(map
|
||||||
#(vect->str "vertex" %)
|
#(vect->str "vertex" %)
|
||||||
(:vertices tri)))
|
(:vertices tri)))
|
||||||
|
@ -157,8 +162,7 @@
|
||||||
solidname
|
solidname
|
||||||
(s/trim (:header stl))
|
(s/trim (:header stl))
|
||||||
"\n"
|
"\n"
|
||||||
(apply
|
(s/join
|
||||||
str
|
|
||||||
(map
|
(map
|
||||||
facet2str
|
facet2str
|
||||||
(:facets stl)))
|
(:facets stl)))
|
||||||
|
|
|
@ -13,18 +13,17 @@
|
||||||
1. `object` is not a map;
|
1. `object` is not a map;
|
||||||
2. any of `tags` is not a keyword."
|
2. any of `tags` is not a keyword."
|
||||||
[object & tags]
|
[object & tags]
|
||||||
(if
|
(when-not (map? object)
|
||||||
(map? object)
|
(throw (IllegalArgumentException.
|
||||||
(if
|
(str "Must be a map: " (kind-type object)))))
|
||||||
(every? keyword? tags)
|
(let [tags' (flatten tags)]
|
||||||
|
(when-not (every? keyword? tags')
|
||||||
|
(throw (IllegalArgumentException.
|
||||||
|
(str "Must be keywords: " (map kind-type tags')))))
|
||||||
(let [ot (::tags object)]
|
(let [ot (::tags object)]
|
||||||
(and
|
(and
|
||||||
(set? ot)
|
(set? ot)
|
||||||
(every? ot tags)))
|
(every? ot tags')))))
|
||||||
(throw (IllegalArgumentException.
|
|
||||||
(str "Must be keyword(s): " (map kind-type tags)))))
|
|
||||||
(throw (IllegalArgumentException.
|
|
||||||
(str "Must be a map: " (kind-type object))))))
|
|
||||||
|
|
||||||
(defn tag
|
(defn tag
|
||||||
"Return an object like this `object` but with these `tags` added to its tags,
|
"Return an object like this `object` but with these `tags` added to its tags,
|
||||||
|
@ -38,16 +37,14 @@
|
||||||
useful things like `(tag obj (map keyword some-strings))`."
|
useful things like `(tag obj (map keyword some-strings))`."
|
||||||
[object & tags]
|
[object & tags]
|
||||||
(l/debug "Tagging" (kind-type object) "with" tags)
|
(l/debug "Tagging" (kind-type object) "with" tags)
|
||||||
|
(when-not (map? object)
|
||||||
|
(throw (IllegalArgumentException.
|
||||||
|
(str "Must be a map: " (kind-type object)))))
|
||||||
(let [tags' (flatten tags)]
|
(let [tags' (flatten tags)]
|
||||||
(if
|
(when-not (every? keyword? tags')
|
||||||
(map? object)
|
|
||||||
(if
|
|
||||||
(every? keyword? tags')
|
|
||||||
(assoc object ::tags (union (set tags') (::tags object)))
|
|
||||||
(throw (IllegalArgumentException.
|
(throw (IllegalArgumentException.
|
||||||
(str "Must be keyword(s): " (map kind-type tags')))))
|
(str "Must be keywords: " (map kind-type tags')))))
|
||||||
(throw (IllegalArgumentException.
|
(assoc object ::tags (union (set tags') (::tags object)))))
|
||||||
(str "Must be a map: " (kind-type object)))))))
|
|
||||||
|
|
||||||
(defmacro tags
|
(defmacro tags
|
||||||
"Return the tags of this object, if any."
|
"Return the tags of this object, if any."
|
||||||
|
@ -59,14 +56,13 @@
|
||||||
tags, if present. It is an error (and an exception will be thrown) if
|
tags, if present. It is an error (and an exception will be thrown) if
|
||||||
|
|
||||||
1. `object` is not a map;
|
1. `object` is not a map;
|
||||||
2. any of `tags` is not a keyword."
|
2. any of `tags` is not a keyword or sequence of keywords."
|
||||||
[object & tags]
|
[object & tags]
|
||||||
(if
|
(when-not (map? object)
|
||||||
(map? object)
|
|
||||||
(if
|
|
||||||
(every? keyword? tags)
|
|
||||||
(assoc object ::tags (difference (::tags object) (set tags)))
|
|
||||||
(throw (IllegalArgumentException.
|
(throw (IllegalArgumentException.
|
||||||
(str "Must be keywords: " (map kind-type tags)))))
|
(str "Must be a map: " (kind-type object)))))
|
||||||
|
(let [tags' (flatten tags)]
|
||||||
|
(when-not (every? keyword? tags')
|
||||||
(throw (IllegalArgumentException.
|
(throw (IllegalArgumentException.
|
||||||
(str "Must be a map: " (kind-type object))))))
|
(str "Must be keywords: " (map kind-type tags')))))
|
||||||
|
(assoc object ::tags (difference (::tags object) (set tags')))))
|
||||||
|
|
|
@ -27,3 +27,17 @@
|
||||||
,essages, so return \"nil\"."
|
,essages, so return \"nil\"."
|
||||||
[object]
|
[object]
|
||||||
(or (:kind object) (type object) "nil"))
|
(or (:kind object) (type object) "nil"))
|
||||||
|
|
||||||
|
(defn =ish
|
||||||
|
"True if numbers `n1`, `n2` are roughly equal; that is to say, equal to
|
||||||
|
within `tolerance` (defaults to one part in a million)."
|
||||||
|
([n1 n2]
|
||||||
|
(if (and (number? n1) (number? n2))
|
||||||
|
(let [m (m/abs (min n1 n2))
|
||||||
|
t (if (zero? m) 0.000001 (* 0.000001 m))]
|
||||||
|
(=ish n1 n2 t))
|
||||||
|
(= n1 n2)))
|
||||||
|
([n1 n2 tolerance]
|
||||||
|
(if (and (number? n1) (number? n2))
|
||||||
|
(< (m/abs (- n1 n2)) tolerance)
|
||||||
|
(= n1 n2))))
|
||||||
|
|
Loading…
Reference in a new issue