linear_weight

Function linear_weight 

Source
pub fn linear_weight(x1: f64, x2: f64, x: f64) -> f64
Expand description

Calculates the interpolation weight between x1 and x2 for a value x.

The returned weight w satisfies y = (1 - w) * y1 + w * y2 when interpolating ordinates that correspond to abscissas x1 and x2.

ยงPanics

Panics if x1 and x2 are too close (within machine epsilon), which would cause division by zero or numerical instability. Uses f64::EPSILON * 2.0 to account for floating-point rounding in the difference computation.