[Haskell-cafe] Netwire bouncing ball
es at ertes.de
Wed Jul 10 23:44:47 CEST 2013
Just <haskell at justnothing.org> wrote:
> I'm trying to get a grasp of netwire by implementing a bouncing ball
> simulation and I'm failing.
> The ball starts from the ground with a given velocity and when hitting
> the ground the wire inhibits successfully. Now I'm kinda stuck.
> How can I make the ball bounce?
A very simple way to do this is to use integralLim_ instead of
integral_. It allows the ball itself to handle the bouncing. A less
invasive way (i.e. you can add it to your example) is to use the (-->)
ball = integral_ 0 . integral_ 40 . (-9.8)
aboveGround = require (>= 0)
bouncingBall = aboveGround . ball --> bouncingBall
While this gives you a bouncing ball, the ball will not follow real
physics. Once the ball hits the ground, it will just start over with
its original velocity. integralLim_ is the correct solution.
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: not available
More information about the Haskell-Cafe