diff options
| author | a1xd <[email protected]> | 2020-08-14 03:48:40 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-08-14 03:48:40 -0400 |
| commit | 0621a7ebd431102d720497a143190505dcfeb7a1 (patch) | |
| tree | 01d7df8f55e5a1cce90617fd876eaf994eb26846 /grapher/Models/Calculations/AccelData.cs | |
| parent | Merge pull request #14 from JacobPalecki/GainCap (diff) | |
| parent | Fix initial points, add poll time constant (diff) | |
| download | rawaccel-0621a7ebd431102d720497a143190505dcfeb7a1.tar.xz rawaccel-0621a7ebd431102d720497a143190505dcfeb7a1.zip | |
Merge pull request #15 from JacobPalecki/GUI
GUI: Add x/y graphs, moving dot
Diffstat (limited to 'grapher/Models/Calculations/AccelData.cs')
| -rw-r--r-- | grapher/Models/Calculations/AccelData.cs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/grapher/Models/Calculations/AccelData.cs b/grapher/Models/Calculations/AccelData.cs new file mode 100644 index 0000000..683c67e --- /dev/null +++ b/grapher/Models/Calculations/AccelData.cs @@ -0,0 +1,74 @@ +using grapher.Models.Charts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static grapher.AccelCharts; + +namespace grapher.Models.Calculations +{ + public class AccelData + { + + public AccelData( + EstimatedPoints combined, + EstimatedPoints x, + EstimatedPoints y) + { + Combined = new AccelChartData(); + X = new AccelChartData(); + Y = new AccelChartData(); + + Estimated = combined; + EstimatedX = x; + EstimatedY = y; + } + + public AccelChartData Combined { get; } + + public AccelChartData X { get; } + + public AccelChartData Y { get; } + + private EstimatedPoints Estimated { get; } + + private EstimatedPoints EstimatedX { get; } + + private EstimatedPoints EstimatedY { get; } + + public void Clear() + { + Combined.Clear(); + X.Clear(); + Y.Clear(); + } + + public void CalculateDots(int x, int y, double timeInMs) + { + var magnitude = AccelCalculator.Velocity(x, y, timeInMs); + + (var inCombVel, var combSens, var combGain) = Combined.FindPointValuesFromOut(magnitude); + Estimated.Velocity.Set(inCombVel, magnitude); + Estimated.Sensitivity.Set(inCombVel, combSens); + Estimated.Gain.Set(inCombVel, combGain); + } + + public void CalculateDotsXY(int x, int y, double timeInMs) + { + var outX = Math.Abs(x); + var outY = Math.Abs(y); + + (var inXVelocity, var xSensitivity, var xGain) = X.FindPointValuesFromOut(outX); + EstimatedX.Velocity.Set(inXVelocity, outX); + EstimatedX.Sensitivity.Set(inXVelocity, xSensitivity); + EstimatedX.Gain.Set(inXVelocity, xGain); + + (var inYVelocity, var ySensitivity, var yGain) = Y.FindPointValuesFromOut(outY); + EstimatedY.Velocity.Set(inYVelocity, outY); + EstimatedY.Sensitivity.Set(inYVelocity, ySensitivity); + EstimatedY.Gain.Set(inYVelocity, yGain); + } + + } +} |