Add new strrrups DTOs
This commit is contained in:
18
StructureHelperCommon/Services/IInterpolateValueLogic.cs
Normal file
18
StructureHelperCommon/Services/IInterpolateValueLogic.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
34
StructureHelperCommon/Services/InterpolateValueLogic.cs
Normal file
34
StructureHelperCommon/Services/InterpolateValueLogic.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user