diff options
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 } } |