About ready for 1.2.

This commit is contained in:
That_One_Nerd 2024-03-20 08:35:16 -04:00
parent 9b4905233c
commit f8c1788502
7 changed files with 59 additions and 48 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
.vs/ .vs/
.github/
Base/obj/ Base/obj/
Base/bin/ Base/bin/

View File

@ -12,18 +12,18 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageId>ThatOneNerd.Graphing</PackageId> <PackageId>ThatOneNerd.Graphing</PackageId>
<Title>ThatOneNerd.Graphing</Title> <Title>ThatOneNerd.Graphing</Title>
<Version>1.1.0</Version> <Version>1.2.0</Version>
<Authors>That_One_Nerd</Authors> <Authors>That_One_Nerd</Authors>
<Description>A fairly adept graphing calculator made in Windows Forms.</Description> <Description>A fairly adept graphing calculator made in Windows Forms.</Description>
<Copyright>MIT</Copyright> <Copyright>MIT</Copyright>
<RepositoryUrl>https://github.com/That-One-Nerd/Graphing</RepositoryUrl> <RepositoryUrl>https://github.com/That-One-Nerd/Graphing</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>graphing;graph;plot;math;calculus;visual;desmos</PackageTags> <PackageTags>graphing;graph;plot;math;calculus;visual;desmos;slope field;slopefield;equation;visualizer</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageLicenseExpression>MIT</PackageLicenseExpression>
<IncludeSymbols>True</IncludeSymbols> <IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat> <SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageReleaseNotes>View the GitHub release for the changelog: <PackageReleaseNotes>View the GitHub release for the changelog:
https://github.com/That-One-Nerd/Graphing/releases/tag/1.1.0</PackageReleaseNotes> https://github.com/That-One-Nerd/Graphing/releases/tag/1.2.0</PackageReleaseNotes>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@ -43,7 +43,7 @@ namespace Graphing.Forms
ResultView = new Panel(); ResultView = new Panel();
BottomPanel = new Panel(); BottomPanel = new Panel();
OkButton = new Button(); OkButton = new Button();
CancelButton = new Button(); CancellingButton = new Button();
RgbSliders.SuspendLayout(); RgbSliders.SuspendLayout();
((System.ComponentModel.ISupportInitialize)BlueTrackBar).BeginInit(); ((System.ComponentModel.ISupportInitialize)BlueTrackBar).BeginInit();
((System.ComponentModel.ISupportInitialize)RedTrackBar).BeginInit(); ((System.ComponentModel.ISupportInitialize)RedTrackBar).BeginInit();
@ -172,7 +172,7 @@ namespace Graphing.Forms
// //
BottomPanel.BackColor = SystemColors.Window; BottomPanel.BackColor = SystemColors.Window;
BottomPanel.Controls.Add(OkButton); BottomPanel.Controls.Add(OkButton);
BottomPanel.Controls.Add(CancelButton); BottomPanel.Controls.Add(CancellingButton);
BottomPanel.Dock = DockStyle.Bottom; BottomPanel.Dock = DockStyle.Bottom;
BottomPanel.Location = new Point(0, 517); BottomPanel.Location = new Point(0, 517);
BottomPanel.Margin = new Padding(0); BottomPanel.Margin = new Padding(0);
@ -194,15 +194,15 @@ namespace Graphing.Forms
// //
// CancelButton // CancelButton
// //
CancelButton.Anchor = AnchorStyles.Right; CancellingButton.Anchor = AnchorStyles.Right;
CancelButton.Location = new Point(384, 9); CancellingButton.Location = new Point(384, 9);
CancelButton.Margin = new Padding(0); CancellingButton.Margin = new Padding(0);
CancelButton.Name = "CancelButton"; CancellingButton.Name = "CancelButton";
CancelButton.Size = new Size(150, 46); CancellingButton.Size = new Size(150, 46);
CancelButton.TabIndex = 0; CancellingButton.TabIndex = 0;
CancelButton.Text = "Cancel"; CancellingButton.Text = "Cancel";
CancelButton.UseVisualStyleBackColor = true; CancellingButton.UseVisualStyleBackColor = true;
CancelButton.Click += CancelButton_Click; CancellingButton.Click += CancelButton_Click;
// //
// GraphColorPickerForm // GraphColorPickerForm
// //
@ -237,7 +237,7 @@ namespace Graphing.Forms
private TrackBar BlueTrackBar; private TrackBar BlueTrackBar;
private TrackBar RedTrackBar; private TrackBar RedTrackBar;
private Panel BottomPanel; private Panel BottomPanel;
private Button CancelButton; private Button CancellingButton;
private Button OkButton; private Button OkButton;
private TextBox RedValueBox; private TextBox RedValueBox;
private TextBox BlueValueBox; private TextBox BlueValueBox;

View File

@ -63,7 +63,7 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable
// Origin is off the left side of the screen. // Origin is off the left side of the screen.
// Get to the left side from the origin. // Get to the left side from the origin.
double start = graph.MinVisibleGraph.x, end = graph.MaxVisibleGraph.x; double start = graph.MinVisibleGraph.x, end = graph.MaxVisibleGraph.x;
SetInternalStepper(start, epsilon, null); SetInternalStepper(start, epsilon);
// Now we can start. // Now we can start.
double previousX = stepX; double previousX = stepX;
@ -82,7 +82,7 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable
// Origin is off the right side of the screen. // Origin is off the right side of the screen.
// Get to the right side of the origin. // Get to the right side of the origin.
double start = graph.MaxVisibleGraph.x, end = graph.MinVisibleGraph.x; double start = graph.MaxVisibleGraph.x, end = graph.MinVisibleGraph.x;
SetInternalStepper(start, epsilon, null); SetInternalStepper(start, epsilon);
// Now we can start. // Now we can start.
double previousX = stepX; double previousX = stepX;
@ -103,7 +103,7 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable
// Start with right. // Start with right.
double start = 0, end = graph.MaxVisibleGraph.x; double start = 0, end = graph.MaxVisibleGraph.x;
SetInternalStepper(start, epsilon, null); SetInternalStepper(start, epsilon);
double previousX = stepX; double previousX = stepX;
double previousY = stepY; double previousY = stepY;
@ -119,7 +119,7 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable
// Now do left. // Now do left.
start = 0; start = 0;
end = graph.MinVisibleGraph.x; end = graph.MinVisibleGraph.x;
SetInternalStepper(start, epsilon, null); SetInternalStepper(start, epsilon);
previousX = stepX; previousX = stepX;
previousY = stepY; previousY = stepY;
@ -139,27 +139,19 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable
private double stepX = 0; private double stepX = 0;
private double stepY = 0; private double stepY = 0;
private void SetInternalStepper(double x, double dX, Action<double, double>? stepCallback) private void SetInternalStepper(double x, double dX)
{ {
stepX = 0; stepX = 0;
stepY = 0; stepY = 0;
if (usingAlt) altBaseEqu!.SetInternalStepper(0, dX, null); if (usingAlt) altBaseEqu!.SetInternalStepper(0, dX);
if (x > 0) if (x > 0)
{ {
while (stepX < x) while (stepX < x) MoveInternalStepper(dX);
{
MoveInternalStepper(dX);
stepCallback?.Invoke(stepX, stepY);
}
} }
else if (x < 0) else if (x < 0)
{ {
while (x < stepX) while (x < stepX) MoveInternalStepper(-dX);
{
MoveInternalStepper(-dX);
stepCallback?.Invoke(stepX, stepY);
}
} }
} }
private void MoveInternalStepper(double dX) private void MoveInternalStepper(double dX)
@ -195,17 +187,38 @@ public class IntegralEquation : Graphable, IIntegrable, IDerivable
// Inefficient for successive calls. // Inefficient for successive calls.
public double IntegralAtPoint(double x) public double IntegralAtPoint(double x)
{ {
EquationDelegate equ = baseEqu.GetDelegate(); if (x > 0)
{
double start = Math.Min(0, x), end = Math.Max(0, x); double start = Math.Min(0, x), end = Math.Max(0, x);
const double step = 1e-3; const double step = 1e-3;
double sum = 0; double sum = 0;
for (double t = start; t <= end; t += step) sum += equ(t) * step; SetInternalStepper(start, step);
if (x < 0) sum = -sum; for (double t = start; t <= end; t += step)
{
MoveInternalStepper(step);
sum += stepY * step;
}
return 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;
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) public override bool ShouldSelectGraphable(in GraphForm graph, Float2 graphMousePos, double factor)
{ {

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
--> -->
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<History>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;</History> <History>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;</History>
<LastFailureDetails /> <LastFailureDetails />
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -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: 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). - Graph an equation (duh).
- There are currently some rendering issues with asymptotes which will be focused on at some point. - 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. - Graph a slope field of a `dy/dx =` style equation.
- View a tangent line of an equation. - View a tangent line of an equation.
- Display a vertical bar graph. - 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)) graph.Graph(new Equation(x => Math.Pow(2, x))
{ {
Color = Color.Green, Color = Color.Green,
Name = "2^x" Name = "Exponential Base 2"
}); });
``` ```

View File

@ -21,14 +21,10 @@ internal static class Program
TangentLine tl = new(2, 2, equ); TangentLine tl = new(2, 2, equ);
graph.Graph(equ, sf, tl); graph.Graph(equ, sf, tl);
// You can preload graphs in by going Misc > Preload Cache. // Now, when integrating equations, the result is much less jagged
// Keep in mind this uses more memory than usual and can take // and much faster. Try it out! You can also select points along
// some time. // equations and such as well. Click on an equation to see for
// yourself!
// Integrating equations is now much smoother and less intensive.
// Try it out!
// You can click and drag on an equation to select specific points.
Application.Run(graph); Application.Run(graph);
} }