Class: Dieses::Geometry::Equation::Steep
- Inherits:
-
Object
- Object
- Dieses::Geometry::Equation::Steep
- Defined in:
- lib/dieses/geometry/equation/steep.rb
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(c) ⇒ Steep
constructor
A new instance of Steep.
-
#intersect(other) ⇒ Object
rubocop:enable Lint/UnusedMethodArgument.
- #left?(point, precision: Support::Float.precision) ⇒ Boolean
- #onto?(point, precision: Support::Float.precision) ⇒ Boolean
- #right?(point, precision: Support::Float.precision) ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
-
#translate(distance = nil, x: nil, y: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
- #x(_ = nil) ⇒ Object
- #y(_ = nil) ⇒ Object
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: ==
50 51 52 |
# File 'lib/dieses/geometry/equation/steep.rb', line 50 def eql?(other) self.class == other.class && x == other.x end |
#hash ⇒ Object
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
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
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
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_h ⇒ Object
60 61 62 |
# File 'lib/dieses/geometry/equation/steep.rb', line 60 def to_h { x: x } end |
#to_s ⇒ Object
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 |