Files
Иван Ивашкин bcea9639f6 Interpolation with test done
2024-10-31 17:35:31 +05:00

22 lines
518 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Services
{
public static class MathUtils
{
public static double Interpolation(double x, double x1, double x2, double y1, double y2)
{
if (Math.Abs(x2 - x1) < 10E-3)
{
return (y1 + y2) / 2;
}
var y = (y2 - y1) * (x - x1) / (x2 - x1) + y1;
return y;
}
}
}