diff options
| author | a1xd <[email protected]> | 2020-07-24 20:54:41 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-07-24 20:54:41 -0400 |
| commit | 73c18530cccfd237ebda99308e283fc12e4485aa (patch) | |
| tree | 0bbaef80f43937c59134e247702e4c7ba2ed773a /grapher/Form1.cs | |
| parent | Merge pull request #4 from a1xd/vec-parse-fix (diff) | |
| parent | Add correct names and labels (diff) | |
| download | rawaccel-73c18530cccfd237ebda99308e283fc12e4485aa.tar.xz rawaccel-73c18530cccfd237ebda99308e283fc12e4485aa.zip | |
Merge pull request #5 from JacobPalecki/WrapperAndGrapher
Wrapper and grapher
Diffstat (limited to 'grapher/Form1.cs')
| -rw-r--r-- | grapher/Form1.cs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/grapher/Form1.cs b/grapher/Form1.cs new file mode 100644 index 0000000..1915b01 --- /dev/null +++ b/grapher/Form1.cs @@ -0,0 +1,64 @@ +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 RawAcceleration : Form + { + public RawAcceleration() + { + InitializeComponent(); + var managedAccel = new ManagedAccel(6, 0, 1, 0.025, 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.AccelerationChart.Series.FirstOrDefault(); + series.Points.Clear(); + + foreach (var point in orderedPoints) + { + series.Points.AddXY(point.Key, point.Value); + } + + this.AccelerationChart.ChartAreas[0].AxisX.RoundAxisValues(); + } + + 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); + } + + private void Form1_Load(object sender, EventArgs e) + { + + } + } +} |