Module: Vector2d::Properties
Instance Method Summary collapse
- #angle ⇒ Object
- #aspect_ratio ⇒ Object
- #length ⇒ Object
- #normalized? ⇒ Boolean
- #squared_length ⇒ Object
Instance Method Details
#angle ⇒ Object
12 13 14 |
# File 'lib/vector2d/properties.rb', line 12 def angle Math.atan2(y, x) end |
#aspect_ratio ⇒ Object
21 22 23 |
# File 'lib/vector2d/properties.rb', line 21 def aspect_ratio (x.to_f / y.to_f).abs end |
#length ⇒ Object
30 31 32 |
# File 'lib/vector2d/properties.rb', line 30 def length Math.sqrt(squared_length) end |
#normalized? ⇒ Boolean
49 50 51 |
# File 'lib/vector2d/properties.rb', line 49 def normalized? self.length.to_f == 1.0 end |
#squared_length ⇒ Object
39 40 41 |
# File 'lib/vector2d/properties.rb', line 39 def squared_length x * x + y * y end |