optionstratlib_math/geometrics/interpolation/types.rs
1/// Represents the different types of interpolation methods supported in the library.
2///
3/// This enum defines the available interpolation techniques that can be used in various
4/// mathematical modeling, data analysis, and visualization scenarios. Each interpolation
5/// method has unique characteristics making it suitable for different applications.
6///
7/// # Variants
8/// - **`Linear`**:
9/// Performs linear interpolation. This method calculates interpolated values
10/// by connecting two adjacent points on a line and using the slope between
11/// them to determine new values.
12///
13/// - **`Cubic`**:
14/// Utilizes cubic interpolation, which involves fitting a cubic polynomial
15/// between data points to provide a smoother curve. This is commonly used for
16/// precise curve fitting and smoothing applications.
17///
18/// - **`Spline`**:
19/// Implements spline interpolation, typically involving piecewise polynomials
20/// (e.g., cubic splines) that ensure smooth transitions between data points
21/// while maintaining continuity of derivatives at the joins. Spline methods
22/// are widely used in mathematical modeling and graphical applications.
23///
24/// - **`Bilinear`**:
25/// A two-dimensional extension of linear interpolation. Commonly used in grid-based
26/// data interpolation, bilinear interpolation calculates the value at a point within
27/// a cell of a 2D grid based on the values at the vertices of the cell.
28///
29/// # Usage
30/// This enumeration is typically used as part of a larger interpolation framework,
31/// providing a way to select the desired interpolation method. Each variant corresponds
32/// to a specific interpolation strategy, and implementations for these can be found in
33/// their respective modules (e.g., `linear`, `cubic`, `spline`, `bilinear`).
34///
35/// # Integration
36/// The `InterpolationType` enum is re-exported in the library's root module to make it
37/// easily accessible as part of the public API. It works in conjunction with traits such as
38/// `Interpolate`, allowing users to dynamically specify the desired interpolation type
39/// when performing operations.
40///
41/// # Example Use Case
42/// While the `InterpolationType` enum itself does not contain any methods or logic,
43/// it serves as a configuration point for choosing the interpolation method to be used
44/// in a context where multiple types of interpolation are supported.
45///
46/// # See Also
47/// - [`crate::geometrics::LinearInterpolation`]: Implements linear interpolation.
48/// - [`crate::geometrics::CubicInterpolation`]: Implements cubic interpolation.
49/// - [`crate::geometrics::SplineInterpolation`]: Implements spline interpolation.
50/// - [`crate::geometrics::BiLinearInterpolation`]: Implements bilinear interpolation.
51///
52/// This enum is part of a modular design, with each interpolation type defined in its own
53/// module for clarity and separation of concerns.
54///
55#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
56#[repr(u8)]
57pub enum InterpolationType {
58 /// Linear interpolation that calculates values by drawing straight lines between data points.
59 /// Efficient but may lack smoothness for certain applications.
60 Linear,
61
62 /// Cubic interpolation that uses third-degree polynomials to create smoother curves
63 /// between data points, providing better continuity than linear interpolation.
64 Cubic,
65
66 /// Spline interpolation that ensures smooth curves with continuous first and second
67 /// derivatives at the connection points between interpolation segments.
68 Spline,
69
70 /// Bilinear interpolation for two-dimensional data, performing linear interpolation
71 /// first in one direction and then in the other, used commonly in image processing
72 /// and spatial data analysis.
73 Bilinear,
74}