crystal_vector_math

Vector and Matrix math library for the Crystal language

vector_math

Crystal library for basic 2D, 3D, and 4D vector and matrix math.

It's currently quite small, but includes:

  • Everything is a struct, so everything happens on the stack
  • Completely immutable, so behavior is easy to reason about
  • Operator overloading for +, -, * and /
  • Rotation and translation helpers for 4D matrices

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  vector_math:
    github: ajselvig/crystal_vector_math
  1. Run shards install

Usage

require "vector_math"
include VectorMath

# 2D vectors
vec2(1.0, 2.0) + vec2(3.0, 4.0)
# => [4.0, 6.0]
vec2(2.0, 4.0, 6.0) / 2
# => [1.0, 2.0, 3.0]

Contributing

  1. Fork it (https://github.com/ajselvig/crystal_vector_math/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

crystal_vector_math

Owner
Statistic
  • 1
  • 0
  • 0
  • 0
  • 0
  • over 5 years ago
  • January 20, 2019
License

MIT License

Links
Synced at

Thu, 16 May 2024 18:16:45 GMT

Languages