open Prelude
let niter = 32
let limit = 4.0
let burning_ship z x y =
let cr = 2.0 *. float x /. z -. 2.1 in
let ci = 2.0 *. float y /. z -. 1.8 in
let rec aux i zr zi = if i >= niter then 0 else
let nzr = absf (zr *. zr -. zi *. zi +. cr)
and nzi = 2.0 *. absf (zr *. zi +. ci) in
if nzr *. nzr +. nzi *. nzi > limit then niter-i
else aux (i+1) nzr nzi in
aux 0 0.0 0.0
let pbinit2D f w h = pbinit (fun i -> let y,x = quot_rem i w in f x y) (w*h)
let draw_fractal z w h = pbinit2D (burning_ship (float z *. 0.8)) w h
let pgm_fractal w h = sprintf "P5 %i %i %i\n" w h niter ^ draw_fractal (min w h) w h
let () = print_string @@ pgm_fractal (parseInt Sys.argv.(1)) (parseInt Sys.argv.(2))
art with code
2008-09-02
Almost Burning Ship
Have an almost Burning Ship fractal.
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2008
(107)
-
▼
September
(17)
- I/O in programming languages: open and read
- Basics of I/O
- Building an OCaml array library from basic operations
- A month and a half of iPhone 3G
- Gitbug - In-repo bug tracker for git
- prelude.ml: now on GitHub
- Slow-motion Missile Fleet
- prelude.ml: further modularization
- prelude.ml: more combinatorial wanking
- prelude.ml: range iterators
- "Shared Memory" Parallelism
- Non-copying forked workers using Bigarrays
- Constant-space parallel combinators in OCaml
- Haskell on parallel hardware
- Almost Burning Ship
- Adaptive blur filter Mandelbrot
- Prelude.ml - more multicore mandelbrot
-
▼
September
(17)
No comments:
Post a Comment