class Sangaku::Point

Public Class Methods

convert(points) click to toggle source
# File lib/sangaku/point.rb, line 9
def self.convert(points)
  points.map { |p| Point.new(*p) }
end
new(x, y) click to toggle source
# File lib/sangaku/point.rb, line 5
def initialize(x, y)
  @coord = [x, y]
end

Public Instance Methods

*(scale) click to toggle source
# File lib/sangaku/point.rb, line 31
def *(scale)
  Point.new(self.x * scale,  self.y * scale)
end
+(other) click to toggle source
# File lib/sangaku/point.rb, line 23
def +(other)
  Point.new(self.x + other.x, self.y + other.y)
end
-(other) click to toggle source
# File lib/sangaku/point.rb, line 27
def -(other)
  Point.new(self.x - other.x, self.y - other.y)
end
/(scale) click to toggle source
# File lib/sangaku/point.rb, line 35
def /(scale)
  Point.new(self.x / scale,  self.y / scale)
end
dist(other) click to toggle source
# File lib/sangaku/point.rb, line 39
def dist(other)
  Math.sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2 )
end
h()
Alias for: y
h=(val)
Alias for: y=
inspect()
Alias for: to_s
to_a() click to toggle source
# File lib/sangaku/point.rb, line 43
def to_a; @coord; end
to_s() click to toggle source
# File lib/sangaku/point.rb, line 44
def to_s; "(#{@coord.join(', ')})"; end
Also aliased as: inspect
w()
Alias for: x
w=(val)
Alias for: x=
x() click to toggle source
# File lib/sangaku/point.rb, line 13
def x; @coord[0]; end
Also aliased as: w
x=(val) click to toggle source
# File lib/sangaku/point.rb, line 14
def x=(val); @coord[0]=val; end
Also aliased as: w=
y() click to toggle source
# File lib/sangaku/point.rb, line 15
def y; @coord[1]; end
Also aliased as: h
y=(val) click to toggle source
# File lib/sangaku/point.rb, line 16
def y=(val); @coord[1]=val; end
Also aliased as: h=