Beispiel #1
0
        public static IEnumerable <Point> GetSplinePointsConnectingAbsoluteFirstLastDataPoints(IList <DataPoint> dataPoints, double scaleFactor)
        {
            DataPoint firstPoint = dataPoints[0];
            DataPoint lastPoint  = dataPoints[dataPoints.Count - 1];

            if (firstPoint.isEmpty || double.IsNaN(firstPoint.CenterX()) || double.IsNaN(firstPoint.CenterY()) ||
                lastPoint.isEmpty || double.IsNaN(lastPoint.CenterX()) || double.IsNaN(lastPoint.CenterY()))
            {
                yield break;
            }

            double tolerance = DefaultTolerance;

            if (scaleFactor > 2)
            {
                tolerance *= (int)scaleFactor / 2;
            }

            DataPoint previousSignificantPointBeforeAbsoluteLast = FindPreviousNonEmptyPointBeforeAbsoluteLast(dataPoints);
            DataPoint nextSignificantPointAfterAbsoluteFirst     = FindNextNonEmptyPointAfterAbsoluteFirst(dataPoints);

            // return the first point since spline segmentation skips it
            yield return(lastPoint.Center());

            foreach (Point point in Segment(previousSignificantPointBeforeAbsoluteLast.Center(), lastPoint.Center(), firstPoint.Center(), nextSignificantPointAfterAbsoluteFirst.Center(), tolerance))
            {
                yield return(point);
            }
        }