class Mittsu::Vector2
Constants
- DIMENSIONS
- ELEMENTS
Public Class Methods
new(x = 0, y = 0)
click to toggle source
Calls superclass method
Mittsu::Vector::new
# File lib/mittsu/math/vector2.rb, line 8 def initialize(x = 0, y = 0) super [x.to_f, y.to_f] end
Public Instance Methods
distance_to_squared(v)
click to toggle source
# File lib/mittsu/math/vector2.rb, line 26 def distance_to_squared(v) dx, dy = x - v.x, y - v.y dx * dx + dy * dy end
dot(v)
click to toggle source
# File lib/mittsu/math/vector2.rb, line 22 def dot(v) x * v.x + y * v.y end
from_attribute(attribute, index, offset = 0)
click to toggle source
# File lib/mittsu/math/vector2.rb, line 31 def from_attribute(attribute, index, offset = 0) index = index * attribute.item_size + offset @elements[0] = attribute.array[index] @elements[1] = attribute.array[index + 1] self end
set(x, y)
click to toggle source
Calls superclass method
Mittsu::Vector#set
# File lib/mittsu/math/vector2.rb, line 12 def set(x, y) super [x.to_f, y.to_f] end
x()
click to toggle source
# File lib/mittsu/math/vector2.rb, line 16 def x; @elements[0]; end
x=(value)
click to toggle source
# File lib/mittsu/math/vector2.rb, line 19 def x=(value); @elements[0] = value.to_f; end
y()
click to toggle source
# File lib/mittsu/math/vector2.rb, line 17 def y; @elements[1]; end
y=(value)
click to toggle source
# File lib/mittsu/math/vector2.rb, line 20 def y=(value); @elements[1] = value.to_f; end