From 361aa988bc419c472fb6df5b6291ef2285f63d0b Mon Sep 17 00:00:00 2001 From: Pavle Portic Date: Sun, 3 Feb 2019 14:44:35 +0100 Subject: [PATCH] Optimize calculation for points that are on the main cardioid and bulb --- mandelbrot.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mandelbrot.py b/mandelbrot.py index 93f1f60..5ff0bc7 100644 --- a/mandelbrot.py +++ b/mandelbrot.py @@ -36,6 +36,12 @@ def get_points(cols, rows): def calculate_point(x, y): global ITERATIONS z = 0 + p = (x - 0.25) ** 2 + y ** 2 + if p * (p + (x - 0.25)) < 0.25 * (y ** 2): + return -1 + if (x + 1) ** 2 + y ** 2 <= 0.0625: + return -1 + for i in range(MAX_ITERS): ITERATIONS += 1 z = z ** 2 + complex(x, y)