Module: TerminalVis::Interpolation
- Defined in:
- lib/math/interpolation.rb,
lib/math/linear_interpolation.rb,
lib/math/region_interpolation.rb,
lib/math/bilinear_interpolation.rb
Overview
This module holds methods and classes to interpolate data values with different methods. The following interpolation methods are implemented:
* Linear interpolation
* Bilinear interpolation
* Region interpolation
Defined Under Namespace
Classes: BilinearInterpolation, DataPoint, LinearInterpolation, RegionInterpolation
Class Method Summary collapse
-
.calculate_interpolation_factor(data_point0, data_point1, x, y) ⇒ Float
singleton method to calculate interpolation coefficient with accuracy to the fifth digit.
-
.interpolate_for_coordinate(meta_data, coordinates, data_set) ⇒ Float
interpolates the data for the provided coordinate and prints the result.
-
.linear_interpolation_for_coordinate(data_point0, data_point1, x, y) ⇒ Float
singleton method for linear interpolation between two points.
-
.region_interpolation(meta_data, data_set, coordinates, values) ⇒ Object
singleton method to interpolate the data values specified for the region defined by the coordinates and the interval and delta values.
Class Method Details
.calculate_interpolation_factor(data_point0, data_point1, x, y) ⇒ Float
singleton method to calculate interpolation coefficient with accuracy to the fifth digit
70 71 72 73 74 75 76 |
# File 'lib/math/interpolation.rb', line 70 def self.calculate_interpolation_factor(data_point0, data_point1, x, y) coordinate = DataPoint.new(x, y) ( (coordinate.coordinate - data_point0.coordinate). dot(data_point1.coordinate - data_point0.coordinate) / (data_point1.coordinate - data_point0.coordinate).magnitude**2). round(5) end |
.interpolate_for_coordinate(meta_data, coordinates, data_set) ⇒ Float
interpolates the data for the provided coordinate and prints the result
26 27 28 29 30 31 32 33 |
# File 'lib/math/interpolation.rb', line 26 def self.interpolate_for_coordinate(, coordinates, data_set) x_coordinate = coordinates[:x] y_coordinate = coordinates[:y] BilinearInterpolation.bilinear_interpolation(, data_set, x_coordinate, y_coordinate) end |
.linear_interpolation_for_coordinate(data_point0, data_point1, x, y) ⇒ Float
singleton method for linear interpolation between two points
41 42 43 |
# File 'lib/math/interpolation.rb', line 41 def self.linear_interpolation_for_coordinate(data_point0, data_point1, x, y) LinearInterpolation.linear_interpolation(data_point0, data_point1, x, y) end |
.region_interpolation(meta_data, data_set, coordinates, values) ⇒ Object
singleton method to interpolate the data values specified for the region defined by the coordinates and the interval and delta values
53 54 55 56 57 58 |
# File 'lib/math/interpolation.rb', line 53 def self.region_interpolation(, data_set, coordinates, values) ri = RegionInterpolation.new(values[:inter_x], values[:delta_x], values[:inter_y], values[:delta_y]) ri.interpolate_region(coordinates[:x], coordinates[:y], , data_set) end |