AccidentalNoise.ImplicitBasisFunction.SetMagicNumbers C# (CSharp) Method

SetMagicNumbers() private method

private SetMagicNumbers ( BasisType type ) : void
type BasisType
return void
        private void SetMagicNumbers(BasisType type)
        {
            // This function is a damned hack.
            // The underlying noise functions don't return values in the range [-1,1] cleanly, and the ranges vary depending
            // on basis type and dimensionality. There's probably a better way to correct the ranges, but for now I'm just
            // setting he magic numbers scale and offset manually to empirically determined magic numbers.
            switch (type)
            {
                case BasisType.VALUE:
                    this.scale[0] = 1.0;
                    this.offset[0] = 0.0;
                    this.scale[1] = 1.0;
                    this.offset[1] = 0.0;
                    this.scale[2] = 1.0;
                    this.offset[2] = 0.0;
                    this.scale[3] = 1.0;
                    this.offset[3] = 0.0;
                    break;

                case BasisType.GRADIENT:
                    this.scale[0] = 1.86848;
                    this.offset[0] = -0.000118;
                    this.scale[1] = 1.85148;
                    this.offset[1] = -0.008272;
                    this.scale[2] = 1.64127;
                    this.offset[2] = -0.01527;
                    this.scale[3] = 1.92517;
                    this.offset[3] = 0.03393;
                    break;

                case BasisType.GRADIENTVALUE:
                    this.scale[0] = 0.6769;
                    this.offset[0] = -0.00151;
                    this.scale[1] = 0.6957;
                    this.offset[1] = -0.133;
                    this.scale[2] = 0.74622;
                    this.offset[2] = 0.01916;
                    this.scale[3] = 0.7961;
                    this.offset[3] = -0.0352;
                    break;

                case BasisType.WHITE:
                    this.scale[0] = 1.0;
                    this.offset[0] = 0.0;
                    this.scale[1] = 1.0;
                    this.offset[1] = 0.0;
                    this.scale[2] = 1.0;
                    this.offset[2] = 0.0;
                    this.scale[3] = 1.0;
                    this.offset[3] = 0.0;
                    break;

                default:
                    this.scale[0] = 1.0;
                    this.offset[0] = 0.0;
                    this.scale[1] = 1.0;
                    this.offset[1] = 0.0;
                    this.scale[2] = 1.0;
                    this.offset[2] = 0.0;
                    this.scale[3] = 1.0;
                    this.offset[3] = 0.0;
                    break;
            }
        }
    }