B2TensorDampingController
From Box2D Wiki
| b2TensorDampingController | |
|---|---|
| Box2D/Dynamics/Controllers | |
| Visibility | Public |
| Definition Object | b2TensorDampingControllerDef |
| Parent Object | b2Controller |
| Source reference |
|
b2TensorDampingController is a controller implementing anisotropic linear damping to each of its bodies, i.e. damping that depends on the velocity of the body in local co-ordinates.
This is mainly useful for simulating top down wheels, which have high resistance to motion along their axis, but will freely move (by implied rotation) perpendicular to their axis.
Usage
This controller's behaviour is determined by the value of its T matrix (the tensor in question). This determines the damping by:
damping = T * v
where v is the body's velocity in local co-ordinates.
Some typical examples of T, for some values a and b:
| Normal linear damping | ||||
| Electron in fixed field - a force at right angles to velocity with proportional magnitude | ||||
| Differing x and y damping. Useful e.g. for top-down wheels. |
For this final form, there is a helper function to quickly set it up:
void b2TensorDampingControllerDef::SetAxisAligned(float32 xDamping, float32 yDamping);
This function takes positive values.
As damping is calculated once per step, it is possible that the total change in velocity from damping is enough to reverse the direction of the body. In order to prevent this, set maxTimestep to limit the size of a step that can have an effect. SetAxisAligned automatically sets this to 1/(max eigenvalue of T), which is probably the only useful value save 0, which disables it.


