diff options
| author | a1xd <[email protected]> | 2020-09-26 02:10:29 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-26 02:10:29 -0400 |
| commit | 9353f5b9adc50456fefc2e55aab5e57029e89682 (patch) | |
| tree | 5d28926aee87c077ffc4ed7222469bbf2f28bd2c /grapher/Models/Calculations/AccelChartData.cs | |
| parent | Merge pull request #22 from JacobPalecki/GUI (diff) | |
| parent | SetActive changes field default, bugs fixed (diff) | |
| download | rawaccel-9353f5b9adc50456fefc2e55aab5e57029e89682.tar.xz rawaccel-9353f5b9adc50456fefc2e55aab5e57029e89682.zip | |
Merge pull request #23 from JacobPalecki/GUI
Settings writer; GUI performance enhancement and touchups
Diffstat (limited to 'grapher/Models/Calculations/AccelChartData.cs')
| -rw-r--r-- | grapher/Models/Calculations/AccelChartData.cs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs index 54685a2..60d4c89 100644 --- a/grapher/Models/Calculations/AccelChartData.cs +++ b/grapher/Models/Calculations/AccelChartData.cs @@ -13,8 +13,8 @@ namespace grapher.Models.Calculations AccelPoints = new SortedDictionary<double, double>(); VelocityPoints = new SortedDictionary<double, double>(); GainPoints = new SortedDictionary<double, double>(); - OrderedVelocityPointsList = new List<double>(); OutVelocityToPoints = new Dictionary<double, (double, double, double)>(); + LogToIndex = new int[701]; } #endregion Constructors @@ -35,7 +35,7 @@ namespace grapher.Models.Calculations public SortedDictionary<double, double> GainPoints { get; } - public List<double> OrderedVelocityPointsList { get; } + public int[] LogToIndex { get; } public Dictionary<double, (double, double, double)> OutVelocityToPoints { get; } @@ -48,8 +48,8 @@ namespace grapher.Models.Calculations AccelPoints.Clear(); VelocityPoints.Clear(); GainPoints.Clear(); - OrderedVelocityPointsList.Clear(); OutVelocityToPoints.Clear(); + Array.Clear(LogToIndex, 0, LogToIndex.Length); } public (double, double, double) FindPointValuesFromOut(double outVelocityValue) @@ -80,15 +80,19 @@ namespace grapher.Models.Calculations public int GetVelocityIndex(double outVelocityValue) { - var velIdx = OrderedVelocityPointsList.BinarySearch(outVelocityValue); - - if (velIdx < 0) + var log = Math.Log10(outVelocityValue); + if (log < -2) + { + log = -2; + } + else if (log > 5) { - velIdx = ~velIdx; + log = 5; } - velIdx = Math.Min(velIdx, VelocityPoints.Count - 1); - velIdx = Math.Max(velIdx, 0); + log = log * 100 + 200; + + var velIdx = LogToIndex[(int)log]; return velIdx; } |