using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace grapher.Models.Calculations { public class AccelChartData { public AccelChartData() { AccelPoints = new SortedDictionary(); VelocityPoints = new SortedDictionary(); GainPoints = new SortedDictionary(); } public SortedDictionary AccelPoints { get; } public SortedDictionary VelocityPoints { get; } public SortedDictionary GainPoints { get; } public void Clear() { AccelPoints.Clear(); VelocityPoints.Clear(); GainPoints.Clear(); } public (double, double, double) FindInValuesFromOut(double outVelocityValue) { var velIdx = ~VelocityPoints.Values.ToList().BinarySearch(outVelocityValue); if (velIdx < 0) { velIdx = ~velIdx; } return (VelocityPoints.ElementAt(velIdx).Key, AccelPoints.ElementAt(velIdx).Value, GainPoints.ElementAt(velIdx).Value); } } }