Slope field works with decimals now.
This commit is contained in:
parent
ed4ce2bbeb
commit
ea9d2cd3b6
16
Base/Forms/GraphForm.Designer.cs
generated
16
Base/Forms/GraphForm.Designer.cs
generated
@ -72,7 +72,7 @@ namespace Graphing.Forms
|
||||
GraphMenu.Items.AddRange(new ToolStripItem[] { MenuViewport, MenuElements, MenuOperations, MenuConvert, MenuMisc });
|
||||
GraphMenu.Location = new Point(0, 0);
|
||||
GraphMenu.Name = "GraphMenu";
|
||||
GraphMenu.Size = new Size(1449, 40);
|
||||
GraphMenu.Size = new Size(1449, 42);
|
||||
GraphMenu.TabIndex = 1;
|
||||
GraphMenu.Text = "menuStrip1";
|
||||
//
|
||||
@ -80,7 +80,7 @@ namespace Graphing.Forms
|
||||
//
|
||||
MenuViewport.DropDownItems.AddRange(new ToolStripItem[] { ButtonViewportSetZoom, ButtonViewportSetCenter, ButtonViewportReset, ButtonViewportResetWindow });
|
||||
MenuViewport.Name = "MenuViewport";
|
||||
MenuViewport.Size = new Size(129, 36);
|
||||
MenuViewport.Size = new Size(129, 38);
|
||||
MenuViewport.Text = "Viewport";
|
||||
//
|
||||
// ButtonViewportSetZoom
|
||||
@ -115,7 +115,7 @@ namespace Graphing.Forms
|
||||
//
|
||||
MenuElements.DropDownItems.AddRange(new ToolStripItem[] { MenuElementsColors, MenuElementsRemove });
|
||||
MenuElements.Name = "MenuElements";
|
||||
MenuElements.Size = new Size(131, 36);
|
||||
MenuElements.Size = new Size(131, 38);
|
||||
MenuElements.Text = "Elements";
|
||||
//
|
||||
// MenuElementsColors
|
||||
@ -134,7 +134,7 @@ namespace Graphing.Forms
|
||||
//
|
||||
MenuOperations.DropDownItems.AddRange(new ToolStripItem[] { MenuOperationsDerivative, MenuOperationsIntegral, MenuOperationsTranslate });
|
||||
MenuOperations.Name = "MenuOperations";
|
||||
MenuOperations.Size = new Size(151, 36);
|
||||
MenuOperations.Size = new Size(151, 38);
|
||||
MenuOperations.Text = "Operations";
|
||||
//
|
||||
// MenuOperationsDerivative
|
||||
@ -159,26 +159,26 @@ namespace Graphing.Forms
|
||||
//
|
||||
MenuConvert.DropDownItems.AddRange(new ToolStripItem[] { MenuConvertEquation, MenuConvertSlopeField });
|
||||
MenuConvert.Name = "MenuConvert";
|
||||
MenuConvert.Size = new Size(118, 36);
|
||||
MenuConvert.Size = new Size(118, 38);
|
||||
MenuConvert.Text = "Convert";
|
||||
//
|
||||
// MenuConvertEquation
|
||||
//
|
||||
MenuConvertEquation.Name = "MenuConvertEquation";
|
||||
MenuConvertEquation.Size = new Size(297, 44);
|
||||
MenuConvertEquation.Size = new Size(359, 44);
|
||||
MenuConvertEquation.Text = "To Equation";
|
||||
//
|
||||
// MenuConvertSlopeField
|
||||
//
|
||||
MenuConvertSlopeField.Name = "MenuConvertSlopeField";
|
||||
MenuConvertSlopeField.Size = new Size(297, 44);
|
||||
MenuConvertSlopeField.Size = new Size(359, 44);
|
||||
MenuConvertSlopeField.Text = "To Slope Field";
|
||||
//
|
||||
// MenuMisc
|
||||
//
|
||||
MenuMisc.DropDownItems.AddRange(new ToolStripItem[] { MenuMiscCaches, MiscMenuPreload });
|
||||
MenuMisc.Name = "MenuMisc";
|
||||
MenuMisc.Size = new Size(83, 36);
|
||||
MenuMisc.Size = new Size(83, 38);
|
||||
MenuMisc.Text = "Misc";
|
||||
//
|
||||
// MenuMiscCaches
|
||||
|
||||
@ -11,11 +11,11 @@ public class SlopeField : Graphable
|
||||
private static int slopeFieldNum;
|
||||
|
||||
protected readonly SlopeFieldsDelegate equ;
|
||||
protected readonly int detail;
|
||||
protected readonly double detail;
|
||||
|
||||
protected readonly List<(Float2, GraphLine)> cache;
|
||||
|
||||
public SlopeField(int detail, SlopeFieldsDelegate equ)
|
||||
public SlopeField(double detail, SlopeFieldsDelegate equ)
|
||||
{
|
||||
slopeFieldNum++;
|
||||
Name = $"Slope Field {slopeFieldNum}";
|
||||
@ -27,12 +27,18 @@ public class SlopeField : Graphable
|
||||
|
||||
public override IEnumerable<IGraphPart> GetItemsToRender(in GraphForm graph)
|
||||
{
|
||||
double epsilon = 1 / (detail * 2.0);
|
||||
double step = 1 / detail;
|
||||
double epsilon = step * 0.5;
|
||||
List<IGraphPart> lines = [];
|
||||
|
||||
for (double x = Math.Ceiling(graph.MinVisibleGraph.x - 1); x < graph.MaxVisibleGraph.x + 1; x += 1.0 / detail)
|
||||
double minX = Math.Round((graph.MinVisibleGraph.x - 1) / step) * step,
|
||||
maxX = Math.Round((graph.MaxVisibleGraph.x + 1) / step) * step,
|
||||
minY = Math.Round((graph.MinVisibleGraph.y - 1) / step) * step,
|
||||
maxY = Math.Round((graph.MaxVisibleGraph.y + 1) / step) * step;
|
||||
|
||||
for (double x = minX; x < maxX; x += step)
|
||||
{
|
||||
for (double y = Math.Ceiling(graph.MinVisibleGraph.y - 1); y < graph.MaxVisibleGraph.y + 1; y += 1.0 / detail)
|
||||
for (double y = minY; y < maxY; y += step)
|
||||
{
|
||||
lines.Add(GetFromCache(epsilon, x, y));
|
||||
}
|
||||
|
||||
@ -16,12 +16,15 @@ internal static class Program
|
||||
|
||||
GraphForm graph = new("One Of The Graphing Calculators Of All Time");
|
||||
|
||||
Equation equA = new(Math.Sin),
|
||||
/*Equation equA = new(Math.Sin),
|
||||
equB = new(Math.Cos);
|
||||
EquationDifference diff = new(2, equA, equB);
|
||||
ParametricEquation equC = new(0, 20, t => 0.0375 * t * Math.Cos(t), t => 0.0625 * t * Math.Sin(t) + 3);
|
||||
TangentLine tanA = new(2, 2, equA);
|
||||
graph.Graph(equA, equB, diff, equC, equB.ToColumnTable(-3, 3, 2), tanA);
|
||||
graph.Graph(equA, equB, diff, equC, equB.ToColumnTable(-3, 3, 2), tanA);*/
|
||||
|
||||
SlopeField sf1 = new(1.5, (x, y) => Math.Cos(x) + Math.Sin(y));
|
||||
graph.Graph(sf1);
|
||||
|
||||
Application.Run(graph);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user