Webphysics

Physics playground - just for fun!


Project maintained by RodrigoCastiel Hosted on GitHub Pages — Theme by mattgraham

Introduction

Webphysics is what I've done during a winter week in Minnesota (just for fun). It features a basic 2d-physics simulation for particles, springs, dampers, elastic ropes and meshes. There are 6 main modes (5 of which were implemented) that allow to add particles, connectors, elastic ropes and meshes. The gravity is computed by a summation of gravitational fields (code-specified by functions) and also can be enabled/disabled. It is possible to connect particles to springs, ropes, dampers and manually create complex systems and attach them to the wall. Moreover, in edit mode we can interact with objects using mouse click and drag, which changes their position and velocity. Example: try to generate waves in strings! To make edition easy, simulation pause is available.

Click here to play with physics!



Modes description

Modes are selectable by numerical keys from 1 to 6 on the keyboard.

1. Edit Mode

Uses the mouse input to change position and velocity for particles, elastic ropes and meshes. Instructions: left-click on an object, drag holding the button and release. Future features: change object attributes (mass, density, color, elasticity coefficient and so on) and delete it.

2. Area Edit

Info: not implemented yet. Guide: not implemented yet. Future features: select all objects within a rectangle area and set all their attributes simultaneously or even delete them.

3. Add Particle

Creates a particle to the physical system with origin coordinates at the mouse left-click position and a velocity proportional to mouse displacement. Instructors: left-click anywhere, drag holding the button to specify initial speed orientation and release.

4. Add Connector

Adds connector from a particle to either a fixed point or another particle. By pressing C on keyboard the user changes the type of connector: rope, spring or damper (each one with a different color and shape). Instructions: choose an object, click on it with left button, choose another object or a background location and click on it to create the connector according to the correponding mode.

5. Mesh 1d

Adds a string made up by particles and elastic ideal ropes. Left button creates a string with free ends and right button creates a string with the two ends attached to the background. Instructions: left and drag create to create free string and right drag to create fixed string.

6. Mesh 2d

Info: adds a 2d-mesh structure made up by particles, springs and dampers. It is still under development (that's why its drawning isn't working). Instructions: TODO(RodrigoCastiel)

Extra features

All particle attributes are settable through the source code. In the future, edit mode will be in charge of it.