| | | 1 | | using System.Collections.Generic; |
| | | 2 | | using UnityEngine; |
| | | 3 | | |
| | | 4 | | // Base implementation of a launch angle data interpolator. |
| | | 5 | | // |
| | | 6 | | // The launch angle data interpolator interpolates the values from a static list of values. |
| | | 7 | | public abstract class LaunchAngleDataInterpolatorBase : LaunchAngleInterpolatorBase { |
| | 36 | 8 | | public LaunchAngleDataInterpolatorBase(IAgent agent) : base(agent) {} |
| | | 9 | | |
| | | 10 | | // Initialize the interpolator. |
| | 12 | 11 | | protected override void InitInterpolator() { |
| | 12 | 12 | | var interpolatorDataPoints = new List<Interpolator2DDataPoint>(); |
| | 144 | 13 | | foreach (var dataPoint in GenerateData()) { |
| | 36 | 14 | | var interpolatorDataPoint = new Interpolator2DDataPoint { |
| | | 15 | | Coordinates = new Vector2(dataPoint.Input.Distance, dataPoint.Input.Altitude), |
| | | 16 | | Data = new List<float> { dataPoint.Output.LaunchAngle, dataPoint.Output.TimeToPosition }, |
| | | 17 | | }; |
| | 36 | 18 | | interpolatorDataPoints.Add(interpolatorDataPoint); |
| | 36 | 19 | | } |
| | 12 | 20 | | _interpolator = new NearestNeighborInterpolator2D(interpolatorDataPoints); |
| | 12 | 21 | | } |
| | | 22 | | |
| | | 23 | | // Generate the launch angle data points to interpolate. |
| | | 24 | | protected abstract IEnumerable<LaunchAngleDataPoint> GenerateData(); |
| | | 25 | | } |