Just <hask...@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 (-->)
combinator:

    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.


Greets,
Ertugrul

-- 
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.

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to