diff options
| author | Jacob Palecki <[email protected]> | 2020-09-21 14:27:12 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-21 14:27:12 -0700 |
| commit | 96112bf6eaee310985ae607b66b43fafcc5efb1e (patch) | |
| tree | 6ffdee3a16c7b5c89b6f12117e8a9b78b1112e6f /grapher/Models/Calculations/AccelChartData.cs | |
| parent | conditional around lookup map (diff) | |
| parent | Merge pull request #21 from JacobPalecki/GUI (diff) | |
| download | rawaccel-96112bf6eaee310985ae607b66b43fafcc5efb1e.tar.xz rawaccel-96112bf6eaee310985ae607b66b43fafcc5efb1e.zip | |
Merge branch 'GUI' into experiment
Diffstat (limited to 'grapher/Models/Calculations/AccelChartData.cs')
| -rw-r--r-- | grapher/Models/Calculations/AccelChartData.cs | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs index 8c0c8ea..fbf1944 100644 --- a/grapher/Models/Calculations/AccelChartData.cs +++ b/grapher/Models/Calculations/AccelChartData.cs @@ -52,12 +52,7 @@ namespace grapher.Models.Calculations } else { - var velIdx = OrderedVelocityPointsList.BinarySearch(outVelocityValue); - - if (velIdx < 0) - { - velIdx = ~velIdx; - } + var velIdx = GetVelocityIndex(outVelocityValue); velIdx = Math.Min(velIdx, VelocityPoints.Count - 1); values = (VelocityPoints.ElementAt(velIdx).Key, AccelPoints.ElementAt(velIdx).Value, GainPoints.ElementAt(velIdx).Value); @@ -66,6 +61,30 @@ namespace grapher.Models.Calculations } } + public (double, double, double) ValuesAtIndex(int index) + { + return (AccelPoints.ElementAt(index).Value, VelocityPoints.ElementAt(index).Value, GainPoints.ElementAt(index).Value); + } + + public (double, double, double) ValuesAtInVelocity(double inVelocity) + { + return (AccelPoints[inVelocity], VelocityPoints[inVelocity], GainPoints[inVelocity]); + } + + public int GetVelocityIndex(double outVelocityValue) + { + var velIdx = OrderedVelocityPointsList.BinarySearch(outVelocityValue); + + if (velIdx < 0) + { + velIdx = ~velIdx; + } + + velIdx = Math.Min(velIdx, VelocityPoints.Count - 1); + + return velIdx; + } + #endregion Methods } } |