summaryrefslogtreecommitdiff
path: root/grapher/Models/Calculations/AccelCalculator.cs
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-22 14:01:05 -0700
committerJacob Palecki <[email protected]>2020-09-22 14:01:05 -0700
commit720a45289b2342c62eebb0e1cee3c4b88c9fe696 (patch)
tree19447d387a1f69eb16baebaf6b2fc97dda5b3709 /grapher/Models/Calculations/AccelCalculator.cs
parentRename experiment two to motivity (diff)
downloadrawaccel-720a45289b2342c62eebb0e1cee3c4b88c9fe696.tar.xz
rawaccel-720a45289b2342c62eebb0e1cee3c4b88c9fe696.zip
Scaling improvement, remove y data from xy combined
Diffstat (limited to 'grapher/Models/Calculations/AccelCalculator.cs')
-rw-r--r--grapher/Models/Calculations/AccelCalculator.cs79
1 files changed, 79 insertions, 0 deletions
diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs
index ab6e9de..d9b51b2 100644
--- a/grapher/Models/Calculations/AccelCalculator.cs
+++ b/grapher/Models/Calculations/AccelCalculator.cs
@@ -62,6 +62,11 @@ 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)
@@ -73,11 +78,31 @@ namespace grapher.Models.Calculations
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);
@@ -98,6 +123,10 @@ namespace grapher.Models.Calculations
}
data.OrderedVelocityPointsList.AddRange(data.VelocityPoints.Values.ToList());
+ data.MaxAccel = maxRatio;
+ data.MinAccel = minRatio;
+ data.MaxGain = maxRatio;
+ data.MinGain = minRatio;
}
public void CalculateCombinedDiffSens(AccelData data, ManagedAccel accel, DriverSettings settings, ICollection<MagnitudeData> magnitudeData)
@@ -106,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)
@@ -124,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);
@@ -143,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);
@@ -169,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()