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 Data.List (unfoldr) | |
-- dy/dx = f | |
f x y = - a * y | |
-- パラメータ | |
a = 1 | |
-- 区間と初期値 | |
x0 = 0 | |
x1 = 5 | |
y0 = 1 |
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 Data.List (unfoldr) | |
-- dx/dt = f | |
f t x v = v | |
-- dv/dt = g | |
g t x v = - om2 * x | |
-- パラメータ | |
om = 2 | |
om2 = om ** 2 | |
-- 区間と初期値 |
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 Graphics.UI.GLUT | |
display :: DisplayCallback | |
display = do | |
clear [ColorBuffer] | |
flush | |
main :: IO () | |
main = do | |
getArgsAndInitialize |
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 Graphics.UI.GLUT | |
display :: DisplayCallback | |
display = do | |
clear [ColorBuffer] | |
color (Color3 0 0 0 :: Color3 GLdouble) | |
renderPrimitive Lines $ mapM_ vertex2d [ | |
Vertex2 (-0.9) (-0.9) | |
, Vertex2 0.9 0.9 | |
] |
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 Graphics.UI.GLUT | |
display :: DisplayCallback | |
display = do | |
clear [ColorBuffer] | |
color (Color3 0 0 0 :: Color3 GLdouble) | |
renderPrimitive LineLoop $ mapM_ vertex2d [ | |
Vertex2 0 0 | |
, Vertex2 0.3 0 | |
, Vertex2 0.3 0.4 |
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 Graphics.UI.GLUT | |
display :: DisplayCallback | |
display = do | |
clear [ColorBuffer] | |
color (Color3 0 0 0 :: Color3 GLdouble) | |
renderPrimitive LineLoop $ mapM_ vertex2d [ | |
Vertex2 (-0.9) (-0.9) | |
, Vertex2 0.9 (-0.9) | |
, Vertex2 0.9 0.9 |
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 Graphics.UI.GLUT | |
display :: DisplayCallback | |
display = do | |
clear [ColorBuffer] | |
color (Color3 0 0 0 :: Color3 GLdouble) | |
renderPrimitive LineLoop $ mapM_ vertex2d [Vertex2 (0.5*cos t) (0.5*sin t) | t <- [0,0.01..2*pi]] | |
flush | |
where | |
vertex2d = vertex :: Vertex2 GLdouble -> IO () |
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 Graphics.UI.GLUT | |
display :: DisplayCallback | |
display = do | |
clear [ColorBuffer] | |
color (Color3 0 0 0 :: Color3 GLdouble) | |
renderPrimitive Polygon $ mapM_ vertex2d [ | |
Vertex2 (-0.9) (-0.9) | |
, Vertex2 0.9 (-0.9) | |
, Vertex2 0.9 0.9 |
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 Graphics.UI.GLUT | |
import Data.IORef | |
display :: IORef GLdouble -> DisplayCallback | |
display rot = do | |
clear [ColorBuffer] | |
r <- get rot | |
loadIdentity | |
rotate r $ Vector3 0 1 0 | |
color (Color3 0 0 0 :: Color3 GLdouble) |
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 Graphics.UI.GLUT | |
import Data.IORef | |
cubeVertex :: [Vertex3 GLdouble] | |
cubeVertex = [ Vertex3 0 0 0 | |
, Vertex3 1 0 0 | |
, Vertex3 1 1 0 | |
, Vertex3 0 1 0 | |
, Vertex3 0 0 1 | |
, Vertex3 1 0 1 |