class VectorBeWinding::Vector
Attributes
x[RW]
y[RW]
Public Class Methods
new(x, y)
click to toggle source
# File lib/vector_be_winding/vector.rb, line 5 def initialize(x, y) @x = x @y = y end
Public Instance Methods
*(s)
click to toggle source
# File lib/vector_be_winding/vector.rb, line 26 def *(s) Vector.new(x * s, y * s) end
+(v)
click to toggle source
# File lib/vector_be_winding/vector.rb, line 18 def +(v) Vector.new(x + v.x, y + v.y) end
-(v)
click to toggle source
# File lib/vector_be_winding/vector.rb, line 22 def -(v) Vector.new(x - v.x, y - v.y) end
-@()
click to toggle source
# File lib/vector_be_winding/vector.rb, line 14 def -@() Vector.new(-x, -y) end
==(v)
click to toggle source
# File lib/vector_be_winding/vector.rb, line 10 def ==(v) x == v.x && y == v.y end
cross(v)
click to toggle source
# File lib/vector_be_winding/vector.rb, line 38 def cross(v) x * v.y - y * v.x end
dot(v)
click to toggle source
# File lib/vector_be_winding/vector.rb, line 30 def dot(v) x * v.x + y * v.y end
norm()
click to toggle source
# File lib/vector_be_winding/vector.rb, line 34 def norm dot(self) end
reflect(v)
click to toggle source
Create reflection point of self
# File lib/vector_be_winding/vector.rb, line 43 def reflect(v) v + (v - self) end