From 2a756dfb08b4f8c0870173ad4e0393cdeef33c94 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Sun, 20 Sep 2020 23:16:15 -0700 Subject: Attempt to get separate x/y working --- grapher/Models/Calculations/AccelChartData.cs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'grapher/Models/Calculations/AccelChartData.cs') diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs index 8c0c8ea..c943643 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,23 @@ namespace grapher.Models.Calculations } } + public (double, double, double) ValuesAtIndex(int index) + { + return (VelocityPoints.ElementAt(index).Value, AccelPoints.ElementAt(index).Value, GainPoints.ElementAt(index).Value); + } + + public int GetVelocityIndex(double outVelocityValue) + { + var velIdx = OrderedVelocityPointsList.BinarySearch(outVelocityValue); + + if (velIdx < 0) + { + velIdx = ~velIdx; + } + + return velIdx; + } + #endregion Methods } } -- cgit v1.2.3