packages feed

not-gloss-examples 0.2 → 0.2.1

raw patch · 2 files changed

+17/−9 lines, 2 filesdep ~not-gloss

Dependency ranges changed: not-gloss

Files

not-gloss-examples.cabal view
@@ -1,5 +1,5 @@ name:                not-gloss-examples-version:             0.2+version:             0.2.1 stability:           Experimental synopsis:            examples for not-gloss license:             BSD3@@ -13,28 +13,28 @@  executable           not-gloss-display   main-is:           src/Display.hs-  build-depends:     not-gloss == 0.4.*,+  build-depends:     not-gloss >= 0.4.1,                      spatial-math >= 0.1.4 && < 0.2,                      base == 4.5.*   ghc-options:       -threaded -O2  executable           not-gloss-animate   main-is:           src/Animate.hs-  build-depends:     not-gloss == 0.4.*,+  build-depends:     not-gloss >= 0.4.1,                      spatial-math >= 0.1.4 && < 0.2,                      base == 4.5.*   ghc-options:       -threaded -O2  executable           not-gloss-simulate   main-is:           src/Simulate.hs-  build-depends:     not-gloss == 0.4.*,+  build-depends:     not-gloss >= 0.4.1,                      spatial-math >= 0.1.4 && < 0.2,                      base == 4.5.*   ghc-options:       -threaded -O2  executable           not-gloss-game   main-is:           src/Play.hs-  build-depends:     not-gloss == 0.4.*,+  build-depends:     not-gloss >= 0.4.1,                      spatial-math >= 0.1.4 && < 0.2,                      GLUT == 2.3.*,                      containers == 0.4.*,
src/Simulate.hs view
@@ -10,15 +10,19 @@ ts :: Double ts = 0.01 -data State a = State (a,a) (Quat a)+data State a = State (a,a) (Quat a) [Xyz a]  simFun :: Float -> State Double -> State Double-simFun _ (State (x,v) q0) = State (x + v*ts, v + 5*ts*(-1 - x)) (Quat.qmult' q0 dq)+simFun _ (State (x0,v) q0 trail0) = State (x, v + 5*ts*(-1 - x)) (Quat.qmult' q0 dq) trail   where     dq = Quat 1 (x*ts) (v*ts) (x*v*ts)+    x = x0 + v*ts+    trail+      | length trail0 < 75 = (Xyz 0 x (-1)):trail0+      | otherwise = take 75 ((Xyz 0 x (-1)):trail0)  drawFun :: State Double -> VisObject Double-drawFun (State (x,_) quat) = VisObjects $ [axes,box,ellipsoid,sphere] ++ (map text [-5..5]) ++ [boxText, plane] +drawFun (State (x,_) quat trail) = VisObjects $ [axes,box,ellipsoid,sphere, line] ++ (map text [-5..5]) ++ [boxText, plane]    where     axes = VisAxes (0.5, 15) (Xyz 0 0 0) (Quat 1 0 0 0)     sphere = VisSphere 0.15 (Xyz 0 x (-1)) Wireframe (makeColor 0.2 0.3 0.8 1)@@ -29,8 +33,12 @@       where         x' = realToFrac $ (x + 1)/0.4*k/5     boxText = Vis3dText "trololololo" (Xyz 0 0 (x-0.2)) TimesRoman24 (makeColor 1 0 0 1)+    line = VisLine' $ zip trail (map (\a -> makeColor 1 0 0 a) (linspace 1 0 (length trail))) -- (makeColor 1 0 0 1) +linspace :: Fractional a => a -> a -> Int -> [a]+linspace x0 xf n = map (\k -> x0 + (xf - x0) * (fromIntegral k) / (fromIntegral n-1)) [0..(n-1)]+ main :: IO () main = do-  let state0 = State (-1.4,0) (Quat 1 0 0 0)+  let state0 = State (-1.4,0) (Quat 1 0 0 0) []   simulate ts state0 drawFun simFun