elastolab a physics playground for kids david buck simberon inc

25
ElastoLab A Physics Playground for Kids David Buck Simberon Inc. www.simberon.com

Upload: jacob-leslie-malone

Post on 18-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

ElastoLabA Physics Playground for Kids

David BuckSimberon Inc.

www.simberon.com

History

• Started as a Master’s 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)

Demo

Physics

• 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– Euler’s method

Problem

• Falling particles work great• Springs explode when the

strength gets too high

Solution: Runge Kutta

• Calculate forces 4 times, combine results.

Better

• But really strong springs still explode.• Solution: Adaptive Runge Kutta• Adapt step size according to error

between single and double steps.

Barriers

• Easy – you just reflect the particle’s position and velocity by the barrier

Umm… Problem

• Springs explode and rigid bodies don’t spin.

• Solution: Step forward to the time of collision then apply an impulse to the particle

What 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?

Solution

• Use Bisection Method to narrow down time of first collision.

Resting Contact?

• What happens if the particle is sitting on the barrier? Collision time is almost zero.

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

Net Force

Constraint Force

Multiple resting contacts

• What happens if a particle is in resting contact with two or more barriers?

Solution

• Use Quadratic Programming or Baraff [94]

• <uncle>• Ok, just stop the particle and

hope nobody notices.

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

Custom Widgets

• Custom widgets enhance the appearance of ElastoLab.

Interfacing to Sound

• Smalltalk calls a C DLL I wrote• The C DLL calls the COM

interface to access the DirectX 8 sound facilities.

Help Facilities

• Three kinds of help– Fly by help– Help mode – Windows help files– Guided tour

Guided Tour

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

Making it Fast

• Displaying bitmaps works much faster if you use convertForGraphicsDevice: and cache the result.

• High level optimizations better than low level optimizations

Packaging

• Runtime Packager used for stripping image.

• ResHacker used to create one executable.

• InstallShield Express used to install.

Message Board

• Online message board runs on Web Toolkit.

• SSL pages link to Smalltalk servlets

• Small app (4 classes)

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