Skip to content

Common vector functions for use in geometric or graphical calculations.

License

Notifications You must be signed in to change notification settings

pkinney/vector_ex

Repository files navigation

Vector Math Library for Elixir

Build Status Hex.pm Documentation

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

Installation

defp deps do
  [{:vector, "~> 1.1"}]
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.

About

Common vector functions for use in geometric or graphical calculations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •