[Haskell-cafe] Netwire bouncing ball

Oliver Charles ollie at ocharles.org.uk
Fri Jul 12 00:02:32 CEST 2013


On 07/11/2013 05:52 PM, Just wrote:
> On 07/10/2013 11:44 PM, Ertugrul Söylemez wrote:
>> 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.
> 
> Thank you very much, this works as expected and is easy to understand.
> However a complete example of a bouncing ball would be super awesome
> since I have trouble to get it work with integralLim_.
> 
> My first try was to use object_ from Control.Wire.Prefab.Move but got
> stuck very quickly.
> 
> I think this would be a good addition to the quickstart tutorial.

It would indeed be a fantastic addition - this is almost exactly what I
was trying to do as my example netwire project. For a bit more support,
I was trying to move a point from x=0 to x=10, and then back to x=0 -
and so on. I got as far as getting to x=10, but then had no idea how to
reverse the direction and make the whole thing cycle. I was told to read
about ArrowLoop, but sadly I never got much further.

- ollie

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130711/1be20e77/attachment.pgp>


More information about the Haskell-Cafe mailing list