diff --git a/StructureHelperCommon/Models/Functions/Decorator/LimXDecorator.cs b/StructureHelperCommon/Models/Functions/Decorator/LimXDecorator.cs index ab6fac9..bbcde04 100644 --- a/StructureHelperCommon/Models/Functions/Decorator/LimXDecorator.cs +++ b/StructureHelperCommon/Models/Functions/Decorator/LimXDecorator.cs @@ -25,7 +25,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator } public override double GetByX(double xValue) { - if (xValue > leftBound && xValue < rightBound) + if (xValue >= leftBound && xValue <= rightBound) { return base.GetByX(xValue); } diff --git a/StructureHelperCommon/Models/Functions/Decorator/LimYDecorator.cs b/StructureHelperCommon/Models/Functions/Decorator/LimYDecorator.cs index 70d86de..6b29fd6 100644 --- a/StructureHelperCommon/Models/Functions/Decorator/LimYDecorator.cs +++ b/StructureHelperCommon/Models/Functions/Decorator/LimYDecorator.cs @@ -52,6 +52,14 @@ namespace StructureHelperCommon.Models.Functions.Decorator { 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); graphSettings.GraphPoints = graphLimitGraphPoint; diff --git a/StructureHelperCommon/Models/Functions/GraphPoint.cs b/StructureHelperCommon/Models/Functions/GraphPoint.cs index 35073d0..92873fb 100644 --- a/StructureHelperCommon/Models/Functions/GraphPoint.cs +++ b/StructureHelperCommon/Models/Functions/GraphPoint.cs @@ -8,7 +8,7 @@ namespace StructureHelperCommon.Models.Functions { public class GraphPoint : ICloneable { - public bool Exclude { get; set; } + public bool Visible { get; set; } public double X { get; set; } public double Y { get; set; } @@ -16,7 +16,7 @@ namespace StructureHelperCommon.Models.Functions { X = x; Y = y; - Exclude = false; + Visible = true; } public object Clone() { diff --git a/StructureHelperCommon/Models/Functions/TableFunction.cs b/StructureHelperCommon/Models/Functions/TableFunction.cs index c3a619b..e11dee6 100644 --- a/StructureHelperCommon/Models/Functions/TableFunction.cs +++ b/StructureHelperCommon/Models/Functions/TableFunction.cs @@ -82,17 +82,16 @@ namespace StructureHelperCommon.Models.Functions { 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) { return rightBound.Y; } + else + { + return MathUtils.Interpolation(xValue, leftBound.X, rightBound.X, leftBound.Y, rightBound.Y); + } } return 0; - //Можно добавить экстраполяцию } public GraphSettings GetGraphSettings() { diff --git a/StructureHelperTests/UnitTests/Interpolation/InterpolationTest.cs b/StructureHelperTests/UnitTests/Interpolation/InterpolationTest.cs index 97311da..fc70753 100644 --- a/StructureHelperTests/UnitTests/Interpolation/InterpolationTest.cs +++ b/StructureHelperTests/UnitTests/Interpolation/InterpolationTest.cs @@ -9,7 +9,8 @@ namespace StructureHelperTests.UnitTests.Interpolation { 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) { //Arrange