Bounce Example

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Bounce Example

summae3443

Hello,

 

I once saw a workspace example which caused a morph to move along an arc in a realistic way - appearing to be affected by gravity. Possibly written by someone from Disney?  Now I search in vain to find it. Please give me a reference.

 

- Dan


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

RE: Bounce Example

Ron Teitelbaum

Hi Dan,

 

Maybe you are looking for Takashi-san’s ODECo?

 

http://languagegame.org:8080/ggame/15

 

Alan Kay uses a bouncing ball all the time in his talks.  He does a nice example of a bouncing ball that deforms.  And he does it while its bouncing.  Very cool video. https://plus.google.com/113828454523913869336/posts/GU89wzvFTY6

 

Here is a really cool paper that shows you all the tools you need are really right there in Morphic.  http://www.vpri.org/pdf/rn2005001_learning.pdf

 

If you know the laws of physics you can model them.

 

All the best,

 

Ron Teitelbaum

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email]
Sent: Wednesday, November 19, 2014 10:15 PM
To: beginners
Subject: [Newbies] Bounce Example

 

Hello,

 

I once saw a workspace example which caused a morph to move along an arc in a realistic way - appearing to be affected by gravity. Possibly written by someone from Disney?  Now I search in vain to find it. Please give me a reference.

 

- Dan


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Bounce Example

dcorking
Ron Teitelbaum  wrote:

> If you know the laws of physics you can model them.

Right! Squeak is a great place to model or even break the laws of physics.

Here is a great set of Squeak Etoys for NASA from physics professor Randy Caton

http://www.pcs.cnu.edu/~rcaton/SqIndex/squeakindex.html

Etoys isn't the Smalltalk workspace, but the simple tile scripting
language built into Squeak.

Here are more Etoys on physics, but you don't need to be a Squeak
Central or NASA guru to make them, as I show in Free Fall.

Particle Gas Model (Yoshiki Ohshima)
http://squeakland.org/showcase/project.jsp?id=7430
Ball Drop Analysis 1 (Alan Kay)
http://squeakland.org/showcase/project.jsp?id=7425
Collision Physics (Bert Freudenberg)
http://squeakland.org/showcase/project.jsp?id=7052
Lunar Lander Game (Alan Kay)  http://squeakland.org/showcase/project.jsp?id=7424
Free Fall (David Corking) http://www.squeakland.org/showcase/project.jsp?id=9709

Have fun!
David
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Bounce Example

Bert Freudenberg
In reply to this post by summae3443
On 20.11.2014, at 04:14, <[hidden email]> <[hidden email]> wrote:

> Hello,
>
>  
> I once saw a workspace example which caused a morph to move along an arc in a realistic way - appearing to be affected by gravity. Possibly written by someone from Disney?  Now I search in vain to find it. Please give me a reference.

Morphic is not really set up for workspace-style programming. It assumes you will create your own morph class and implement methods to specify behavior.

It's certainly possible to do. But you will run into various problems that you wouldn't have if you did it properly.

That said, try the following. Assuming constant mass and gravity, the acceleration is constant (since F = ma).

m := Morph new openInWorld.
m position: World center.
speed := 5 @ 0. "move horizontally at start"
acceleration := 0 @ 1. "accelerate downwards"
move := [m owner ifNotNil: [
        "Acceleration is a 2nd-order (quadratic) function. Physics and Math FTW"
        speed := speed + acceleration. "accel is 1st derivative of speed"
        m position: m position + speed. "speed is 1st derivative of pos"
        m left < m owner left ifTrue: [speed := speed x abs @ speed y]. "bounce"
        m right > m owner right ifTrue: [speed := speed x abs negated @ speed y].
        m top < m owner top ifTrue: [speed := speed x @ speed y abs].
        m bottom > m owner bottom ifTrue: [speed := speed x @ speed y abs negated].
        (move future: 20) value. "repeat every 20ms"
]].
move value. "first step"

For even more fun you could control the morph with a joystick:

        j := JoystickMorph new openInWorld.

And insert this inside the move block:

        acceleration := (j leftRight @ j upDown negated) * 0.1.

Have fun!

- Bert -



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Bounce Example

summae3443
In reply to this post by summae3443
Many thanks to Bert, David, and Ron!

Bert wins the prize for being closest to what I saw.
This I can work with.

- Dan
-----Original Message-----

>From: Bert Freudenberg <[hidden email]>
>Sent: Nov 20, 2014 9:52 AM
>To: "A friendly place to get answers to even the most basic questions about
> Squeak." <[hidden email]>
>Subject: Re: [Newbies] Bounce Example
>
>On 20.11.2014, at 04:14, <[hidden email]> <[hidden email]> wrote:
>
>> Hello,
>>
>>  
>> I once saw a workspace example which caused a morph to move along an arc in a realistic way - appearing to be affected by gravity. Possibly written by someone from Disney?  Now I search in vain to find it. Please give me a reference.
>
>Morphic is not really set up for workspace-style programming. It assumes you will create your own morph class and implement methods to specify behavior.
>
>It's certainly possible to do. But you will run into various problems that you wouldn't have if you did it properly.
>
>That said, try the following. Assuming constant mass and gravity, the acceleration is constant (since F = ma).
>
>m := Morph new openInWorld.
>m position: World center.
>speed := 5 @ 0. "move horizontally at start"
>acceleration := 0 @ 1. "accelerate downwards"
>move := [m owner ifNotNil: [
> "Acceleration is a 2nd-order (quadratic) function. Physics and Math FTW"
> speed := speed + acceleration. "accel is 1st derivative of speed"
> m position: m position + speed. "speed is 1st derivative of pos"
> m left < m owner left ifTrue: [speed := speed x abs @ speed y]. "bounce"
> m right > m owner right ifTrue: [speed := speed x abs negated @ speed y].
> m top < m owner top ifTrue: [speed := speed x @ speed y abs].
> m bottom > m owner bottom ifTrue: [speed := speed x @ speed y abs negated].
> (move future: 20) value. "repeat every 20ms"
>]].
>move value. "first step"
>
>For even more fun you could control the morph with a joystick:
>
> j := JoystickMorph new openInWorld.
>
>And insert this inside the move block:
>
> acceleration := (j leftRight @ j upDown negated) * 0.1.
>
>Have fun!
>
>- Bert -
>
>

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners