diff options
| author | JacobPalecki <[email protected]> | 2020-09-22 19:59:47 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-22 19:59:47 -0700 |
| commit | 77f420cf45a1a0bee00602965e687097367e2a70 (patch) | |
| tree | fa088af8f2feb54df5bcb6a036715fd32d0511e8 /grapher/Models/Calculations/AccelCalculator.cs | |
| parent | Merge pull request #21 from JacobPalecki/GUI (diff) | |
| parent | Update credits (diff) | |
| download | rawaccel-77f420cf45a1a0bee00602965e687097367e2a70.tar.xz rawaccel-77f420cf45a1a0bee00602965e687097367e2a70.zip | |
Merge pull request #22 from JacobPalecki/GUI
Replace SigmoidGain with Motivity & Cleanup
Diffstat (limited to 'grapher/Models/Calculations/AccelCalculator.cs')
| -rw-r--r-- | grapher/Models/Calculations/AccelCalculator.cs | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs index a140c90..f2a6c7c 100644 --- a/grapher/Models/Calculations/AccelCalculator.cs +++ b/grapher/Models/Calculations/AccelCalculator.cs @@ -62,16 +62,47 @@ namespace grapher.Models.Calculations double lastInputMagnitude = 0; double lastOutputMagnitude = 0; + double maxRatio = 0.0; + double minRatio = Double.MaxValue; + double maxSlope = 0.0; + double minSlope = Double.MaxValue; + foreach (var magnitudeDatum in magnitudeData) { + if (magnitudeDatum.magnitude <=0) + { + continue; + } + var output = accel.Accelerate(magnitudeDatum.x, magnitudeDatum.y, MeasurementTime); var outMagnitude = Magnitude(output.Item1, output.Item2); + var ratio = magnitudeDatum.magnitude > 0 ? outMagnitude / magnitudeDatum.magnitude : starter; + + if (ratio > maxRatio) + { + maxRatio = ratio; + } + + if (ratio < minRatio) + { + minRatio = ratio; + } var inDiff = magnitudeDatum.magnitude - lastInputMagnitude; var outDiff = outMagnitude - lastOutputMagnitude; var slope = inDiff > 0 ? outDiff / inDiff : starter; + if (slope > maxSlope) + { + maxSlope = slope; + } + + if (slope < minSlope) + { + minSlope = slope; + } + if (!data.AccelPoints.ContainsKey(magnitudeDatum.magnitude)) { data.AccelPoints.Add(magnitudeDatum.magnitude, ratio); @@ -92,6 +123,10 @@ namespace grapher.Models.Calculations } data.OrderedVelocityPointsList.AddRange(data.VelocityPoints.Values.ToList()); + data.MaxAccel = maxRatio; + data.MinAccel = minRatio; + data.MaxGain = maxSlope; + data.MinGain = minSlope; } public void CalculateCombinedDiffSens(AccelData data, ManagedAccel accel, DriverSettings settings, ICollection<MagnitudeData> magnitudeData) @@ -100,6 +135,12 @@ namespace grapher.Models.Calculations double lastOutputMagnitudeX = 0; double lastOutputMagnitudeY = 0; + double maxRatio = 0.0; + double minRatio = Double.MaxValue; + double maxSlope = 0.0; + double minSlope = Double.MaxValue; + + Sensitivity = GetSens(ref settings); foreach (var magnitudeDatum in magnitudeData) @@ -118,6 +159,26 @@ namespace grapher.Models.Calculations var xRatio = settings.sensitivity.x * ratio; var yRatio = settings.sensitivity.y * ratio; + if (xRatio > maxRatio) + { + maxRatio = xRatio; + } + + if (xRatio < minRatio) + { + minRatio = xRatio; + } + + if (yRatio > maxRatio) + { + maxRatio = yRatio; + } + + if (yRatio < minRatio) + { + minRatio = yRatio; + } + if (!data.X.AccelPoints.ContainsKey(magnitudeDatum.magnitude)) { data.X.AccelPoints.Add(magnitudeDatum.magnitude, xRatio); @@ -137,6 +198,26 @@ namespace grapher.Models.Calculations var xSlope = inDiff > 0 ? xOutDiff / inDiff : settings.sensitivity.x; var ySlope = inDiff > 0 ? yOutDiff / inDiff : settings.sensitivity.y; + if (xSlope > maxSlope) + { + maxSlope = xSlope; + } + + if (xSlope < minSlope) + { + minSlope = xSlope; + } + + if (ySlope > maxSlope) + { + maxSlope = ySlope; + } + + if (ySlope < minSlope) + { + minSlope = ySlope; + } + if (!data.X.VelocityPoints.ContainsKey(magnitudeDatum.magnitude)) { data.X.VelocityPoints.Add(magnitudeDatum.magnitude, xOut); @@ -163,6 +244,10 @@ namespace grapher.Models.Calculations } data.Combined.OrderedVelocityPointsList.AddRange(data.Combined.VelocityPoints.Values.ToList()); + data.Combined.MaxAccel = maxRatio; + data.Combined.MinAccel = minRatio; + data.Combined.MaxGain = maxSlope; + data.Combined.MinGain = minSlope; } public ReadOnlyCollection<MagnitudeData> GetMagnitudes() |