This repository has been archived by the owner on Dec 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 407
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
}
};
});