class Dieses::Geometry::Equation::Steep

Public Class Methods

new(c) click to toggle source
# File lib/dieses/geometry/equation/steep.rb, line 7
def initialize(c)
  @x = c
end

Public Instance Methods

==(other)
Alias for: eql?
eql?(other) click to toggle source
# File lib/dieses/geometry/equation/steep.rb, line 50
def eql?(other)
  self.class == other.class && x == other.x
end
Also aliased as: ==
hash() click to toggle source
# File lib/dieses/geometry/equation/steep.rb, line 56
def hash
  self.class.hash ^ to_h.hash
end
intersect(other) click to toggle source

rubocop:enable Lint/UnusedMethodArgument

# File lib/dieses/geometry/equation/steep.rb, line 25
def intersect(other)
  case other
  when Slant
    x = self.x
    y = other.y(x)
  when Steep
    x = Float::INFINITY
    y = Float::INFINITY
  end

  Point.new(x, y)
end
left?(point, precision: Support::Float.precision) click to toggle source
# File lib/dieses/geometry/equation/steep.rb, line 38
def left?(point, precision: Support::Float.precision)
  Support.almost_less_than(point.x, x(point.y), precision: precision)
end
onto?(point, precision: Support::Float.precision) click to toggle source
# File lib/dieses/geometry/equation/steep.rb, line 46
def onto?(point, precision: Support::Float.precision)
  Support.almost_equal(point.x, x(point.y), precision: precision)
end
right?(point, precision: Support::Float.precision) click to toggle source
# File lib/dieses/geometry/equation/steep.rb, line 42
def right?(point, precision: Support::Float.precision)
  Support.almost_greater_than(point.x, x(point.y), precision: precision)
end
to_h() click to toggle source
# File lib/dieses/geometry/equation/steep.rb, line 60
def to_h
  { x: x }
end
to_s() click to toggle source
# File lib/dieses/geometry/equation/steep.rb, line 64
def to_s
  "E(x = #{c})"
end
translate(distance = nil, x: nil, y: nil) click to toggle source

rubocop:disable Lint/UnusedMethodArgument

# File lib/dieses/geometry/equation/steep.rb, line 20
def translate(distance = nil, x: nil, y: nil)
  self.class.new self.x + (distance || 0.0) + (x || 0.0)
end
x(_ = nil) click to toggle source
# File lib/dieses/geometry/equation/steep.rb, line 15
def x(_ = nil)
  @x
end
y(_ = nil) click to toggle source
# File lib/dieses/geometry/equation/steep.rb, line 11
def y(_ = nil)
  Float::INFINITY
end