class Draught::Point
Constants
- ZERO
Attributes
x[R]
y[R]
Public Class Methods
from_matrix(matrix)
click to toggle source
# File lib/draught/point.rb, line 7 def self.from_matrix(matrix) x, y = matrix.to_a.flatten Point.new(x, y) end
new(x, y)
click to toggle source
# File lib/draught/point.rb, line 16 def initialize(x, y) @x, @y = x, y end
Public Instance Methods
==(other)
click to toggle source
# File lib/draught/point.rb, line 24 def ==(other) other.point_type == point_type && other.x == x && other.y == y end
approximates?(other, delta)
click to toggle source
# File lib/draught/point.rb, line 29 def approximates?(other, delta) other.point_type == point_type && ((other.x - x).abs <= delta) && ((other.y - y).abs <= delta) end
point_type()
click to toggle source
# File lib/draught/point.rb, line 20 def point_type :point end
to_matrix()
click to toggle source
# File lib/draught/point.rb, line 43 def to_matrix @matrix ||= Matrix[[x],[y],[1]].freeze end
transform(transformation)
click to toggle source
# File lib/draught/point.rb, line 47 def transform(transformation) transformation.call(self) end
translate(vector)
click to toggle source
# File lib/draught/point.rb, line 35 def translate(vector) transform(vector.to_transform) end
translation_to(point)
click to toggle source
# File lib/draught/point.rb, line 39 def translation_to(point) Vector.translation_between(self, point) end