Skip to content

escherlies/elm-vectors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-vectors

Basic, fast linear algebra operations for working with vectors in Elm.

If you do not work with WebGl, you can use this as a much faster alternative than the elm-explorations/linear-algebra package. See Benchmarks for some performance comparisons. You can use this package as a drop-in replacement of the beforementionend.

Usage

a : Vec Float
a =
    vec2 1 2


doSomeMath : Vec Float -> Vec Float
doSomeMath b =
    b
        |> sub a
        |> add (vec2 3 4)
        |> normalize
        |> scale 5


result : Vec Float
result =
    doSomeMath (Vec 5 6) --> Vec -5 0 : Vec Float

You can work with integer vectors as well, although most calculations require floats.

In that case it useful to convert it to an integer vector at the first and last step:

doSomeIntMath : Vec Int -> Vec Int
doSomeIntMath =
    Math.Vector2.round << doSomeMath << Math.Vector2.toFloat

Other packages

About

Basic linear algebra operations for working with vectors in Elm.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages