I write a program to visulize the electron cloud of hydrogen atom.
import System.Exit
import Graphics.UI.GLUT
probDensity :: Double -> Double
probDensity r = abs $ (1 - r) * exp (-r/2.0)
myInit :: IO ()
myInit = clearColor $= Color4 1 1 1 0
grid :: [(GLint,GLint)]
grid = [(x,y) | x <- [-200..200],y <- [-200..200]]
density :: [Double]
density = map (\(i',j') -> probDensity $ sqrt $ (fromIntegral i' ** 2 + fromIntegral j' ** 2 ) / 324) grid
cloud = zip density grid
display :: DisplayCallback
display = do
clear [ColorBuffer]
color $ Color4 1 1 1 (0::GLfloat)
renderPrimitive Points $
mapM_ (\(c,(x,y)) -> color (Color3 c c 0) >> vertex (Vertex2 x y)) cloud
flush
idle :: IdleCallback
idle =
postRedisplay Nothing
reshape :: ReshapeCallback
reshape (Size _ _) = do
viewport $= (Position 0 0, Size 400 400)
matrixMode $= Projection
loadIdentity
ortho2D (-200.0) 200.0 (-200.0) 200.0
matrixMode $= Modelview 0
loadIdentity
keyboard :: KeyboardMouseCallback
keyboard (Char '\27') Down _ _ = exitSuccess
keyboard _ _ _ _ = return ()
main :: IO ()
main = do
(_, _args) <- getArgsAndInitialize
initialDisplayMode $= [ RGBMode ]
initialWindowSize $= Size 400 400
initialWindowPosition $= Position 100 100
_ <- createWindow "Cloud"
shadeModel $= Smooth
myInit
displayCallback $= display
reshapeCallback $= Just reshape
keyboardMouseCallback $= Just keyboard
idleCallback $= Just idle
mainLoop
But the result has many lines on the right part of the graph.
I checked my code again and again and could not find any faults. Is this a bug of the package?