Function bounds done, add other decorators

This commit is contained in:
Иван Ивашкин
2024-10-30 22:49:43 +05:00
parent 49d04c7bcc
commit 94387d0d0b
16 changed files with 223 additions and 35 deletions

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using LiveCharts;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -13,6 +14,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator
private double rightBound;
public LimXDecorator(IOneVariableFunction function, double leftBound, double rightBound) : base(function)
{
Name = $"x\u2208[{leftBound};{rightBound}]";
this.leftBound = leftBound;
this.rightBound = rightBound;
}
@@ -28,5 +30,9 @@ namespace StructureHelperCommon.Models.Functions.Decorator
}
return 0;
}
public override SeriesCollection GetSeriesCollection()
{
return base.GetSeriesCollection();
}
}
}

View File

@@ -0,0 +1,39 @@
using LiveCharts;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Functions.Decorator
{
public class LimYDecorator : FunctionDecorator
{
private double leftBound;
private double rightBound;
public LimYDecorator(IOneVariableFunction function, double leftBound, double rightBound) : base(function)
{
Name = $"y\u2208[{leftBound};{rightBound}]";
this.leftBound = leftBound;
this.rightBound = rightBound;
}
public override bool Check()
{
return base.Check();
}
public override double GetByX(double xValue)
{
var y = base.GetByX(xValue);
if (y > leftBound && y < rightBound)
{
return y;
}
return 0;
}
public override SeriesCollection GetSeriesCollection()
{
return base.GetSeriesCollection();
}
}
}

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using LiveCharts;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -13,7 +14,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator
public ScaleXDecorator(IOneVariableFunction function, double factor) : base(function)
{
this.factor = factor;
Name = $"{function.Name}, y=f({factor}x)";
Name = $"y=f({factor}x)";
}
public override bool Check()
{
@@ -23,5 +24,9 @@ namespace StructureHelperCommon.Models.Functions.Decorator
{
return base.GetByX(factor * xValue);
}
public override SeriesCollection GetSeriesCollection()
{
return base.GetSeriesCollection();
}
}
}

View File

@@ -0,0 +1,32 @@
using LiveCharts;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Functions.Decorator
{
public class ScaleYDecorator : FunctionDecorator
{
private double factor;
public ScaleYDecorator(IOneVariableFunction function, double factor) : base(function)
{
this.factor = factor;
Name = $"y={factor}f(x)";
}
public override bool Check()
{
return base.Check();
}
public override double GetByX(double xValue)
{
return factor * base.GetByX(xValue);
}
public override SeriesCollection GetSeriesCollection()
{
return base.GetSeriesCollection();
}
}
}