Giter Site home page Giter Site logo

euclidean's Introduction

Euclidean

Build Status

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.

Documentation

License

Copyright © 2013 James Reeves

Distributed under the Eclipse Public License, the same as Clojure.

euclidean's People

Contributors

weavejester avatar aamedina avatar floybix avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.