summaryrefslogtreecommitdiff
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
parentRename experiment two to motivity (diff)
downloadrawaccel-720a45289b2342c62eebb0e1cee3c4b88c9fe696.tar.xz
rawaccel-720a45289b2342c62eebb0e1cee3c4b88c9fe696.zip
Scaling improvement, remove y data from xy combined
-rw-r--r--grapher/Models/Calculations/AccelCalculator.cs79
-rw-r--r--grapher/Models/Calculations/AccelChartData.cs8
-rw-r--r--grapher/Models/Charts/ChartState/CombinedState.cs2
-rw-r--r--grapher/Models/Charts/ChartState/XYOneGraphState.cs2
-rw-r--r--grapher/Models/Charts/ChartState/XYTwoGraphState.cs3
-rw-r--r--grapher/Models/Charts/ChartXY.cs22
6 files changed, 116 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()
diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs
index 5225e08..54685a2 100644
--- a/grapher/Models/Calculations/AccelChartData.cs
+++ b/grapher/Models/Calculations/AccelChartData.cs
@@ -23,6 +23,14 @@ namespace grapher.Models.Calculations
public SortedDictionary<double, double> AccelPoints { get; }
+ public double MaxAccel { get; set; }
+
+ public double MinAccel { get; set; }
+
+ public double MaxGain { get; set; }
+
+ public double MinGain { get; set; }
+
public SortedDictionary<double, double> VelocityPoints { get; }
public SortedDictionary<double, double> GainPoints { get; }
diff --git a/grapher/Models/Charts/ChartState/CombinedState.cs b/grapher/Models/Charts/ChartState/CombinedState.cs
index 17cd68a..f4b6b8f 100644
--- a/grapher/Models/Charts/ChartState/CombinedState.cs
+++ b/grapher/Models/Charts/ChartState/CombinedState.cs
@@ -36,6 +36,8 @@ namespace grapher.Models.Charts.ChartState
SensitivityChart.Bind(Data.Combined.AccelPoints);
VelocityChart.Bind(Data.Combined.VelocityPoints);
GainChart.Bind(Data.Combined.GainPoints);
+ SensitivityChart.SetMinMax(Data.Combined.MinAccel, Data.Combined.MaxAccel);
+ GainChart.SetMinMax(Data.Combined.MinGain, Data.Combined.MaxGain);
}
public override void Calculate(ManagedAccel accel, DriverSettings settings)
diff --git a/grapher/Models/Charts/ChartState/XYOneGraphState.cs b/grapher/Models/Charts/ChartState/XYOneGraphState.cs
index bbc0c28..6bfaac5 100644
--- a/grapher/Models/Charts/ChartState/XYOneGraphState.cs
+++ b/grapher/Models/Charts/ChartState/XYOneGraphState.cs
@@ -38,6 +38,8 @@ namespace grapher.Models.Charts.ChartState
SensitivityChart.BindXYCombined(Data.X.AccelPoints, Data.Y.AccelPoints);
VelocityChart.BindXYCombined(Data.X.VelocityPoints, Data.Y.VelocityPoints);
GainChart.BindXYCombined(Data.X.GainPoints, Data.Y.GainPoints);
+ SensitivityChart.SetMinMax(Data.Combined.MinAccel, Data.Combined.MaxAccel);
+ GainChart.SetMinMax(Data.Combined.MinGain, Data.Combined.MaxGain);
}
public override void Calculate(ManagedAccel accel, DriverSettings settings)
diff --git a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs
index 69dc335..b775853 100644
--- a/grapher/Models/Charts/ChartState/XYTwoGraphState.cs
+++ b/grapher/Models/Charts/ChartState/XYTwoGraphState.cs
@@ -65,6 +65,9 @@ namespace grapher.Models.Charts.ChartState
SensitivityChart.BindXY(Data.X.AccelPoints, Data.Y.AccelPoints);
VelocityChart.BindXY(Data.X.VelocityPoints, Data.Y.VelocityPoints);
GainChart.BindXY(Data.X.GainPoints, Data.Y.GainPoints);
+
+ SensitivityChart.SetMinMaxXY(Data.X.MinAccel, Data.X.MaxAccel, Data.Y.MinAccel, Data.Y.MaxAccel);
+ GainChart.SetMinMaxXY(Data.X.MinGain, Data.X.MaxGain, Data.Y.MinGain, Data.Y.MaxGain);
}
public override void Calculate(ManagedAccel accel, DriverSettings settings)
diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs
index 3850e42..253804e 100644
--- a/grapher/Models/Charts/ChartXY.cs
+++ b/grapher/Models/Charts/ChartXY.cs
@@ -100,6 +100,9 @@ namespace grapher
chart.ChartAreas[0].AxisY.ScaleView.MinSize = 0.01;
chart.ChartAreas[0].AxisY.ScaleView.SmallScrollSize = 0.001;
+ chart.ChartAreas[0].AxisX.LabelStyle.Format = "0.##";
+ chart.ChartAreas[0].AxisY.LabelStyle.Format = "0.##";
+
chart.ChartAreas[0].CursorY.Interval = 0.001;
chart.ChartAreas[0].CursorX.AutoScroll = true;
@@ -187,18 +190,37 @@ namespace grapher
public void Bind(IDictionary data)
{
ChartX.Series[0].Points.DataBindXY(data.Keys, data.Values);
+ ChartX.Series[2].IsVisibleInLegend = false;
+ ChartX.Series[2].Points.Clear();
}
public void BindXY(IDictionary dataX, IDictionary dataY)
{
ChartX.Series[0].Points.DataBindXY(dataX.Keys, dataX.Values);
ChartY.Series[0].Points.DataBindXY(dataY.Keys, dataY.Values);
+ ChartX.Series[2].IsVisibleInLegend = false;
+ ChartX.Series[2].Points.Clear();
}
public void BindXYCombined(IDictionary dataX, IDictionary dataY)
{
ChartX.Series[0].Points.DataBindXY(dataX.Keys, dataX.Values);
ChartX.Series[2].Points.DataBindXY(dataY.Keys, dataY.Values);
+ ChartX.Series[2].IsVisibleInLegend = true;
+ }
+
+ public void SetMinMax(double min, double max)
+ {
+ ChartX.ChartAreas[0].AxisY.Minimum = min;
+ ChartX.ChartAreas[0].AxisY.Maximum = max;
+ }
+
+ public void SetMinMaxXY(double minX, double maxX, double minY, double maxY)
+ {
+ ChartX.ChartAreas[0].AxisY.Minimum = minX;
+ ChartX.ChartAreas[0].AxisY.Maximum = maxX;
+ ChartY.ChartAreas[0].AxisY.Minimum = minY;
+ ChartY.ChartAreas[0].AxisY.Maximum = maxY;
}
public void SetCombined()