Class: Variation::LinearFunction
- Inherits:
-
Object
- Object
- Variation::LinearFunction
- Defined in:
- lib/variation/functions/linear_function.rb
Class Method Summary collapse
Class Method Details
.from_points(pt_a, pt_b, abruptness = 0.5) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/variation/functions/linear_function.rb', line 3 def self.from_points pt_a, pt_b, abruptness = 0.5 slope = (pt_b[1] - pt_a[1]) / (pt_b[0] - pt_a[0]).to_f intercept = pt_a[1] - (slope * pt_a[0]) lambda do |x| (slope * x) + intercept end end |