コード例 #1
0
        private double Generate(double x)
        {
            int X = ((int)Math.Floor(x)) & 0xff;

            x -= Math.Floor(x);
            double u = PerlinUtil.Fade(x);

            return(PerlinUtil.Lerp(u, PerlinUtil.Grad(perm[X], x), PerlinUtil.Grad(perm[X + 1], x - 1)) * 2.0d);
        }
コード例 #2
0
        private double Generate(double x, double y)
        {
            int X = ((int)Math.Floor(x)) & 0xff;
            int Y = ((int)Math.Floor(y)) & 0xff;

            x -= Math.Floor(x);
            y -= Math.Floor(y);
            double u = PerlinUtil.Fade(x);
            double v = PerlinUtil.Fade(y);
            int    A = (perm[X] + Y) & 0xff;
            int    B = (perm[X + 1] + Y) & 0xff;

            return(PerlinUtil.Lerp(v,
                                   PerlinUtil.Lerp(u, PerlinUtil.Grad(perm[A], x, y), PerlinUtil.Grad(perm[B], x - 1.0d, y)),
                                   PerlinUtil.Lerp(u, PerlinUtil.Grad(perm[A + 1], x, y - 1.0d), PerlinUtil.Grad(perm[B + 1], x - 1.0d, y - 1.0d))
                                   ));
        }