using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DW5S.App { public class LinearInterpolation { public static double CalSigTimeDto(DateTime x, DateTime x0, DateTime x1, double y0, double y1) { // 线性插值公式: y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0)) if (x0 == x1) { return (y0 + y1) / 2; } double y = y0 + (x - x0).TotalSeconds * ((y1 - y0) / (x1 - x0).TotalSeconds); if (y == double.NaN) { y = 0; } return Math.Round(y, 3); } } }