예제 #1
0
        public LinearInterpolator(IEnumerable <double> xCoords, IEnumerable <double> yCoords, VertexAxisType axisType)
        {
            verticalAxisType = axisType;
            var x = xCoords as IList <double> ?? xCoords.ToList();
            var y = yCoords as IList <double> ?? yCoords.ToList();

            if (x.Count < 2 || y.Count < 2 || x.Count != y.Count)
            {
                throw new ArgumentException("Number of X and Y coordinates should be equal and > 2");
            }

            for (var i = 0; i < x.Count(); i++)
            {
                this.points.Add(new Point(x[i], y[i]));
            }

            this.points = this.points.OrderBy(point => point.X).ToList();
        }
예제 #2
0
        public string GetEvidenceString(double xValue, VertexAxisType axisType)
        {
            var values = this.Points.Select(scatterDataPoints => (new LinearInterpolator(scatterDataPoints.GetXCoords(), scatterDataPoints.GetYCoords(), axisType).Eval(xValue))).ToList();

            values.Sort();

            if (this.Type == InterpolationType.SingleValue)
            {
                return(values[0].ToString());
            }

            if (this.Type == InterpolationType.Uniform)
            {
                return(values[0] + ":" + values[1]);
            }

            if (this.Type == InterpolationType.Triangular)
            {
                return("TRI(" + values[0] + "," + values[1] + "," + values[2] + ")");
            }

            return(null);
        }