Class Index | File Index

Classes


Class pv.Simulation

Represents a particle simulation. Particles are massive points in two-dimensional space. Forces can be applied to these particles, causing them to move. Constraints can also be applied to restrict particle movement, for example, constraining particles to a fixed position, or simulating collision between circular particles with area.

The simulation uses Position Verlet integration, due to the ease with which geometric constraints can be implemented. For each time step, Verlet integration is performed, new forces are accumulated, and then constraints are applied.

The simulation makes two simplifying assumptions: all particles are equal-mass, and the time step of the simulation is fixed. It would be easy to incorporate variable-mass particles as a future enhancement. Variable time steps are also possible, but are likely to introduce instability in the simulation.

This class can be used directly to simulate particle interaction. Alternatively, for network diagrams, see pv.Layout.Force.
Defined in: Simulation.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
pv.Simulation(particles)
Constructs a new simulation for the specified particles.
Field Summary
Field Attributes Field Name and Description
 
The constraints in the simulation.
 
The forces in the simulation.
 
The particles in the simulation.
Method Summary
Method Attributes Method Name and Description
 
Adds the specified constraint to the simulation.
 
force(f)
Adds the specified force to the simulation.
 
Adds the specified particle to the simulation.
 
Apply constraints, and then set the velocities to zero.
 
step()
Advances the simulation one time-step.
Class Detail
pv.Simulation(particles)
Constructs a new simulation for the specified particles.
Parameters:
{array} particles
an array of pv.Particles to simulate.
See:
pv.Layout.Force
pv.Force
pv.Constraint
Field Detail
{pv.Constraint} constraints
The constraints in the simulation. Constraints are stored as a linked list; this field represents the first constraint in the simulation.

{pv.Force} forces
The forces in the simulation. Forces are stored as a linked list; this field represents the first force in the simulation.

{pv.Particle} particles
The particles in the simulation. Particles are stored as a linked list; this field represents the first particle in the simulation.
Method Detail
{pv.Simulation} constraint(c)
Adds the specified constraint to the simulation.
Parameters:
{pv.Constraint} c
the new constraint.
Returns:
{pv.Simulation} this.

{pv.Simulation} force(f)
Adds the specified force to the simulation.
Parameters:
{pv.Force} f
the new force.
Returns:
{pv.Simulation} this.

{pv.Simulation} particle(p)
Adds the specified particle to the simulation.
Parameters:
{pv.Particle} p
the new particle.
Returns:
{pv.Simulation} this.

{pv.Simulation} stabilize(n)
Apply constraints, and then set the velocities to zero.
Parameters:
n
Returns:
{pv.Simulation} this.

step()
Advances the simulation one time-step.

Documentation generated by JsDoc Toolkit 2.3.2 on Sun May 30 2010 18:10:25 GMT-0700 (PDT)