Created
February 26, 2020 17:15
-
-
Save mechamug/d1415f57e673e935976cc8ef399cf4c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countIterations(x, y) { | |
var count = 0; | |
var t = x; | |
x=-y; | |
y=t; | |
var zx = x; | |
var zy = y; | |
var n = 100; | |
var p = 200; | |
while (count < maxIterations && zx*zx + zy*zy < 20) { | |
if (0==(count+1)%n) { | |
x += zx*count/p; | |
y += zy*count/p; | |
n--; | |
p++; | |
} | |
var new_zx = zx*zx - zy*zy + x; | |
zy = 2*zx*zy + y; | |
zx = new_zx; | |
count++; | |
} | |
return count < maxIterations ? count : Math.floor((Math.atan(zy/zx)+Math.PI/2)/Math.PI*count); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment