Skip to content
Siddharth Narayanaswamy edited this page Jul 1, 2014 · 2 revisions

This page documents the high-level structure of the webchurch-box2d translation layer. It (mostly) refers to code in physics2D.js.

Example usage of the code (with comparison to the canonical example from probmods.org) is here.

The story so far

A box2d world:

  • gravity -- specified as a 2-vector
  • entities -- list of structured 4-tuples
    • id -- name
    • shapeT -- shape and its dimensions
      • shape -- circle | rectangle | ngon [triangle, square, pentagon, hexagon]
      • dimensions -- 2D vector that holds radius | (width, height) | (radius, #vertices)
    • body -- bodyType, centroid position, and velocities if any
      • bodyType -- staticType | dynamicType | kinematicType
      • position -- 2D vector of (x, y)
      • velocity -- 2D vector of (x', _y')
      • angularVelocity -- scalar
    • fixture -- density, friction, and restitution (bounciness)
      • density -- scalar
      • friction -- scalar
      • restitution -- scalar

Upcoming Changes

  1. More opened-up version of the translation layer create fixtures, bodies, and worlds directly with full webchurch <-> box2d translation, allowing for
    • sampling over many more free parameters (like static|dynamic) of fixtures and bodies
    • creation of compositional bodies -- multiple fixtures combined to form a single body (Josh Hartstone)
  2. Collision listener and filter groups efficient spec and handling of collisions, allowing for
    • ghosting objects (useful for counterfactuals)
    • perturbation of particular collisions (either by flags or objects)
Clone this wiki locally