示例#1
0
        public void NumberToPointToNumberTest()
        {
            const int xRange = 500;
            const int yRange = 500;

            var resolution = new Size(xRange * 2, yRange * 2);

            const int xLower = -1 * xRange;
            const int xUpper = xRange;
            const int yLower = -1 * yRange;
            const int yUpper = yRange;

            var area = new Area(new InclusiveRange(xLower, xUpper), new InclusiveRange(yLower, yUpper));
            for (int x = xLower; x < xUpper; x++)
            {
                for (int y = yLower; y < yUpper; y++)
                {
                    var number = new Complex(x, y);

                    var calculatedPoint = area.GetPointFromNumber(resolution, number);
                    var calculatedNumber = area.GetNumberFromPoint(resolution, calculatedPoint);

                    Assert.AreEqual(number.Real, calculatedNumber.Real);
                    Assert.AreEqual(number.Imaginary, calculatedNumber.Imaginary);
                }
            }
        }
        public static int IsInSet(Complex c)
        {
            if (MandelbrotFinder.IsInSet(c))
            {
                return -1;
            }

            var rePrev = c.Real;
            var imPrev = c.Imaginary;

            double re = 0;
            double im = 0;

            for (int i = 0; i < Bailout; i++)
            {
                var reTemp = re * re - im * im + rePrev;
                im = 2 * re * im + imPrev;
                re = reTemp;

                var magnitudeSquared = re * re + im * im;
                if (magnitudeSquared > 4)
                {
                    return i;
                }
            }

            return -1;
        }
        protected override bool ValidatePoint(Complex point)
        {
            if (base.ValidatePoint(point))
            {
                return true;
            }

            return _edgeAreas.Any(a => a.IsInside(point));
        }
 protected override bool ValidatePoint(Complex point)
 {
     return !MandelbulbChecker.IsInsideBulbs(point);
 }
示例#5
0
        private IEnumerable<Complex> GetTrajectory(Complex c)
        {
            double re = 0;
            double im = 0;

            // Cache the squares
            // They are used to find the magnitude; reuse these values when computing the next re/im
            double re2 = 0;
            double im2 = 0;

            for (uint i = 0; i < _bailout; i++)
            {
                var reTemp = re2 - im2 + c.Real;
                im = 2 * re * im + c.Imaginary;
                re = reTemp;

                yield return new Complex(re, im);

                re2 = re * re;
                im2 = im * im;

                // Check the magnitude squared against 2^2
                if ((re2 + im2) > 4)
                {
                    yield break;
                }
            }
        }
 protected override bool ValidatePoint(Complex c, BailoutRange bailoutRange)
 {
     return MandelbrotFinder.IsInSet(c);
 }
示例#7
0
 protected abstract bool ValidatePoint(Complex c, BailoutRange bailoutRange);
 protected virtual bool ValidatePoint(Complex point)
 {
     return true;
 }