Integrators

Jasper edited this page Apr 22, 2014 · 3 revisions

Integrators follow the Factory Pattern. Please read about the factory pattern to learn about creation, declaration, and extending integrators.

See also: API Reference on Integrators.

Integrators are fairly straightforward to create. Simply follow the Factory Pattern, and extend the methods .integrateVelocities() and .integratePositions().

Example:

Physics.integrator('my-integrator', function( parent ){

    return {
        
        integrateVelocities: function( bodies, dt ){

            // update the velocities of all bodies according to timestep dt
            // store previous velocities in .state.old.vel
            // and .state.old.angular.vel
        },

        integratePositions: function( bodies, dt ){

            // update the positions of all bodies according to timestep dt
            // store the previous positions in .state.old.pos
            // and .state.old.angular.pos
            // also set the accelerations to zero
        }
    };
});
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.