Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elektronaut/vector2d
Ruby library (and gem) for handling two-dimensional vectors
https://github.com/elektronaut/vector2d
math ruby vector
Last synced: 1 day ago
JSON representation
Ruby library (and gem) for handling two-dimensional vectors
- Host: GitHub
- URL: https://github.com/elektronaut/vector2d
- Owner: elektronaut
- License: mit
- Created: 2009-05-19T23:37:56.000Z (over 15 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T12:33:07.000Z (3 months ago)
- Last Synced: 2024-10-29T14:59:11.355Z (3 months ago)
- Topics: math, ruby, vector
- Language: Ruby
- Homepage:
- Size: 107 KB
- Stars: 9
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Version](https://img.shields.io/gem/v/vector2d.svg?style=flat)](https://rubygems.org/gems/vector2d)
![Build](https://github.com/elektronaut/vector2d/workflows/Build/badge.svg)
[![Code Climate](https://codeclimate.com/github/elektronaut/vector2d/badges/gpa.svg)](https://codeclimate.com/github/elektronaut/vector2d)
[![Code Climate](https://codeclimate.com/github/elektronaut/vector2d/badges/coverage.svg)](https://codeclimate.com/github/elektronaut/vector2d)# Vector2d
Vector2d handles two-dimensional coordinates and vectors.
Vectors are immutable, meaning this is a purely functional library.## Quick example
```ruby
require 'vector2d'vector = Vector2d(50, 70)
vector.aspect_ratio # => 0.714285714285714
vector.length # => 86.0232526704263vector * 2 # => Vector2d(100,140)
vector + Vector2d(20, 30) # => Vector2d(70,100)vector.fit(Vector2d(64, 64)) # => Vector2d(64,45)
Vector2d.parse([50, 70]) # => Vector2d(50,70)
Vector2d.parse("50x70") # => Vector2d(50,70)
```## Documentation
[API documentation](https://rdoc.info/github/elektronaut/vector2d/main)
## License
Copyright (c) 2006-2019 Inge Jørgensen
Vector2d is released under the [MIT License](http://www.opensource.org/licenses/MIT).