
In these images, I've plotted the real and imaginary components along the x and y axes respectively. But the more popular way to visualize this attractor adds an extra parameter to the system and is expressed in trigonometric functions. Such adaptation of the code below yields these results.
This file contains 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
{-# LANGUAGE NoMonomorphismRestriction #-} | |
import Data.Complex | |
import Graphics.UI.SDL as SDL | |
(xRes, yRes) = (1366, 768) | |
[a, b, k, p] = [0.85, 0.9, 0.4, 7.7] | |
main = withInit [InitVideo] $ do | |
w <- setVideoMode xRes yRes 32 [NoFrame] | |
s <- createRGBSurface [] 1 1 32 0 0 0 0 | |
fillRect s Nothing $ Pixel 0xFFFFFF | |
enableEvent SDLMouseMotion False | |
setCaption "Ikeda" "Ikeda" | |
render w s $ ikeda $ 0 :+ 0 | |
SDL.flip w | |
run w | |
run w = do | |
e <- pollEvent | |
delay 64 | |
case e of | |
KeyUp (Keysym SDLK_ESCAPE _ _) -> return () | |
_ -> run w | |
render w s = mapM_ draw | |
where | |
rect (x,y) = Just $ Rect (round x) (round y) 1 1 | |
g (x,y) = (x + xRes / 24, y + yRes / 2.25) | |
draw z = blitSurface s Nothing w $ rect $ g p | |
where | |
p = (1050 * realPart z, 1050 * imagPart z) | |
ikeda = take 1500000 . filter g . iterate f | |
where | |
f z = a + b * z * exp(i * (k-p) * (1 + abs z^2)) | |
i = 0 :+ 1 | |
g (r:+i) = -35 < r && r < 35 && -18 < i && i < 18 |