Class: Dieses::Geometry::Equation::Steep

Inherits:
Object
  • Object
show all
Defined in:
lib/dieses/geometry/equation/steep.rb

Instance Method Summary collapse

Constructor Details

#initialize(c) ⇒ Steep

Returns a new instance of Steep.



7
8
9
# File 'lib/dieses/geometry/equation/steep.rb', line 7

def initialize(c)
  @x = c
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


50
51
52
# File 'lib/dieses/geometry/equation/steep.rb', line 50

def eql?(other)
  self.class == other.class && x == other.x
end

#hashObject



56
57
58
# File 'lib/dieses/geometry/equation/steep.rb', line 56

def hash
  self.class.hash ^ to_h.hash
end

#intersect(other) ⇒ Object

rubocop:enable Lint/UnusedMethodArgument



25
26
27
28
29
30
31
32
33
34
35
36
# 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) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# 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) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# 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) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# 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_hObject



60
61
62
# File 'lib/dieses/geometry/equation/steep.rb', line 60

def to_h
  { x: x }
end

#to_sObject



64
65
66
# File 'lib/dieses/geometry/equation/steep.rb', line 64

def to_s
  "E(x = #{c})"
end

#translate(distance = nil, x: nil, y: nil) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



20
21
22
# 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) ⇒ Object



15
16
17
# File 'lib/dieses/geometry/equation/steep.rb', line 15

def x(_ = nil)
  @x
end

#y(_ = nil) ⇒ Object



11
12
13
# File 'lib/dieses/geometry/equation/steep.rb', line 11

def y(_ = nil)
  Float::INFINITY
end