
Here's an unusual chaotic attractor: the web doesn't seem to have much information on this one, except that it was invented to model particle trajectories in physics. A google image search for 'mira fractals' does turn up some pretty results though.
The system seems to give interesting results only when b is close to one. It behaves less chaotically when b > 1 is fixed, so you can actually animate it - click the thumbnail to see.
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
import Control.Arrow ((***)) | |
import Graphics.UI.SDL as SDL | |
(xres, yres) = (200, 200) | |
main = withInit [InitVideo] $ do | |
w <- setVideoMode xres yres 32 [NoFrame] | |
enableEvent SDLMouseMotion False | |
setCaption "Gumowski-Mira" "Gumowski-Mira" | |
loop w p pss | |
where | |
p = (xres `div` 2, yres `div` 2) | |
pss = map points [0.31, 0.3101.. 0.316] | |
loop w p pss = do | |
render w p $ map (round *** round) $ head pss | |
e <- pollEvent | |
case e of | |
KeyUp (Keysym SDLK_ESCAPE _ _) -> return () | |
_ -> loop w p $ tail pss | |
render w (x,y) ps = do | |
s <- createRGBSurface [SWSurface] 2 2 32 0 0 0 0 | |
fillRect w (Just $ Rect 0 0 xres yres) (Pixel 0) | |
mapM_ (draw s 0xFFFFFF . rect . center) ps | |
SDL.flip w | |
where | |
center = ((xres - x) +) *** (+ (yres - y)) | |
rect (x,y) = Just $ Rect x y 1 1 | |
draw s c p = do fillRect s Nothing $ Pixel c | |
blitSurface s Nothing w p | |
points a = take 650000 . map (h *** h) $ iterate f (12, 0) | |
where | |
f (x,y) = let x' = b*y + g x in (x', -x + g x') | |
g x = a*x + (2 * (1 - a) * x^2) / (1 + x^2) | |
(b,h) = (1.005, (* 4)) |
No comments:
Post a Comment