Class: Teien::Vector2D
- Inherits:
-
Object
- Object
- Teien::Vector2D
- Defined in:
- lib/teien/core/tools.rb
Overview
2d vector
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#initialize(x = 0.0, y = 0.0) ⇒ Vector2D
constructor
A new instance of Vector2D.
- #set(x, y) ⇒ Object
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
#x ⇒ Object
Returns the value of attribute x.
14 15 16 |
# File 'lib/teien/core/tools.rb', line 14 def x @x end |
#y ⇒ Object
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 |