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();
}
}
}

View File

@@ -1,9 +1,11 @@
using Microsoft.VisualBasic.ApplicationServices;
using LiveCharts;
using Microsoft.VisualBasic.ApplicationServices;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Media;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -42,6 +44,7 @@ namespace StructureHelperCommon.Models.Functions
public double MinArg { get; set; }
public double MaxArg { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public Color Color { get; set; }
public FormulaFunction(bool isUser = false)
{
@@ -86,7 +89,7 @@ namespace StructureHelperCommon.Models.Functions
yValue = Math.Round(Math.Pow(xValue, 2), 2); //Временное тестовой выражение квадратичной параболы, будет разбор выражения
return yValue;
}
public List<GraphPoint> CalculateTable()
private List<GraphPoint> CalculateTable()
{
var table = new List<GraphPoint>();
var stepLenght = Math.Abs(MaxArg - MinArg) / Step;
@@ -97,5 +100,9 @@ namespace StructureHelperCommon.Models.Functions
}
return table;
}
public SeriesCollection GetSeriesCollection()
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,9 +1,11 @@
using StructureHelperCommon.Infrastructures.Enums;
using LiveCharts;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Media;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -30,6 +32,7 @@ namespace StructureHelperCommon.Models.Functions
public double MinArg { get; set; }
public double MaxArg { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public Color Color { get; set; }
public TableFunction(bool isUser = false)
{
@@ -71,7 +74,12 @@ namespace StructureHelperCommon.Models.Functions
{
//Реализовать взятие значения из таблицы и интерполяцию по таблице
return 100;
return 0;
}
public SeriesCollection GetSeriesCollection()
{
throw new NotImplementedException();
}
}
}