예제 #1
0
        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);
        }
예제 #2
0
        private Tuple <Point, Color> PickColorForPoint(Point point, Area viewPort, Size resolution, bool checkForEdges, IEnumerable <Area> areasToInclude)
        {
            var number = viewPort.GetNumberFromPoint(resolution, point);
            var color  = PickColor(
                () => checkForEdges && areasToInclude.Any(a => a.IsInside(number)),
                () => MandelbrotFinder.IsInSet(number),
                () => MandelbulbChecker.IsInsideBulbs(number));

            return(Tuple.Create(point, color));
        }