# weavejester/euclidean

Fast, immutable math for 3D geometries in Clojure Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information. src test/euclidean .gitignore .travis.yml README.md project.clj

# Euclidean A Clojure library for performing calculations suitable for 3D games using fast, immutable data structures.

Euclidean is written in pure Clojure, but has performance comparable to vector libraries written in Java, such as Vectorz.

## Installation

Add the following dependency to your `project.clj` file:

``````[euclidean "0.2.0"]
``````

## Usage

Euclidean provides two namespaces, one for constructing vectors, the other for quaternions:

```(require '[euclidean.math.vector :as v])
(require '[euclidean.math.quaternion :as q])```

The library includes data readers for 2D and 3D vectors, and 4D quaternions:

```#math/vector [1 2]          ;; 2D vector
#math/vector [1 2 3]        ;; 3D vector
#math/quaternion [0 0 0 1]  ;; Quaternion```

But you can also create data structures through various contructor functions:

```(v/vector 1 2)
(v/vector 1 2 3)
(v/into-vector [1 2])
(v/into-vector [1 2 3])

(q/quaternion 0 0 0 1)
(q/into-quaternion [0 0 0 1])```

These data structures implement standard Clojure interfaces, so you can use functions like `get`, `count` and `seq` on them:

```(def v (v/vector 1 2 3))

(get v 0)            ;; => 1.0
(v 1)                ;; => 2.0
(count v)            ;; => 3
(seq v)              ;; => (1.0 2.0 3.0)
(= v [1.0 2.0 3.0])  ;; => true```

Note how the numbers in the vector are stored as doubles. This is for performance purposes.

Euclidean provides a number of additional functions for manipulating and creating vectors and quaternions. For a full list, see the API documentation linked below.