Beispiel #1
0
        /// <summary>
        /// Calculates a single Newton fractal value.
        /// </summary>
        /// <param name="x">The x value.</param>
        /// <param name="y">The y value.</param>
        /// <returns>The result (color value 0..1).</returns>
        public override double Run(double x, double y)
        {
            var iter = 0;
            var maxiter = MaxIterations;

            ScalarValue zn = new ScalarValue(x, y);
            ScalarValue pz = ScalarValue.One;
            ScalarValue pzd = ScalarValue.Zero;

            if(x != 0 || y != 0)
            {
                while ((iter < maxiter) && pz.AbsSquare() > 1e-8)
                {
                    pz = zn.Pow(new ScalarValue(3)) - 1.0;
                    pzd = 3.0 * zn.Square();
                    zn = zn - pz / pzd;
                    iter++;
                }
            }

            return Math.Max((double)(maxiter - iter * Colors) / (double)maxiter, 0.0);
        }
Beispiel #2
0
        /// <summary>
        /// Calculates a single Newton fractal value.
        /// </summary>
        /// <param name="x">The x value.</param>
        /// <param name="y">The y value.</param>
        /// <returns>The result (color value 0..1).</returns>
        public override double Run(double x, double y)
        {
            var iter    = 0;
            var maxiter = MaxIterations;

            ScalarValue zn  = new ScalarValue(x, y);
            ScalarValue pz  = ScalarValue.One;
            ScalarValue pzd = ScalarValue.Zero;

            if (x != 0 || y != 0)
            {
                while ((iter < maxiter) && pz.AbsSquare() > 1e-8)
                {
                    pz  = zn.Pow(new ScalarValue(3)) - 1.0;
                    pzd = 3.0 * zn.Square();
                    zn  = zn - pz / pzd;
                    iter++;
                }
            }

            return(Math.Max((double)(maxiter - iter * Colors) / (double)maxiter, 0.0));
        }
Beispiel #3
0
 protected override ScalarValue GetValue(ScalarValue z)
 {
     return((1.0 / z + (1.0 / z.Square() + 1.0).Sqrt()).Ln());
 }
Beispiel #4
0
 protected override ScalarValue GetValue(ScalarValue z)
 {
     return (1.0 / z + (1.0 / z.Square() + 1.0).Sqrt()).Ln();
 }