vector2d-ruby ============= A class for working with two dimensional vectors. ```ruby require 'vector2d' def print_my_vector vector puts "#{vector}, magnitude: #{vector.magnitude}, angle: #{vector.get_angle}" end a = Vector2D.new(3,10) print_my_vector a # 3:10, magnitude: 10.44030650891055, angle: 1.2793395323170296 b = a.normalize print_my_vector b # 0.2873478855663454:0.9578262852211513, magnitude: 0.9999999999999999, angle: 1.2793395323170296 c = b.multiply_scalar(3) print_my_vector c # 0.8620436566990362:2.873478855663454, magnitude: 2.9999999999999996, angle: 1.2793395323170296 d = c.rotate(Math::PI) print_my_vector d # -0.8620436566990365:2.873478855663454, magnitude: 2.9999999999999996, angle: 1.8622531212727638 ```
Project
vector2d-ruby
Basic math and operations on 2D Vectors. Ported and expanded upon Daniel Shiffman's Vector2D/PVector class for Processing (processing.org).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
Pull Requests
Development
Dependencies
Project Readme