class Point2d
Attributes
x[RW]
y[RW]
Public Class Methods
new(x=0, y=0)
click to toggle source
# File lib/point2d.rb, line 4 def initialize(x=0, y=0) @x = x @y = y end
Public Instance Methods
*(factor)
click to toggle source
# File lib/point2d.rb, line 17 def *(factor) Point2d.new(x*factor, y*factor) end
+(other)
click to toggle source
# File lib/point2d.rb, line 9 def +(other) Point2d.new(x+other.x, y+other.y) end
-(other)
click to toggle source
# File lib/point2d.rb, line 13 def -(other) Point2d.new(x-other.x, y-other.y) end
/(factor)
click to toggle source
# File lib/point2d.rb, line 21 def /(factor) Point2d.new(x/factor, y/factor) end
cross(other)
click to toggle source
# File lib/point2d.rb, line 25 def cross(other) x*other.y - y*other.x end
Also aliased as: %
dot(other)
click to toggle source
# File lib/point2d.rb, line 30 def dot(other) x*other.x + y*other.y end
Also aliased as: ^