diff options
| author | Jacob Palecki <[email protected]> | 2021-01-18 17:39:10 -0800 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2021-01-18 17:39:10 -0800 |
| commit | 8c55ca08881b59943bc9dda193107cc8a117cf69 (patch) | |
| tree | 8c8ea7956a69c058d1829250a189b250b2659e7b /grapher/Models/Calculations/Data/AccelDataXYComponential.cs | |
| parent | Fix xy anisotropy combining in gui (diff) | |
| download | rawaccel-8c55ca08881b59943bc9dda193107cc8a117cf69.tar.xz rawaccel-8c55ca08881b59943bc9dda193107cc8a117cf69.zip | |
Refactor for new graph calculation method
Diffstat (limited to 'grapher/Models/Calculations/Data/AccelDataXYComponential.cs')
| -rw-r--r-- | grapher/Models/Calculations/Data/AccelDataXYComponential.cs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/grapher/Models/Calculations/Data/AccelDataXYComponential.cs b/grapher/Models/Calculations/Data/AccelDataXYComponential.cs new file mode 100644 index 0000000..6231eb3 --- /dev/null +++ b/grapher/Models/Calculations/Data/AccelDataXYComponential.cs @@ -0,0 +1,64 @@ +using grapher.Models.Charts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace grapher.Models.Calculations.Data +{ + public class AccelDataXYComponential : IAccelData + { + public AccelDataXYComponential( + EstimatedPoints xPoints, + EstimatedPoints yPoints, + AccelCalculator calculator) + { + X = new AccelChartData(); + Y = new AccelChartData(); + XPoints = xPoints; + YPoints = yPoints; + Calculator = calculator; + } + + public AccelChartData X { get; } + + public AccelChartData Y { get; } + + private EstimatedPoints XPoints { get; } + + private EstimatedPoints YPoints { get; } + + private AccelCalculator Calculator { get; } + + public void CalculateDots(double x, double y, double timeInMs) + { + var outX = Math.Abs(x) / timeInMs; + var outY = Math.Abs(y) / timeInMs; + + (var inXVelocity, var xSensitivity, var xGain) = X.FindPointValuesFromOut(outX); + XPoints.Velocity.Set(inXVelocity, outX); + XPoints.Sensitivity.Set(inXVelocity, xSensitivity); + XPoints.Gain.Set(inXVelocity, xGain); + + (var inYVelocity, var ySensitivity, var yGain) = Y.FindPointValuesFromOut(outY); + YPoints.Velocity.Set(inYVelocity, outY); + YPoints.Sensitivity.Set(inYVelocity, ySensitivity); + YPoints.Gain.Set(inYVelocity, yGain); + + } + + public void Clear() + { + X.Clear(); + Y.Clear(); + } + + public void CreateGraphData(ManagedAccel accel, DriverSettings settings) + { + Clear(); + Calculator.Calculate(X, accel, settings.sensitivity.x, Calculator.SimulatedInputX); + Calculator.Calculate(Y, accel, settings.sensitivity.y, Calculator.SimulatedInputY); + } + } +} |