Class: Sevgi::Geometry::Equation::Linear::Horizontal
- Defined in:
- lib/sevgi/geometry/equation/linear.rb
Overview
Horizontal linear equation in y = c form.
Instance Attribute Summary
Attributes inherited from Diagonal
Instance Method Summary collapse
-
#approx(precision = nil) ⇒ Sevgi::Geometry::Equation::Linear::Horizontal
Returns an equation rounded to precision.
-
#initialize(c) ⇒ void
constructor
Creates a horizontal equation.
-
#shift(distance = nil, dx: nil, dy: nil) ⇒ Sevgi::Geometry::Equation::Linear::Horizontal
Returns a parallel horizontal equation shifted by offsets.
-
#to_s ⇒ String
Formats the equation for display.
Methods inherited from Diagonal
#eql?, #hash, #left?, #on?, #right?, #x, #y
Constructor Details
#initialize(c) ⇒ void
Creates a horizontal equation.
119 |
# File 'lib/sevgi/geometry/equation/linear.rb', line 119 def initialize(c) = super(slope: 0.0, intercept: c) |
Instance Method Details
#approx(precision = nil) ⇒ Sevgi::Geometry::Equation::Linear::Horizontal
Returns an equation rounded to precision.
124 |
# File 'lib/sevgi/geometry/equation/linear.rb', line 124 def approx(precision = nil) = self.class.new(F.approx(intercept, precision)) |
#shift(distance = nil, dx: nil, dy: nil) ⇒ Sevgi::Geometry::Equation::Linear::Horizontal
Returns a parallel horizontal equation shifted by offsets.
A positive signed distance shifts upward in screen coordinates.
133 134 135 136 137 |
# File 'lib/sevgi/geometry/equation/linear.rb', line 133 def shift(distance = nil, dx: nil, dy: nil) _dx = dx self.class.new(intercept + (dy || 0.0) - (distance || 0.0)) end |
#to_s ⇒ String
Formats the equation for display.
141 |
# File 'lib/sevgi/geometry/equation/linear.rb', line 141 def to_s = "Linear<y = #{F.approx(intercept)}>" |