Linear Grid Surface Class
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
public sealed class LinearGridSurface : GridSurface- Inheritance
- Object → Surface → GridSurface → LinearGridSurface
Remarks
This surface performs multi-linear interpolation within each grid cell. For 2D grids this is bilinear interpolation, for 3D it is trilinear, and for N-D it generalizes to 2N corner interpolation using weighted averaging of cell vertices.
Characteristics:
- Continuity: C0 (continuous everywhere)
- Smoothness: First derivatives are discontinuous at cell boundaries
- Performance: Fast evaluation, O(2D) operations per query where D is dimension
- Gradient: Piecewise constant within each cell, discontinuous at boundaries
When to use:
- General-purpose interpolation: Best default choice for most continuous data. Provides good balance between smoothness, accuracy, and computational cost.
- Real-time applications: When smooth interpolation is needed but cubic methods are too expensive (e.g., game graphics, interactive visualization).
- Large datasets: For high-dimensional or large grids where cubic methods would require excessive memory or computation time.
- Non-smooth data: When the underlying function has discontinuities or sharp features that cubic methods might overshoot (ringing artifacts).
Alternatives:
- NearestGridSurface: Use for categorical data or when maximum speed is required and continuity is not necessary.
- CubicGridSurface2D or CubicGridSurface3D: Use for 2D/3D data when C2 smoothness is required (smooth first and second derivatives). Provides better visual quality and derivative accuracy at higher computational cost.
- TensorSplineGridSurface: Use for N-dimensional smooth interpolation with C1 continuity. Better than linear for smooth functions but more expensive than specialized 2D/3D cubic methods.
Applications:
- Image and texture resampling (bilinear filtering)
- 3D volume rendering and medical imaging
- Physical simulation lookup tables (temperature, pressure fields)
- Geographic data interpolation (elevation, climate data)
- Computer graphics and real-time rendering
- N-dimensional parameter space exploration in optimization
Technical notes:
Multi-linear interpolation linearly interpolates along each dimension in sequence. For a 2D cell with corners (f₀₀, f₀₁, f₁₀, f₁₁) at normalized coordinates (s, t) ∈ [0,1]², the interpolated value is:
f(s,t) = (1-s)(1-t)f₀₀ + s(1-t)f₁₀ + (1-s)t f₀₁ + st f₁₁
This generalizes naturally to higher dimensions using tensor products of 1D linear interpolants.
Creating instances: Use GridLinearInterpolator(IReadOnlyList<IReadOnlyList<Double>>, IReadOnlyList<Double>, ExtrapolationMode) factory methods to create instances of this class.
Properties
| Dimension |
Gets the number of dimensions of the input space.
(Inherited from Surface) |
| Values |
Gets a read-only span containing the values of at the data points.
(Inherited from GridSurface) |
Methods
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
| Evaluate(Double[]) |
Evaluates the surface at the specified point.
(Inherited from Surface) |
| Evaluate( |
Evaluates the surface at the specified point.
(Inherited from Surface) |
| Evaluate( |
Evaluates the surface at the specified point.
(Inherited from GridSurface) |
| Evaluate( |
Evaluates the surface at multiple points specified by a list of vectors.
(Inherited from Surface) |
| Evaluate( |
Evaluates the surface at the specified point.
(Inherited from GridSurface) |
| Evaluate( |
Evaluates the surface at multiple points specified by a read-only span of vectors.
(Inherited from Surface) |
| Evaluate( |
Evaluates the surface at multiple points stored in column-major layout.
(Inherited from Surface) |
| Get | Serves as the default hash function. (Inherited from Object) |
| Get | Gets the Type of the current instance. (Inherited from Object) |
| Gradient( |
Computes the gradient of the surface at the specified point.
(Inherited from Surface) |
| Gradient( |
Computes the gradient of a 2D surface at the specified point.
(Inherited from Surface) |
| Gradient( |
Computes the gradient of the scalar field at the specified point.
(Inherited from GridSurface) |
| Gradient( |
Computes the gradient of the surface at the specified point.
(Inherited from Surface) |
| Gradient( | (Inherited from GridSurface) |
| Gradients( |
Computes the gradients of the surface at multiple points.
(Inherited from Surface) |
| Gradients( |
Computes the gradients of the surface at multiple points.
(Inherited from Surface) |
| Hessian |
Computes the Hessian matrix of the surface at the specified point.
(Inherited from Surface) |
| ToString | Returns a string that represents the current object. (Inherited from Object) |