Skip to content
No description, website, or topics provided.
Elixir Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bench
config
doc
lib
test
.gitignore
.travis.yml
LICENSE
README.md
mix.exs
mix.lock
validate.sh

README.md

Vector Math Library for Elixir

Build Status Hex.pm

Library of common vector functions for use in geometric or graphical calculations.

Installation

defp deps do
  [{:vector, "~> 1.0"}]
end

Usage

Full Documentation

The Vector module contains several functions that take one or more vectors. Each vector can be a 2- or 3-element tuple. It is possible to mix two- and three-dimensional vectors, in which case the z of the two-dimensional vector will be assumed 0.

Vector.dot({2, 3}, {1, 4}) #=> 14
Vector.cross({2, 0, -1}, {0, 3, 3}) #=> {3, -6, 6}
Vector.norm({3, -6, 6}) #=> 9
Vector.unit({2, -1}) #=> {0.894, -0.447}
Vector.add({2, 0, -1}, {0, 3, 3}) #=> {2, 3, 1}
Vector.subtract({2, 0, -1}, {1, 3}) #=> {1, -3, 1}
Vector.component({2, 3, -2}, :y) #=> 3

Tests

> mix test

Included in the project are a suite of algebraic identities that can be run against a large generated set of vectors.

You can’t perform that action at this time.