Ticket #23 (new defect)

Opened 5 years ago

Last modified 5 years ago

Circular integral equation doesn't work

Reported by: cgibbard Owned by:
Priority: major Milestone:
Version: Keywords:
Cc: cgibbard@…

Description

I wrote the following small demo. Note the circular relationship between the velocity and acceleration. Conal says this is supposed to work. The program produces the first frame of animation (managing to draw the black background and white disk), but then immediately freezes, and doesn't repaint itself.

import Control.Applicative
import Data.VectorSpace
import FRP.Reactive
import FRP.Reactive.GLUT.Adapter
import Graphics.FieldTrip
import FRP.Reactive.FieldTrip
import Data.Traversable (sequenceA)

main = anim2 myDisk

myDisk ui = motion . pure $ uscale2 (0.1 :: Double) *% udisk
  where motion = liftA2 (*%) (fmap translate2 (position ui))

position ui = integral (framePass ui) (velocity ui)

velocity ui = integral (framePass ui) (accel ui)

accel ui = liftA2 (^+^) (keyAccel ui) (fmap ((-0.1) *^) (velocity ui))

keyAccel :: Anim (Vector2 Double)
keyAccel ui = accumB zeroV . fmap f $ keyAction ui
  where f (Down, k) = (^+^ keyMotion k)
        f (Up, k)   = (^-^ keyMotion k)

arrowKeys :: UI -> Event (KeyState, Key)
arrowKeys = filterE ((`elem` map SpecialKey [KeyUp, KeyDown, KeyLeft, KeyRight]) . snd) . keyAction

keyMotion (SpecialKey KeyUp)    = vector2 0 1
keyMotion (SpecialKey KeyDown)  = vector2 0 (-1)
keyMotion (SpecialKey KeyLeft)  = vector2 (-1) 0
keyMotion (SpecialKey KeyRight) = vector2 1 0
keyMotion _ = zeroV

For reference, here's the GHCi log, which includes the version numbers of the packages involved. I got everything from Hackage.

GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main             ( ReactiveGame.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
Loading package syb ... linking ... done.
Loading package base-3.0.3.0 ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package containers-0.2.0.0 ... linking ... done.
Loading package old-locale-1.0.0.1 ... linking ... done.
Loading package old-time-1.0.0.1 ... linking ... done.
Loading package random-1.0.0.1 ... linking ... done.
Loading package filepath-1.1.0.1 ... linking ... done.
Loading package unix-2.3.1.0 ... linking ... done.
Loading package directory-1.0.0.2 ... linking ... done.
Loading package process-1.0.1.0 ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package QuickCheck-1.2.0.0 ... linking ... done.
Loading package mtl-1.1.0.2 ... linking ... done.
Loading package MemoTrie-0.4 ... linking ... done.
Loading package OpenGL-2.2.1.1 ... linking ... done.
Loading package GLUT-2.1.1.2 ... linking ... done.
Loading package graphicsFormats-0.1 ... linking ... done.
Loading package vector-space-0.5 ... linking ... done.
Loading package pretty-1.0.1.0 ... linking ... done.
Loading package Cabal-1.6.0.1 ... linking ... done.
Loading package bytestring-0.9.1.4 ... linking ... done.
Loading package editline-0.2.1.0 ... linking ... done.
Loading package hpc-0.5.0.2 ... linking ... done.
Loading package packedstring-0.1.0.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package ghc-6.10.1 ... linking ... done.
Loading package category-extras-0.53.5 ... linking ... done.
Loading package lazysmallcheck-0.3 ... linking ... done.
Loading package Stream-0.3 ... linking ... done.
Loading package TypeCompose-0.6.4 ... linking ... done.
Loading package FieldTrip-0.2.1 ... linking ... done.
Loading package checkers-0.1.3 ... linking ... done.
Loading package unamb-0.1.9 ... linking ... done.
Loading package reactive-0.10.5 ... linking ... done.
Loading package reactive-glut-0.1.6 ... linking ... done.
Loading package InfixApplicative-1.0.1 ... linking ... done.
Loading package reactive-fieldtrip-0.0.8 ... linking ... done.

Change History

Changed 5 years ago by cgibbard

  • cc cgibbard@… added
Note: See TracTickets for help on using tickets.