2D Vector | Simple Ruby extension in C
C Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ext
spec
.gitignore
Manifest
README.rdoc
Rakefile

README.rdoc

Usage

Simply require

require 'rubygems'
require 'v2d'

And use

v1 = V2D[1.0, 2.0]  # or v1 = V2D.new(1.0, 2.0)
v2 = V2D[0, 0]

v2.x = v1.x + 10 # v2 = V2D[11, 0]
v2.y = v1.y + 10 # v2 = V2D[11, 12]
(v1 + v2) == V2D[12, 14]
(v1 - v2) == V2D[-10, -10]
(v1 * 3)  == V2D[3, 6]
(v2 / 4)  == V2D[2.75, 3]
V2D[3, 4].abs == 5

Tests

spec v2d_spec.rb

Author

Vladimir Parfinenko, write at vladimir[dot]parfinenko[at]gmail[dot]com