LinearGridSurface Class

Implements multi-linear interpolation on a rectilinear N-dimensional grid.

Definition

Namespace: Numerics.NET.Curves.Surfaces
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
C#
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

EqualsDetermines 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(IReadOnlyList<Double>) Evaluates the surface at the specified point.
(Inherited from Surface)
Evaluate(ReadOnlySpan<Double>) Evaluates the surface at the specified point.
(Inherited from GridSurface)
Evaluate(IReadOnlyList<Vector<Double>>, Span<Double>) Evaluates the surface at multiple points specified by a list of vectors.
(Inherited from Surface)
Evaluate(ReadOnlySpan<Double>, ExtrapolationMode) Evaluates the surface at the specified point.
(Inherited from GridSurface)
Evaluate(ReadOnlySpan<Vector<Double>>, Span<Double>) Evaluates the surface at multiple points specified by a read-only span of vectors.
(Inherited from Surface)
Evaluate(Int32, ReadOnlySpan2D<Double>, Span<Double>) Evaluates the surface at multiple points stored in column-major layout.
(Inherited from Surface)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
Gradient(Vector<Double>) Computes the gradient of the surface at the specified point.
(Inherited from Surface)
Gradient(Double, Double) Computes the gradient of a 2D surface at the specified point.
(Inherited from Surface)
Gradient(ReadOnlySpan<Double>, Span<Double>) Computes the gradient of the scalar field at the specified point.
(Inherited from GridSurface)
Gradient(Vector<Double>, Vector<Double>) Computes the gradient of the surface at the specified point.
(Inherited from Surface)
Gradient(ReadOnlySpan<Double>, ExtrapolationMode, Span<Double>)
(Inherited from GridSurface)
Gradients(Matrix<Double>) Computes the gradients of the surface at multiple points.
(Inherited from Surface)
Gradients(Matrix<Double>, Matrix<Double>) 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)
ToStringReturns a string that represents the current object.
(Inherited from Object)

See Also