Class Index | File Index

Classes


Class pv.Constraint.position

Constraints particles to a fixed position. The fixed position per particle is determined using a given position function, which defaults to function(d) d.fix.

If the position function returns null, then no position constraint is applied to the given particle. Otherwise, the particle's position is set to the returned position, as expressed by a pv.Vector. (Note: the position does not need to be an instance of pv.Vector, but simply an object with x and y attributes.)

This constraint also supports a configurable alpha parameter, which defaults to 1. If the alpha parameter is in the range [0,1], then rather than setting the particle's new position directly to the position returned by the supplied position function, the particle's position is interpolated towards the fixed position. This results is a smooth (exponential) drift towards the fixed position, which can increase the stability of the physics simulation. In addition, the alpha parameter can be decayed over time, relaxing the position constraint, which helps to stabilize on an optimal solution.
Defined in: PositionConstraint.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Constructs a default position constraint using the fix attribute.
Method Summary
Method Attributes Method Name and Description
 
alpha(x)
Sets or gets the alpha parameter for position interpolation.
 
apply(particles)
Applies this constraint to the specified particles.
Class Detail
pv.Constraint.position(f)
Constructs a default position constraint using the fix attribute. An optional position function can be specified to determine how the fixed position per-particle is determined.
Parameters:
{function} f Optional
the position function.
Method Detail
{pv.Constraint.position} alpha(x)
Sets or gets the alpha parameter for position interpolation. If the alpha parameter is in the range [0,1], then rather than setting the particle's new position directly to the position returned by the supplied position function, the particle's position is interpolated towards the fixed position.
Parameters:
{number} x
the new alpha parameter, in the range [0,1].
Returns:
{pv.Constraint.position} this.

apply(particles)
Applies this constraint to the specified particles.
Parameters:
{pv.Particle} particles
particles to which to apply this constraint.

Documentation generated by JsDoc Toolkit 2.3.2 on Fri May 28 2010 10:13:27 GMT-0700 (PDT)