コード例 #1
0
        public static double MedianLow
        (
            this Memory <uint> x
        )
        {
            int n = x.Length;

            System.Linq.IOrderedEnumerable <uint> x_ordered = x.ToArray().OrderBy(x_i => x_i);
            int n2 = n / 2 - 1;

            if (n % 2 == 1)
            {
                return(x_ordered.ElementAt((n + 1) / 2 - 1));
            }

            return(x_ordered.ElementAt(n2));
        }
コード例 #2
0
    public float GetValue(int x, int y, int z = 0, int pointIndex = 0)
    {
        if (_points == null)
        {
            throw new Exception("Call the Generate map method first.");
        }

        int max = Math.Max(Math.Max(Width, Height), Depth);

        int index = x + (y * Width) + (z * Width * Height);

        float[] distances = new float[_points.Length];
        for (int i = 0; i < distances.Length; i++)
        {
            distances[i] = Map(Vector3.Distance(new Vector3(x, y, z), _points[i]), 0, max / 2, 0, 1);
        }
        System.Linq.IOrderedEnumerable <float> ordered = distances.OrderBy(d => d);

        return(ordered.ElementAt(pointIndex % NbOfPoints));
    }