Class: Vector2d
- Inherits:
-
Object
- Object
- Vector2d
- Extended by:
- Calculations::ClassMethods
- Includes:
- Contracts, Calculations, Coercions, Fitting, Properties, Transformations
- Defined in:
- lib/vector2d.rb,
lib/vector2d.rb,
lib/vector2d/fitting.rb,
lib/vector2d/version.rb,
lib/vector2d/coercions.rb,
lib/vector2d/properties.rb,
lib/vector2d/calculations.rb,
lib/vector2d/transformations.rb
Defined Under Namespace
Modules: Calculations, Coercions, Fitting, Properties, Transformations
Constant Summary collapse
- VectorLike =
Or[ [Num, Num]
- VERSION =
"2.2.3"
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Class Method Summary collapse
Instance Method Summary collapse
- #==(comp) ⇒ Object
-
#initialize(x, y) ⇒ Vector2d
constructor
A new instance of Vector2d.
Methods included from Calculations::ClassMethods
angle_between, cross_product, dot_product
Methods included from Transformations
#ceil, #floor, #normalize, #perpendicular, #resize, #reverse, #rotate, #round, #truncate
Methods included from Properties
#angle, #aspect_ratio, #length, #normalized?, #squared_length
Methods included from Fitting
Methods included from Coercions
#coerce, #inspect, #to_a, #to_f_vector, #to_hash, #to_i_vector, #to_s
Methods included from Calculations
#*, #+, #-, #/, #angle_between, #cross_product, #distance, #dot_product, #squared_distance
Constructor Details
#initialize(x, y) ⇒ Vector2d
Returns a new instance of Vector2d.
91 92 93 |
# File 'lib/vector2d.rb', line 91 def initialize(x, y) @x, @y = x, y end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
89 90 91 |
# File 'lib/vector2d.rb', line 89 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
89 90 91 |
# File 'lib/vector2d.rb', line 89 def y @y end |
Class Method Details
.parse(arg, second_arg = nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/vector2d.rb', line 45 def parse(arg, second_arg = nil) if second_arg.nil? parse_single_arg(arg) else self.new(arg, second_arg) end end |
Instance Method Details
#==(comp) ⇒ Object
101 102 103 |
# File 'lib/vector2d.rb', line 101 def ==(comp) comp.x === x && comp.y === y end |