Add extrapolation, debug graphic limits

This commit is contained in:
Иван Ивашкин
2024-12-13 13:27:07 +05:00
parent 585eb9b86b
commit 7c9bc1856b
5 changed files with 17 additions and 9 deletions

View File

@@ -25,7 +25,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator
} }
public override double GetByX(double xValue) public override double GetByX(double xValue)
{ {
if (xValue > leftBound && xValue < rightBound) if (xValue >= leftBound && xValue <= rightBound)
{ {
return base.GetByX(xValue); return base.GetByX(xValue);
} }

View File

@@ -52,6 +52,14 @@ namespace StructureHelperCommon.Models.Functions.Decorator
{ {
graphLimitGraphPoint.Add(point); graphLimitGraphPoint.Add(point);
} }
else if (point.Y <= downBound)
{
graphLimitGraphPoint.Add(new GraphPoint(point.X, downBound));
}
else
{
graphLimitGraphPoint.Add(new GraphPoint(point.X, upBound));
}
} }
graphLimitGraphPoint.Add(upPoint); graphLimitGraphPoint.Add(upPoint);
graphSettings.GraphPoints = graphLimitGraphPoint; graphSettings.GraphPoints = graphLimitGraphPoint;

View File

@@ -8,7 +8,7 @@ namespace StructureHelperCommon.Models.Functions
{ {
public class GraphPoint : ICloneable public class GraphPoint : ICloneable
{ {
public bool Exclude { get; set; } public bool Visible { get; set; }
public double X { get; set; } public double X { get; set; }
public double Y { get; set; } public double Y { get; set; }
@@ -16,7 +16,7 @@ namespace StructureHelperCommon.Models.Functions
{ {
X = x; X = x;
Y = y; Y = y;
Exclude = false; Visible = true;
} }
public object Clone() public object Clone()
{ {

View File

@@ -82,17 +82,16 @@ namespace StructureHelperCommon.Models.Functions
{ {
return leftBound.Y; return leftBound.Y;
} }
else if (xValue > leftBound.X && xValue < rightBound.X)
{
return MathUtils.Interpolation(xValue, leftBound.X, rightBound.X, leftBound.Y, rightBound.Y);
}
else if (xValue == rightBound.X) else if (xValue == rightBound.X)
{ {
return rightBound.Y; return rightBound.Y;
} }
else
{
return MathUtils.Interpolation(xValue, leftBound.X, rightBound.X, leftBound.Y, rightBound.Y);
}
} }
return 0; return 0;
//Можно добавить экстраполяцию
} }
public GraphSettings GetGraphSettings() public GraphSettings GetGraphSettings()
{ {

View File

@@ -9,7 +9,8 @@ namespace StructureHelperTests.UnitTests.Interpolation
{ {
public class InterpolationTest public class InterpolationTest
{ {
[TestCase(1.5, 5.5, 1, 2, 5, 6)] [TestCase(1.5, 5.5, 1, 2, 5, 6)] //Interpolation
[TestCase(9, 4, 6, 8, 1, 3)] //Extrapolation
public void InterpolationTestMethod(double x, double y, double x1, double x2, double y1, double y2) public void InterpolationTestMethod(double x, double y, double x1, double x2, double y1, double y2)
{ {
//Arrange //Arrange