summaryrefslogtreecommitdiff
path: root/grapher/Form1.cs
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-07-24 11:15:04 -0700
committerJacob Palecki <[email protected]>2020-07-24 11:15:04 -0700
commit02f5d86a891edb2f49851b400b0d2b2f8b4e4f98 (patch)
tree31494b77056e89388f6220f68927caa30c79ecf2 /grapher/Form1.cs
parentAdded simple c++/cli wrapper (diff)
downloadrawaccel-02f5d86a891edb2f49851b400b0d2b2f8b4e4f98.tar.xz
rawaccel-02f5d86a891edb2f49851b400b0d2b2f8b4e4f98.zip
Add a basic windows forms grapher
Diffstat (limited to 'grapher/Form1.cs')
-rw-r--r--grapher/Form1.cs57
1 files changed, 57 insertions, 0 deletions
diff --git a/grapher/Form1.cs b/grapher/Form1.cs
new file mode 100644
index 0000000..b51ebe5
--- /dev/null
+++ b/grapher/Form1.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ var managedAccel = new ManagedAccel(6, 0, 0.025, 1.01, 0);
+ var orderedPoints = new SortedDictionary<double, double>();
+
+ for (int i = 0; i < 100; i++)
+ {
+ for (int j = 0; j <= i; j++)
+ {
+ var output = managedAccel.Accelerate(i, j, 1, 6);
+
+ var inMagnitude = Magnitude(i,j);
+ var outMagnitude = Magnitude(output.Item1, output.Item2);
+ var ratio = inMagnitude > 0 ? outMagnitude / inMagnitude : 0;
+
+ if (!orderedPoints.ContainsKey(inMagnitude))
+ {
+ orderedPoints.Add(inMagnitude, ratio);
+ }
+ }
+ }
+
+ var series = this.chart1.Series.FirstOrDefault();
+ series.Points.Clear();
+
+ foreach (var point in orderedPoints)
+ {
+ series.Points.AddXY(point.Key, point.Value);
+ }
+ }
+
+ public static double Magnitude(int x, int y)
+ {
+ return Math.Sqrt(x * x + y * y);
+ }
+
+ public static double Magnitude(double x, double y)
+ {
+ return Math.Sqrt(x * x + y * y);
+ }
+ }
+}