Title: ElastoLab A Physics Playground for Kids
1ElastoLabA Physics Playground for Kids
- David Buck
- Simberon Inc.
- www.simberon.com
2History
- Started as a Masters thesis 1990 Smalltalk
- Re-wrote in C (1993)
- Close to release (1996)
- Rewrote in Smalltalk (1998)
- Released for sale (2001)
- Physics re-written in Smalltalk (2002)
3Demo
4Physics
- How do you simulate physics?
- Easy
- Calculate the forces on each particle.
- a F/m
- Add a bit of the acceleration to the velocity
- Add a bit of the velocity to the position
- Repeat
- Eulers method
5Problem
- Falling particles work great
- Springs explode when the strength gets too high
6Solution Runge Kutta
- Calculate forces 4 times, combine results.
7Better
- But really strong springs still explode.
- Solution Adaptive Runge Kutta
- Adapt step size according to error between single
and double steps.
8Barriers
- Easy you just reflect the particles position
and velocity by the barrier
9Umm Problem
- Springs explode and rigid bodies dont spin.
- Solution Step forward to the time of collision
then apply an impulse to the particle
10What time is the collision?
- How do we know what time the particle hit?
- What if many particles hit around the same time
which hit first?
11Solution
- Use Bisection Method to narrow down time of first
collision.
12Resting Contact?
- What happens if the particle is sitting on the
barrier? Collision time is almost zero.
13Dynamic Constraints
- Detect resting contacts and add a dynamic
constraint force. - The constraint force is a force just strong
enough to prevent the particle from penetrating
the barrier.
Constraint Force
Net Force
14Multiple resting contacts
- What happens if a particle is in resting contact
with two or more barriers?
15Solution
- Use Quadratic Programming or Baraff 94
- ltunclegt
- Ok, just stop the particle and hope nobody
notices.
16User Interface
- Every physics object has a corresponding
Display object. - A Camera defines the transformation from world
to display and back. - Clipping implemented for lines and polygons.
17Custom Widgets
- Custom widgets enhance the appearance of
ElastoLab.
18Interfacing to Sound
- Smalltalk calls a C DLL I wrote
- The C DLL calls the COM interface to access the
DirectX 8 sound facilities.
19Help Facilities
- Three kinds of help
- Fly by help
- Help mode Windows help files
- Guided tour
20Guided Tour
21Source Code Management
- For C, I just made copies of the source files.
- Smalltalk StORE using a Postgres database.
- ElastoLab consists of 2 bundles, 15 packages, 300
classes.
22Making it Fast
- Displaying bitmaps works much faster if you use
convertForGraphicsDevice and cache the result. - High level optimizations better than low level
optimizations
23Packaging
- Runtime Packager used for stripping image.
- ResHacker used to create one executable.
- InstallShield Express used to install.
24Message Board
- Online message board runs on Web Toolkit.
- SSL pages link to Smalltalk servlets
- Small app (4 classes)
25Wrap Up
- Smalltalk is quite fast enough to handle
ElastoLab. - Flexibility of Smalltalk is a big advantage.
- Packaging can create a single executable that
fits into the Windows environment. - SSP pages and Smalltalk servlets can be used to
build community with a message board.