diff --git a/.gitignore b/.gitignore index 9b828e4..9b96ea0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vs/ +.github/ Base/obj/ Base/bin/ diff --git a/Base/Base.csproj b/Base/Base.csproj index 63d9cae..2301302 100644 --- a/Base/Base.csproj +++ b/Base/Base.csproj @@ -12,18 +12,18 @@ True ThatOneNerd.Graphing ThatOneNerd.Graphing - 1.1.0 + 1.2.0 That_One_Nerd A fairly adept graphing calculator made in Windows Forms. MIT https://github.com/That-One-Nerd/Graphing README.md - graphing;graph;plot;math;calculus;visual;desmos + graphing;graph;plot;math;calculus;visual;desmos;slope field;slopefield;equation;visualizer MIT True snupkg View the GitHub release for the changelog: -https://github.com/That-One-Nerd/Graphing/releases/tag/1.1.0 +https://github.com/That-One-Nerd/Graphing/releases/tag/1.2.0 diff --git a/Base/Forms/GraphColorPickerForm.Designer.cs b/Base/Forms/GraphColorPickerForm.Designer.cs index 8b708a4..4bca829 100644 --- a/Base/Forms/GraphColorPickerForm.Designer.cs +++ b/Base/Forms/GraphColorPickerForm.Designer.cs @@ -43,7 +43,7 @@ namespace Graphing.Forms ResultView = new Panel(); BottomPanel = new Panel(); OkButton = new Button(); - CancelButton = new Button(); + CancellingButton = new Button(); RgbSliders.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)BlueTrackBar).BeginInit(); ((System.ComponentModel.ISupportInitialize)RedTrackBar).BeginInit(); @@ -172,7 +172,7 @@ namespace Graphing.Forms // BottomPanel.BackColor = SystemColors.Window; BottomPanel.Controls.Add(OkButton); - BottomPanel.Controls.Add(CancelButton); + BottomPanel.Controls.Add(CancellingButton); BottomPanel.Dock = DockStyle.Bottom; BottomPanel.Location = new Point(0, 517); BottomPanel.Margin = new Padding(0); @@ -194,15 +194,15 @@ namespace Graphing.Forms // // CancelButton // - CancelButton.Anchor = AnchorStyles.Right; - CancelButton.Location = new Point(384, 9); - CancelButton.Margin = new Padding(0); - CancelButton.Name = "CancelButton"; - CancelButton.Size = new Size(150, 46); - CancelButton.TabIndex = 0; - CancelButton.Text = "Cancel"; - CancelButton.UseVisualStyleBackColor = true; - CancelButton.Click += CancelButton_Click; + CancellingButton.Anchor = AnchorStyles.Right; + CancellingButton.Location = new Point(384, 9); + CancellingButton.Margin = new Padding(0); + CancellingButton.Name = "CancelButton"; + CancellingButton.Size = new Size(150, 46); + CancellingButton.TabIndex = 0; + CancellingButton.Text = "Cancel"; + CancellingButton.UseVisualStyleBackColor = true; + CancellingButton.Click += CancelButton_Click; // // GraphColorPickerForm // @@ -237,7 +237,7 @@ namespace Graphing.Forms private TrackBar BlueTrackBar; private TrackBar RedTrackBar; private Panel BottomPanel; - private Button CancelButton; + private Button CancellingButton; private Button OkButton; private TextBox RedValueBox; private TextBox BlueValueBox; diff --git a/Base/Graphables/IntegralEquation.cs b/Base/Graphables/IntegralEquation.cs index 5abd5a4..51742fd 100644 --- a/Base/Graphables/IntegralEquation.cs +++ b/Base/Graphables/IntegralEquation.cs @@ -63,7 +63,7 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable // Origin is off the left side of the screen. // Get to the left side from the origin. double start = graph.MinVisibleGraph.x, end = graph.MaxVisibleGraph.x; - SetInternalStepper(start, epsilon, null); + SetInternalStepper(start, epsilon); // Now we can start. double previousX = stepX; @@ -82,7 +82,7 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable // Origin is off the right side of the screen. // Get to the right side of the origin. double start = graph.MaxVisibleGraph.x, end = graph.MinVisibleGraph.x; - SetInternalStepper(start, epsilon, null); + SetInternalStepper(start, epsilon); // Now we can start. double previousX = stepX; @@ -103,7 +103,7 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable // Start with right. double start = 0, end = graph.MaxVisibleGraph.x; - SetInternalStepper(start, epsilon, null); + SetInternalStepper(start, epsilon); double previousX = stepX; double previousY = stepY; @@ -119,7 +119,7 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable // Now do left. start = 0; end = graph.MinVisibleGraph.x; - SetInternalStepper(start, epsilon, null); + SetInternalStepper(start, epsilon); previousX = stepX; previousY = stepY; @@ -139,27 +139,19 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable private double stepX = 0; private double stepY = 0; - private void SetInternalStepper(double x, double dX, Action? stepCallback) + private void SetInternalStepper(double x, double dX) { stepX = 0; stepY = 0; - if (usingAlt) altBaseEqu!.SetInternalStepper(0, dX, null); + if (usingAlt) altBaseEqu!.SetInternalStepper(0, dX); if (x > 0) { - while (stepX < x) - { - MoveInternalStepper(dX); - stepCallback?.Invoke(stepX, stepY); - } + while (stepX < x) MoveInternalStepper(dX); } else if (x < 0) { - while (x < stepX) - { - MoveInternalStepper(-dX); - stepCallback?.Invoke(stepX, stepY); - } + while (x < stepX) MoveInternalStepper(-dX); } } private void MoveInternalStepper(double dX) @@ -195,16 +187,37 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable // Inefficient for successive calls. public double IntegralAtPoint(double x) { - EquationDelegate equ = baseEqu.GetDelegate(); + if (x > 0) + { + double start = Math.Min(0, x), end = Math.Max(0, x); + const double step = 1e-3; + double sum = 0; - double start = Math.Min(0, x), end = Math.Max(0, x); - const double step = 1e-3; - double sum = 0; + SetInternalStepper(start, step); + for (double t = start; t <= end; t += step) + { + MoveInternalStepper(step); + sum += stepY * step; + } - for (double t = start; t <= end; t += step) sum += equ(t) * step; - if (x < 0) sum = -sum; + return sum; + } + else if (x < 0) + { + double start = Math.Max(0, x), end = Math.Min(0, x); + const double step = 1e-3; + double sum = 0; - return sum; + SetInternalStepper(start, step); + for (double t = start; t >= end; t -= step) + { + MoveInternalStepper(-step); + sum -= stepY * step; + } + + return sum; + } + else return 0; } public override bool ShouldSelectGraphable(in GraphForm graph, Float2 graphMousePos, double factor) diff --git a/Base/Properties/PublishProfiles/FolderProfile.pubxml.user b/Base/Properties/PublishProfiles/FolderProfile.pubxml.user index 083b367..706348e 100644 --- a/Base/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/Base/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2024-03-13T14:31:43.4569441Z;False|2024-03-13T10:30:01.4347009-04:00;False|2024-03-13T10:27:31.9554551-04:00; + True|2024-03-20T12:39:01.6402921Z;True|2024-03-13T10:31:43.4569441-04:00;False|2024-03-13T10:30:01.4347009-04:00;False|2024-03-13T10:27:31.9554551-04:00; \ No newline at end of file diff --git a/README.md b/README.md index 8ba0c76..ac7ed2b 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ This is a graphing calculator I made initially for a Calculus project in a day o Currently, it doesn't have a whole lot of features, but I'll be adding more in the future. Here's currently what it can do: - Graph an equation (duh). - There are currently some rendering issues with asymptotes which will be focused on at some point. +- Integrate and derive equations. - Graph a slope field of a `dy/dx =` style equation. - View a tangent line of an equation. - Display a vertical bar graph. @@ -74,7 +75,7 @@ An equation requires a delegate such as the one you see. Alternatively, you can graph.Graph(new Equation(x => Math.Pow(2, x)) { Color = Color.Green, - Name = "2^x" + Name = "Exponential Base 2" }); ``` diff --git a/Testing/Program.cs b/Testing/Program.cs index e70142d..851e7f8 100644 --- a/Testing/Program.cs +++ b/Testing/Program.cs @@ -21,14 +21,10 @@ internal static class Program TangentLine tl = new(2, 2, equ); graph.Graph(equ, sf, tl); - // You can preload graphs in by going Misc > Preload Cache. - // Keep in mind this uses more memory than usual and can take - // some time. - - // Integrating equations is now much smoother and less intensive. - // Try it out! - - // You can click and drag on an equation to select specific points. + // Now, when integrating equations, the result is much less jagged + // and much faster. Try it out! You can also select points along + // equations and such as well. Click on an equation to see for + // yourself! Application.Run(graph); }