packages feed

not-gloss-examples (empty) → 0.1

raw patch · 6 files changed

+162/−0 lines, 6 filesdep +basedep +not-glossdep +spatial-mathsetup-changed

Dependencies added: base, not-gloss, spatial-math

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2012, Greg Horn++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Greg Horn nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ not-gloss-examples.cabal view
@@ -0,0 +1,38 @@+name:                not-gloss-examples+version:             0.1+stability:           Experimental+synopsis:            examples for not-gloss+license:             BSD3+license-file:        LICENSE+author:              Greg Horn+maintainer:          gregmainland@gmail.com+-- copyright:           +category:            Graphics+build-type:          Simple+cabal-version:       >=1.8++executable           not-gloss-display+  main-is:           src/Display.hs+  build-depends:     not-gloss == 0.3.*,+                     spatial-math == 0.1.*,+                     base == 4.5.*+  ghc-options:       -threaded -O2++executable           not-gloss-animate+  main-is:           src/Animate.hs+  build-depends:     not-gloss == 0.3.*,+                     spatial-math == 0.1.*,+                     base == 4.5.*+  ghc-options:       -threaded -O2++executable           not-gloss-simulate+  main-is:           src/Simulate.hs+  build-depends:     not-gloss == 0.3.*,+                     spatial-math == 0.1.*,+                     base == 4.5.*+  ghc-options:       -threaded -O2+++source-repository head+  type:     git+  location: git://github.com/ghorn/not-gloss-examples.git
+ src/Animate.hs view
@@ -0,0 +1,28 @@+{-# OPTIONS_GHC -Wall #-}++module Main where++import SpatialMath+import qualified Quat++import Vis++drawFun :: Float -> VisObject Double+drawFun time = VisObjects $ [axes,box,ellipsoid,sphere] ++ (map text [-5..5]) ++ [boxText, plane] +  where+    x = realToFrac $ -1 + sin (2*time)+    quat = Quat.normalize $ Quat 1 x (1-x) (x*x)+    +    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)+    ellipsoid = VisEllipsoid (0.2, 0.3, 0.4) (Xyz x 0 (-1)) quat Solid (makeColor 1 0.3 0.5 1)+    box = VisBox (0.2, 0.2, 0.2) (Xyz 0 0 x) quat Wireframe (makeColor 0 1 1 1)+    plane = VisPlane (Xyz 0 0 1) 0 (makeColor 1 1 1 1) (makeColor 0.4 0.6 0.65 0.4)+    text k = Vis2dText "OLOLOLOLOLO" (100,500 - k*100*x) TimesRoman24 (makeColor 0 (0.5 + x'/2) (0.5 - x'/2) 1)+      where+        x' = realToFrac $ (x + 1)/0.4*k/5+    boxText = Vis3dText "trololololo" (Xyz 0 0 (x-0.2)) TimesRoman24 (makeColor 1 0 0 1)++main :: IO ()+main = do+  animate drawFun
+ src/Display.hs view
@@ -0,0 +1,28 @@+{-# OPTIONS_GHC -Wall #-}++module Main where++import SpatialMath+import qualified Quat++import Vis++drawFun :: VisObject Double+drawFun = VisObjects $ [axes,box,ellipsoid,sphere] ++ (map text [-5..5]) ++ [boxText, plane] +  where+    x = -1+    quat = Quat.normalize $ Quat 1 2 3 4+    +    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)+    ellipsoid = VisEllipsoid (0.2, 0.3, 0.4) (Xyz x 0 (-1)) quat Solid (makeColor 1 0.3 0.5 1)+    box = VisBox (0.2, 0.2, 0.2) (Xyz 0 0 x) quat Wireframe (makeColor 0 1 1 1)+    plane = VisPlane (Xyz 0 0 1) 0 (makeColor 1 1 1 1) (makeColor 0.4 0.6 0.65 0.4)+    text k = Vis2dText "OLOLOLOLOLO" (100,500 - k*100*x) TimesRoman24 (makeColor 0 (0.5 + x'/2) (0.5 - x'/2) 1)+      where+        x' = realToFrac $ (x + 1)/0.4*k/5+    boxText = Vis3dText "trololololo" (Xyz 0 0 (x-0.2)) TimesRoman24 (makeColor 1 0 0 1)++main :: IO ()+main = do+  display drawFun
+ src/Simulate.hs view
@@ -0,0 +1,36 @@+{-# OPTIONS_GHC -Wall #-}++module Main where++import SpatialMath+import qualified Quat++import Vis++ts :: Double+ts = 0.01++data State a = State (a,a) (Quat 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)+  where+    dq = Quat 1 (x*ts) (v*ts) (x*v*ts)++drawFun :: State Double -> VisObject Double+drawFun (State (x,_) quat) = VisObjects $ [axes,box,ellipsoid,sphere] ++ (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)+    ellipsoid = VisEllipsoid (0.2, 0.3, 0.4) (Xyz x 0 (-1)) quat Solid (makeColor 1 0.3 0.5 1)+    box = VisBox (0.2, 0.2, 0.2) (Xyz 0 0 x) quat Wireframe (makeColor 0 1 1 1)+    plane = VisPlane (Xyz 0 0 1) 0 (makeColor 1 1 1 1) (makeColor 0.4 0.6 0.65 0.4)+    text k = Vis2dText "OLOLOLOLOLO" (100,500 - k*100*x) TimesRoman24 (makeColor 0 (0.5 + x'/2) (0.5 - x'/2) 1)+      where+        x' = realToFrac $ (x + 1)/0.4*k/5+    boxText = Vis3dText "trololololo" (Xyz 0 0 (x-0.2)) TimesRoman24 (makeColor 1 0 0 1)++main :: IO ()+main = do+  let state0 = State (-1.4,0) (Quat 1 0 0 0)+  simulate ts state0 drawFun simFun