Class: TerminalVis::Interpolation::LinearInterpolation
- Inherits:
-
Object
- Object
- TerminalVis::Interpolation::LinearInterpolation
- Defined in:
- lib/math/linear_interpolation.rb
Overview
math class to apply linear interpolation between two points
Class Method Summary collapse
-
.linear_interpolation(data_point0, data_point1, x, y) ⇒ Object
singleton method for linear interpolation between two points.
Class Method Details
.linear_interpolation(data_point0, data_point1, x, y) ⇒ Object
singleton method for linear interpolation between two points
18 19 20 21 22 |
# File 'lib/math/linear_interpolation.rb', line 18 def self.linear_interpolation(data_point0, data_point1, x, y) r = Interpolation::calculate_interpolation_factor(data_point0, data_point1, x, y) ((1-r) * data_point0.value + r * data_point1.value).round(3) end |