Exemplo n.º 1
0
        /// <inheritdoc />
        protected override float Single(int seed, double x)
        {
            int x0 = Math2.Floor(x);

            double xs;

            switch (_noiseInterpolationType)
            {
            default:
            case NoiseInterpolationType.Linear:
                xs = x - x0;
                break;

            case NoiseInterpolationType.Hermite:
                xs = Math2.CurveHermite(x - x0);
                break;

            case NoiseInterpolationType.Quintic:
                xs = Math2.CurveQuintic(x - x0);
                break;
            }

            return(Math2.Lerp(
                       ValueCoord1D(seed, x0),
                       ValueCoord1D(seed, x0 + 1),
                       xs));
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        protected override float Single(int seed, double x, double y, double z)
        {
            int x0 = Math2.Floor(x);
            int y0 = Math2.Floor(y);
            int z0 = Math2.Floor(z);
            int x1 = x0 + 1;
            int y1 = y0 + 1;
            int z1 = z0 + 1;

            double xs, ys, zs;

            switch (_noiseInterpolationType)
            {
            default:
            case NoiseInterpolationType.Linear:
                xs = x - x0;
                ys = y - y0;
                zs = z - z0;
                break;

            case NoiseInterpolationType.Hermite:
                xs = Math2.CurveHermite(x - x0);
                ys = Math2.CurveHermite(y - y0);
                zs = Math2.CurveHermite(z - z0);
                break;

            case NoiseInterpolationType.Quintic:
                xs = Math2.CurveQuintic(x - x0);
                ys = Math2.CurveQuintic(y - y0);
                zs = Math2.CurveQuintic(z - z0);
                break;
            }

            return(Math2.Lerp(
                       Math2.Lerp(
                           Math2.Lerp(
                               ValueCoord3D(seed, x0, y0, z0),
                               ValueCoord3D(seed, x1, y0, z0),
                               xs),
                           Math2.Lerp(
                               ValueCoord3D(seed, x0, y1, z0),
                               ValueCoord3D(seed, x1, y1, z0),
                               xs),
                           ys),
                       Math2.Lerp(
                           Math2.Lerp(
                               ValueCoord3D(seed, x0, y0, z1),
                               ValueCoord3D(seed, x1, y0, z1),
                               xs),
                           Math2.Lerp(
                               ValueCoord3D(seed, x0, y1, z1),
                               ValueCoord3D(seed, x1, y1, z1),
                               xs),
                           ys),
                       zs));
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        protected override float Single(int seed, double x, double y)
        {
            int x0 = Math2.Floor(x);
            int y0 = Math2.Floor(y);
            int x1 = x0 + 1;
            int y1 = y0 + 1;

            double xd0 = x - x0;
            double yd0 = y - y0;
            double xs, ys;

            switch (_noiseInterpolationType)
            {
            default:
            case NoiseInterpolationType.Linear:
                xs = xd0;
                ys = yd0;
                break;

            case NoiseInterpolationType.Hermite:
                xs = Math2.CurveHermite(xd0);
                ys = Math2.CurveHermite(yd0);
                break;

            case NoiseInterpolationType.Quintic:
                xs = Math2.CurveQuintic(xd0);
                ys = Math2.CurveQuintic(yd0);
                break;
            }

            double xd1 = xd0 - 1.0f;
            double yd1 = yd0 - 1.0f;

            return(Math2.Lerp(
                       Math2.Lerp(
                           GradCoord2D(seed, x0, y0, xd0, yd0),
                           GradCoord2D(seed, x1, y0, xd1, yd0),
                           xs),
                       Math2.Lerp(
                           GradCoord2D(seed, x0, y1, xd0, yd1),
                           GradCoord2D(seed, x1, y1, xd1, yd1),
                           xs),
                       ys));
        }