sims.engine2D.BlankApp

previous next


BlankApp lets you experiment building a rigid body simulation via scripting. It has a ContactSim, LabCanvas, SimView, Terminal and other objects already created. Below is a sample script to try by entering in Terminal.

NOTE: This will only work on simple-compiled versions of this app; advanced-compiled versions cannot execute JavaScript.

ELASTICITY=0.9;
SHOW_CLOCK=true;
Walls.make(sim,12,12,0.01);
var p=Shapes.makeBall(0.2,'fast_ball');
p.setMass(0.1);
p.setPosition(new Vector(-5, 0));
p.setVelocity(new Vector(200, 153));
p.setElasticity(0.9);
sim.addBody(p);
displayList.findShape(p).setFillStyle('green');
sim.saveInitialState();
app.addStandardControls();

A script can be provided in the query string of the URL (after the question mark) for this page. For example, the following URL contains the above script.

http://www.myphysicslab.com/develop/build/sims/engine2D/BlankApp_en.html?ELASTICITY=0.9;
SHOW_CLOCK=true;Walls.make(sim,12,12,0.01);var%20p=Shapes.makeBall(0.2,'fast_ball');
p.setMass(0.1);p.setPosition(new Vector(-5,0));p.setVelocity(new Vector(200,153));
p.setElasticity(0.9);sim.addBody(p);displayList.findShape(p).setFillStyle('green');
sim.saveInitialState();app.addStandardControls();

Because of percent-encoding we must substitute in the URL:

See this character encoding chart to learn which other characters must be percent-encoded.

This page is for testing and development please see myPhysicsLab for the published version of this simulation.

Valid HTML 4.01