LinearInterpolation.cs 594 B

1234567891011121314151617181920212223
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace XdCxRhDW.App
  7. {
  8. public class LinearInterpolation
  9. {
  10. public static double CalSigTimeDto(DateTime x, DateTime x0, DateTime x1, double y0, double y1)
  11. {
  12. // 线性插值公式: y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0))
  13. double y= y0 + (x - x0).TotalSeconds * ((y1 - y0) / (x1 - x0).TotalSeconds);
  14. if (y == double.NaN)
  15. {
  16. y = 0;
  17. }
  18. return y;
  19. }
  20. }
  21. }