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 From ba642cd8c8e63ec3778fa17ecbcd7964074aaba1 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 21 Sep 2020 00:08:19 -0700 Subject: separate x/y mostly works --- grapher/Models/Calculations/AccelChartData.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'grapher/Models/Calculations/AccelChartData.cs') diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs index c943643..907eb0e 100644 --- a/grapher/Models/Calculations/AccelChartData.cs +++ b/grapher/Models/Calculations/AccelChartData.cs @@ -63,7 +63,7 @@ namespace grapher.Models.Calculations public (double, double, double) ValuesAtIndex(int index) { - return (VelocityPoints.ElementAt(index).Value, AccelPoints.ElementAt(index).Value, GainPoints.ElementAt(index).Value); + return (AccelPoints.ElementAt(index).Value, VelocityPoints.ElementAt(index).Value, GainPoints.ElementAt(index).Value); } public int GetVelocityIndex(double outVelocityValue) @@ -75,6 +75,8 @@ namespace grapher.Models.Calculations velIdx = ~velIdx; } + velIdx = Math.Min(velIdx, VelocityPoints.Count - 1); + return velIdx; } -- cgit v1.2.3 From 99ad8686bb039dcf82115550dbf347d8695ee1f8 Mon Sep 17 00:00:00 2001 From: Jacob Palecki Date: Mon, 21 Sep 2020 12:41:16 -0700 Subject: x/y diff sens works --- grapher/Models/Calculations/AccelChartData.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'grapher/Models/Calculations/AccelChartData.cs') diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs index 907eb0e..fbf1944 100644 --- a/grapher/Models/Calculations/AccelChartData.cs +++ b/grapher/Models/Calculations/AccelChartData.cs @@ -66,6 +66,11 @@ namespace grapher.Models.Calculations 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); -- cgit v1.2.3