From 9a82432c2cb0eb589552221ab982d9caaae65b55 Mon Sep 17 00:00:00 2001 From: Chomp Date: Fri, 20 Jun 2025 14:15:28 +0100 Subject: [PATCH] Updated `Interp1` to accept readonly lists as params + added comments --- Libraries/SPTarkov.Server.Core/Utils/MathUtil.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/SPTarkov.Server.Core/Utils/MathUtil.cs b/Libraries/SPTarkov.Server.Core/Utils/MathUtil.cs index 0772ef2d..65e00c64 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/MathUtil.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/MathUtil.cs @@ -98,15 +98,17 @@ public class MathUtil /// Support points in x (of same length as y) /// Support points in y (of same length as x) /// Interpolated value at xp, or null if xp is out of bounds - public double? Interp1(double xp, List x, List y) + public double? Interp1(double xp, IReadOnlyList x, IReadOnlyList y) { if (xp > x[^1]) // ^1 is the last index in C# { + // Value is above max provided value in x array, Clamp result to last value return y[^1]; } if (xp < x[0]) { + // Value is below min provided value in x array, Clamp result to first value return y[0]; }