B2GravityController
From Box2D Wiki
| b2GravityController | |
|---|---|
| Box2D/Dynamics/Controllers | |
| Visibility | Public |
| Definition Object | b2GravityControllerDef |
| Parent Object | b2Controller |
| Source reference |
|
b2GravityController is a controller implementing pairwise gravity between bodies. Each body is approximated as a concentration of it's entire mass at it's center of mass.
Usage
Gravity is an attractive force between each pair of bodies. If they are of mass m1 and m2, and of distance d, then the force is of magnitude
F = G * m1 * m2 / (d ^ 2)
where G is the strength as specified in the definition object.
It is sometime more convenient to follow a simpler model of gravity, which is unphysical, but more useful for a 2d world. In fact, b2GravityController defaults to this, and only uses the above inverse square law if you enable it by setting invSqr to true.
F = G * m1 * m2 / d


