From 7ff3720b7057585fc7612aef9b90026f43762a72 Mon Sep 17 00:00:00 2001 From: That_One_Nerd Date: Mon, 18 Mar 2024 09:14:56 -0400 Subject: [PATCH] Made most of the methods in virtual. --- Base/Graphable.cs | 12 ++++++------ Base/Graphables/ColumnTable.cs | 1 - Base/Graphables/Equation.cs | 6 ++---- Base/Graphables/TangentLine.cs | 2 +- README.md | 4 ++++ Testing/Program.cs | 11 ++++++----- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Base/Graphable.cs b/Base/Graphable.cs index 0608f58..15cbc3e 100644 --- a/Base/Graphable.cs +++ b/Base/Graphable.cs @@ -7,12 +7,12 @@ public abstract class Graphable private static int defaultColorsUsed; public static readonly uint[] DefaultColors = [ - 0xEF_B34D47, // Red - 0xEF_4769B3, // Blue - 0xEF_50B347, // Green - 0xEF_7047B3, // Purple - 0xEF_B38B47, // Orange - 0xEF_5B5B5B // Black + 0xFF_B34D47, // Red + 0xFF_4769B3, // Blue + 0xFF_50B347, // Green + 0xFF_7047B3, // Purple + 0xFF_B38B47, // Orange + 0xFF_5B5B5B // Black ]; public Color Color { get; set; } diff --git a/Base/Graphables/ColumnTable.cs b/Base/Graphables/ColumnTable.cs index 673cd40..4038ca6 100644 --- a/Base/Graphables/ColumnTable.cs +++ b/Base/Graphables/ColumnTable.cs @@ -32,7 +32,6 @@ public class ColumnTable : Graphable tableXY.Add(x, equ(x)); } - public override void EraseCache() { } public override long GetCacheBytes() => 16 * tableXY.Count; public override Graphable DeepCopy() => new ColumnTable(width / 0.75, tableXY.ToArray().ToDictionary()); diff --git a/Base/Graphables/Equation.cs b/Base/Graphables/Equation.cs index 4828be2..a2cb3ef 100644 --- a/Base/Graphables/Equation.cs +++ b/Base/Graphables/Equation.cs @@ -111,10 +111,8 @@ public class Equation : Graphable double totalDist = Math.Sqrt(dist.x * dist.x + dist.y * dist.y); return totalDist <= allowedDist; } - public override Float2 GetSelectedPoint(in GraphForm graph, Float2 graphMousePos) - { - return new(graphMousePos.x, GetFromCache(graphMousePos.x, 0.001)); - } + public override Float2 GetSelectedPoint(in GraphForm graph, Float2 graphMousePos) => + new(graphMousePos.x, GetFromCache(graphMousePos.x, 1e-3)); public override void Preload(Float2 xRange, Float2 yRange, double step) { diff --git a/Base/Graphables/TangentLine.cs b/Base/Graphables/TangentLine.cs index d66736e..549c881 100644 --- a/Base/Graphables/TangentLine.cs +++ b/Base/Graphables/TangentLine.cs @@ -14,7 +14,7 @@ public class TangentLine : Graphable _position = value; } } - private double _position; + private double _position; // Private because it has exactly the same functionality as `Position`. protected readonly Equation parent; protected readonly EquationDelegate parentEqu; diff --git a/README.md b/README.md index 7266efe..8ba0c76 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ Currently, it doesn't have a whole lot of features, but I'll be adding more in t - Graph an equation (duh). - There are currently some rendering issues with asymptotes which will be focused on at some point. - Graph a slope field of a `dy/dx =` style equation. +- View a tangent line of an equation. +- Display a vertical bar graph. + +However, you can develop your own features as well. The system does not and likely will not (at least for a while) support text-to-equation parsing. You must import this project as a library and add graphs that way. diff --git a/Testing/Program.cs b/Testing/Program.cs index 5be5d87..090be95 100644 --- a/Testing/Program.cs +++ b/Testing/Program.cs @@ -14,13 +14,14 @@ internal static class Program GraphForm graph = new("One Of The Graphing Calculators Of All Time"); - Equation possibleA = new(x => x * x * x); - SlopeField sf = new(2, (x, y) => 3 * x * x); - TangentLine tl = new(5, 2, possibleA); + Equation possibleA = new(x => Math.Sin(x)); + SlopeField sf = new(2, (x, y) => Math.Cos(x)); + TangentLine tl = new(2, 2, possibleA); graph.Graph(possibleA, sf, tl); - // You can also now view and reset caches in the UI by going to - // Misc > View Caches. + // You can preload graphs in by going Misc > Preload Cache. + // Keep in mind this uses more memory than usual and can take + // some time. Application.Run(graph); }