walkmap.vertex

Essentially the specification for things we shall consider to be vertices.

Note that there’s no distance function here; to find the distance between two vertices, create an edge from them and use walkmap.edge/length.

canonicalise

(canonicalise o)

If o is a map with numeric values for :x, :y and optionally :z, upgrade it to something we will recognise as a vertex.

check-vertex

macro

(check-vertex o)

If o is not a vertex, throw an IllegalArgumentException with an appropriate message; otherwise, returns o. Macro, so exception is thrown from the calling function.

check-vertices

macro

(check-vertices o)

If o is not a sequence of vertices, throw an IllegalArgumentException with an appropriate message; otherwise, returns o. Macro, so exception is thrown from the calling function.

ensure2d

If o is a vertex, set its :z value to zero; else throw an exception.

ensure3d

Given a vertex o, if o has a :z value, just return o; otherwise return a vertex like o but having this dflt value as the value of its :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.

vertex

(vertex x y)(vertex x y z)

Make a vertex with this x, y and (if provided) z values. Returns a map with those values, plus a unique :walkmap.id/id value, and :kind set to :vertex. It’s not necessary to use this function to create a vertex, but the :walkmap.id/id must be present and must be unique.

vertex*

(vertex* v1 v2)

Return a vertex like v1, but with each of its coordinates multiplied by the equivalent vertex in v2. It is an error, and an exception will be thrown, if either v1 or v2 is not a vertex.

vertex-key

(vertex-key o)

Making sure we get the same key everytime we key a vertex with the same coordinates. o must have numeric values for :x, :y, and optionally :z; it is an error and an exception will be thrown if o does not conform to this specification.

Note: these keys can be quite long. No apology is made: it is required that the same key can never refer to two different locations in space.

vertex=

(vertex= v1 v2)

True if vertices v1, v2 represent the same vertex.

vertex?

(vertex? o)

True if o satisfies the conditions for a vertex. That is, essentially, that it must rerpresent a two- or three- dimensional vector. A vertex is shall be a map having at least the keys :x and :y, where the value of those keys is a number. If the key :z is also present, its value must also be a number.

The name vector? was not used as that would clash with a function of that name in clojure.core whose semantics are entirely different.

within-box?

(within-box? target minv maxv)

True if target is within the box defined by minv and maxv. All arguments must be vertices; additionally, both minv and maxv must have :z coordinates.