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 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
|
||||
"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
|
||||
|
|
|
@ -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]
|
||||
[taoensso.timbre :as l]
|
||||
[walkmap.path :refer [path]]
|
||||
;; [walkmap.polygon :refer [polygon]]
|
||||
[walkmap.tag :refer [tag]]
|
||||
[walkmap.utils :refer [kind-type truncate]]
|
||||
[walkmap.vertex :refer [vertex vertex?]]))
|
||||
|
@ -59,7 +58,7 @@
|
|||
representing the line (`l`, `L`) and move (`m`, `M`) commands in
|
||||
that path."
|
||||
[elt]
|
||||
(if (= (-> elt :tag) :path)
|
||||
(if (= (:tag elt) :path)
|
||||
(let [vs (command-string->vertices (-> elt :attrs :d))
|
||||
p (when-not (empty? vs) (apply path vs))]
|
||||
(if (and p (-> elt :attrs :class))
|
||||
|
|
|
@ -79,16 +79,21 @@
|
|||
:facets (canonicalise (:facets o) map-kind))
|
||||
;; if it has :vertices it's a polygon, but it may not yet conform to
|
||||
;; `polygon?`
|
||||
(:vertices o) (gradient
|
||||
(centre
|
||||
(tag
|
||||
(assoc o
|
||||
:walkmap.id/id (or
|
||||
(:walkmap.id/id o)
|
||||
(keyword (gensym "poly")))
|
||||
:kind :polygon
|
||||
:vertices (canonicalise (:vertices o) map-kind))
|
||||
:facet map-kind)))
|
||||
(:vertices o) (let [f (gradient
|
||||
(centre
|
||||
(tag
|
||||
(assoc o
|
||||
:walkmap.id/id (or
|
||||
(:walkmap.id/id o)
|
||||
(keyword (gensym "poly")))
|
||||
:kind :polygon
|
||||
:vertices (canonicalise
|
||||
(: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
|
||||
;; to `vertex?`; it should also be scaled using the scale-vertex, if any.
|
||||
(:x o) (let [c (v/canonicalise o)]
|
||||
|
@ -141,10 +146,10 @@
|
|||
(str
|
||||
(vect->str "facet normal" (:normal tri))
|
||||
"outer loop\n"
|
||||
(apply str
|
||||
(map
|
||||
#(vect->str "vertex" %)
|
||||
(:vertices tri)))
|
||||
(s/join
|
||||
(map
|
||||
#(vect->str "vertex" %)
|
||||
(:vertices tri)))
|
||||
"endloop\nendfacet\n"))
|
||||
|
||||
(defn stl->ascii
|
||||
|
@ -157,8 +162,7 @@
|
|||
solidname
|
||||
(s/trim (:header stl))
|
||||
"\n"
|
||||
(apply
|
||||
str
|
||||
(s/join
|
||||
(map
|
||||
facet2str
|
||||
(:facets stl)))
|
||||
|
|
|
@ -13,18 +13,17 @@
|
|||
1. `object` is not a map;
|
||||
2. any of `tags` is not a keyword."
|
||||
[object & tags]
|
||||
(if
|
||||
(map? object)
|
||||
(if
|
||||
(every? keyword? tags)
|
||||
(when-not (map? object)
|
||||
(throw (IllegalArgumentException.
|
||||
(str "Must be a map: " (kind-type object)))))
|
||||
(let [tags' (flatten tags)]
|
||||
(when-not (every? keyword? tags')
|
||||
(throw (IllegalArgumentException.
|
||||
(str "Must be keywords: " (map kind-type tags')))))
|
||||
(let [ot (::tags object)]
|
||||
(and
|
||||
(set? ot)
|
||||
(every? ot tags)))
|
||||
(throw (IllegalArgumentException.
|
||||
(str "Must be keyword(s): " (map kind-type tags)))))
|
||||
(throw (IllegalArgumentException.
|
||||
(str "Must be a map: " (kind-type object))))))
|
||||
(every? ot tags')))))
|
||||
|
||||
(defn tag
|
||||
"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))`."
|
||||
[object & 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)]
|
||||
(if
|
||||
(map? object)
|
||||
(if
|
||||
(every? keyword? tags')
|
||||
(assoc object ::tags (union (set tags') (::tags object)))
|
||||
(throw (IllegalArgumentException.
|
||||
(str "Must be keyword(s): " (map kind-type tags')))))
|
||||
(when-not (every? keyword? tags')
|
||||
(throw (IllegalArgumentException.
|
||||
(str "Must be a map: " (kind-type object)))))))
|
||||
(str "Must be keywords: " (map kind-type tags')))))
|
||||
(assoc object ::tags (union (set tags') (::tags object)))))
|
||||
|
||||
(defmacro tags
|
||||
"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
|
||||
|
||||
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]
|
||||
(if
|
||||
(map? object)
|
||||
(if
|
||||
(every? keyword? tags)
|
||||
(assoc object ::tags (difference (::tags object) (set tags)))
|
||||
(throw (IllegalArgumentException.
|
||||
(str "Must be keywords: " (map kind-type tags)))))
|
||||
(when-not (map? object)
|
||||
(throw (IllegalArgumentException.
|
||||
(str "Must be a map: " (kind-type object))))))
|
||||
(str "Must be a map: " (kind-type object)))))
|
||||
(let [tags' (flatten tags)]
|
||||
(when-not (every? keyword? tags')
|
||||
(throw (IllegalArgumentException.
|
||||
(str "Must be keywords: " (map kind-type tags')))))
|
||||
(assoc object ::tags (difference (::tags object) (set tags')))))
|
||||
|
|
|
@ -27,3 +27,17 @@
|
|||
,essages, so return \"nil\"."
|
||||
[object]
|
||||
(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