diff options
| author | citrons <citrons@mondecitronne.com> | 2025-08-01 21:08:00 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2025-08-01 21:08:00 -0500 |
| commit | 97e0ca7f099fedfd7ee41c2f0ad4f5a443b70579 (patch) | |
| tree | 45b5745c030c42999de198e3bc9300c237af4990 /mandelbrot.lua | |
Diffstat (limited to 'mandelbrot.lua')
| -rw-r--r-- | mandelbrot.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mandelbrot.lua b/mandelbrot.lua new file mode 100644 index 0000000..a94f46f --- /dev/null +++ b/mandelbrot.lua @@ -0,0 +1,21 @@ +local bignum = require "bignum" + +local M = {} + +local function sq(x, y) + return x*x - y*y, 2 * x * y +end + +function M.orbit(iter, x, y) + local o = {} + local zx, zy = bignum.float(0, 32), bignum.float(0, 32) + for i = 1, iter do + local rx, ry = bignum.tonumber(zx), bignum.tonumber(zy) + table.insert(o, {rx, ry}) + zx, zy = sq(zx, zy) + zx, zy = zx + x, zy + y + end + return o +end + +return M |
