Class: Teien::Vector2D

Inherits:
Object
  • Object
show all
Defined in:
lib/teien/core/tools.rb

Overview

2d vector

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x = 0.0, y = 0.0) ⇒ Vector2D

Returns a new instance of Vector2D.



16
17
18
# File 'lib/teien/core/tools.rb', line 16

def initialize(x = 0.0, y = 0.0)
  set(x, y)
end

Instance Attribute Details

#xObject

Returns the value of attribute x.



14
15
16
# File 'lib/teien/core/tools.rb', line 14

def x
  @x
end

#yObject

Returns the value of attribute y.



15
16
17
# File 'lib/teien/core/tools.rb', line 15

def y
  @y
end

Instance Method Details

#==(o) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/teien/core/tools.rb', line 25

def ==(o)
  if o.is_a?(Vector2D)
    return @x == o.x && @y == o.y
  else
    return false
  end
end

#set(x, y) ⇒ Object



20
21
22
23
# File 'lib/teien/core/tools.rb', line 20

def set(x, y)
  @x = x
  @y = y
end