summaryrefslogtreecommitdiff
path: root/grapher/Models/Calculations/Data
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2021-01-18 22:02:29 -0800
committerJacob Palecki <[email protected]>2021-01-18 22:02:29 -0800
commit4faf0007c7c551fae8fd25fc7a98767070cb9244 (patch)
tree9aec833ce5453ae853148c387410cb9b792c1e2e /grapher/Models/Calculations/Data
parentRefactor for new graph calculation method (diff)
downloadrawaccel-4faf0007c7c551fae8fd25fc7a98767070cb9244.tar.xz
rawaccel-4faf0007c7c551fae8fd25fc7a98767070cb9244.zip
Directional works
Diffstat (limited to 'grapher/Models/Calculations/Data')
-rw-r--r--grapher/Models/Calculations/Data/AccelDataXYDirectional.cs73
1 files changed, 40 insertions, 33 deletions
diff --git a/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs b/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs
index ffa353f..ad54989 100644
--- a/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs
+++ b/grapher/Models/Calculations/Data/AccelDataXYDirectional.cs
@@ -14,16 +14,26 @@ namespace grapher.Models.Calculations.Data
EstimatedPoints yPoints,
AccelCalculator calculator)
{
- X = new AccelChartData();
- Y = new AccelChartData();
XPoints = xPoints;
YPoints = yPoints;
Calculator = calculator;
+ AngleToData = new AccelChartData[Constants.AngleDivisions];
+ FillAngleData();
}
- public AccelChartData X { get; }
+ public AccelChartData X { get => AngleToData[0]; }
- public AccelChartData Y { get; }
+ public AccelChartData Y { get => AngleToData[Constants.AngleDivisions-1]; }
+
+ public double SensitivityMax { get => X.MaxAccel; }
+
+ public double SensitivityMin { get => X.MinAccel; }
+
+ public double GainMax { get => X.MaxGain; }
+
+ public double GainMin { get => X.MinGain; }
+
+ private AccelChartData[] AngleToData { get; }
private EstimatedPoints XPoints { get; }
@@ -33,45 +43,42 @@ namespace grapher.Models.Calculations.Data
public void CalculateDots(double x, double y, double timeInMs)
{
- (var xStripped, var yStripped) = AccelCalculator.StripSens(x, y, settings.sensitivity.x, settings.sensitivity.y);
- var outVelocity = AccelCalculator.Velocity(xStripped, yStripped, timeInMs);
-
- if (OutVelocityToPoints.TryGetValue(outVelocity, out var points))
- {
- XPoints.Sensitivity.Set(points.Item1, points.Item2);
- XPoints.Velocity.Set(points.Item1, points.Item3);
- XPoints.Gain.Set(points.Item1, points.Item4);
- YPoints.Sensitivity.Set(points.Item1, points.Item5);
- YPoints.Velocity.Set(points.Item1, points.Item6);
- YPoints.Gain.Set(points.Item1, points.Item7);
- }
- else
- {
- var index = Combined.GetVelocityIndex(outVelocity);
- var inVelocity = Combined.VelocityPoints.ElementAt(index).Key;
- var xPoints = X.ValuesAtIndex(index);
- var yPoints = Y.ValuesAtIndex(index);
- OutVelocityToPoints.Add(outVelocity, (inVelocity, xPoints.Item1, xPoints.Item2, xPoints.Item3, yPoints.Item1, yPoints.Item2, yPoints.Item3));
- EstimatedX.Sensitivity.Set(inVelocity, xPoints.Item1);
- EstimatedX.Velocity.Set(inVelocity, xPoints.Item2);
- EstimatedX.Gain.Set(inVelocity, xPoints.Item3);
- EstimatedY.Sensitivity.Set(inVelocity, yPoints.Item1);
- EstimatedY.Velocity.Set(inVelocity, yPoints.Item2);
- EstimatedY.Gain.Set(inVelocity, yPoints.Item3);
- }
-
+ var outVelocity = AccelCalculator.Velocity(x, y, timeInMs);
+ var outAngle = Math.Atan2(Math.Abs(y),Math.Abs(x));
+ var nearestAngleDivision = AccelCalculator.NearestAngleDivision(outAngle);
+ var data = AngleToData[nearestAngleDivision];
+ var index = data.GetVelocityIndex(outVelocity);
+ var inVelocity = data.VelocityPoints.ElementAt(index).Key;
+ var xPoints = X.ValuesAtIndex(index);
+ var yPoints = Y.ValuesAtIndex(index);
+ XPoints.Sensitivity.Set(inVelocity, xPoints.Item1);
+ XPoints.Velocity.Set(inVelocity, xPoints.Item2);
+ XPoints.Gain.Set(inVelocity, xPoints.Item3);
+ YPoints.Sensitivity.Set(inVelocity, yPoints.Item1);
+ YPoints.Velocity.Set(inVelocity, yPoints.Item2);
+ YPoints.Gain.Set(inVelocity, yPoints.Item3);
}
public void Clear()
{
- X.Clear();
- Y.Clear();
+ foreach (var data in AngleToData)
+ {
+ data.Clear();
+ }
}
public void CreateGraphData(ManagedAccel accel, DriverSettings settings)
{
Clear();
+ Calculator.CalculateCombinedDiffSens(AngleToData, accel, settings, Calculator.SimulatedDirectionalInput);
}
+ private void FillAngleData()
+ {
+ for(int i=0; i < Constants.AngleDivisions; i++)
+ {
+ AngleToData[i] = new AccelChartData();
+ }
+ }
}
}