private LinearInterpolationSurface(double[] values, IPlotFunction[] functions, LinearInterpolationSurfaceProjection projection)
        {
            int n = values.Length;

            if (functions.Length != n)
            {
                throw new ArgumentException();
            }

            List<Tuple<double, IPlotFunction>> pairs = new List<Tuple<double, IPlotFunction>>();
            for (int i = 0; i < n; i++)
            {
                pairs.Add(Tuple.Create<double, IPlotFunction>(values[i], functions[i]));
            }
            pairs.Sort((p1, p2) => p1.Item1.CompareTo(p2.Item1));

            for (int i = 0; i < n; i++)
            {
                values[i] = pairs[i].Item1;
                functions[i] = pairs[i].Item2;
            }

            Count = n;
            Values = new ImmutableList<double>(values);
            Functions = new ImmutableList<IPlotFunction>(functions);
            Projection = projection;
        }
 public LinearInterpolationSurface(IEnumerable<double> values, IEnumerable<IPlotFunction> functions, LinearInterpolationSurfaceProjection projection)
     : this(new List<double>(values).ToArray(), new List<IPlotFunction>(functions).ToArray(), projection)
 {
 }
 public LinearInterpolationSurface(LinearInterpolationSurfaceProjection projection)
     : this(new double[0], new IPlotFunction[0], projection)
 {
 }