Add new strrrups DTOs

This commit is contained in:
RedikultsevEvg
2025-07-17 00:06:26 +05:00
parent 0addeda339
commit efb0fa6e1e
13 changed files with 237 additions and 17 deletions

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Services
{
public interface IInterpolateValueLogic
{
double X1 { get; set; }
double Y1 { get; set; }
double X2 { get; set; }
double Y2 { get; set; }
double KnownValueX { get; set; }
double GetValueY();
}
}

View File

@@ -0,0 +1,34 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Services
{
public class InterpolateValueLogic : IInterpolateValueLogic
{
public double X1 { get; set; }
public double Y1 { get; set; }
public double X2 { get; set; }
public double Y2 { get; set; }
public double KnownValueX { get; set; }
public double GetValueY()
{
Check();
double tangent = (Y2-Y1) / (X2-X1);
double value = Y1 + (tangent * (KnownValueX - X1));
return value;
}
private void Check()
{
if (X1 == X2)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Value X1 = {X1} must be inequal to value X2, but it was");
}
}
}
}