Class Index | File Index

Classes


Class pv.Force.spring


Extends pv.Force.
Implements a spring force, per Hooke's law. The spring force can be configured with a tension constant, rest length, and damping factor. The tension and damping will automatically be normalized using the inverse square root of the maximum link degree of attached nodes; this makes springs weaker between nodes of high link degree.

Unlike other forces (such as charge and drag forces) which may be applied globally, spring forces are only applied between linked particles. Therefore, an array of links must be specified before this force can be applied; the links should be an array of pv.Layout.Network.Links. See also pv.Layout.Force for an example of using spring and charge forces for network layout.
Defined in: SpringForce.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Constructs a new spring force with the specified constant.
Method Summary
Method Attributes Method Name and Description
 
apply(particles)
Applies this force to the specified particles.
 
Sets or gets the spring constant.
 
The spring damping factor, in the range [0,1].
 
length(x)
The spring rest length.
 
links(x)
Sets or gets the links associated with this spring force.
Class Detail
pv.Force.spring(k)
Constructs a new spring force with the specified constant. The links associated with this spring force must be specified before the spring force can be applied.
Parameters:
{number} k
the spring constant.
See:
#constant
#links
Method Detail
apply(particles)
Applies this force to the specified particles.
Parameters:
{pv.Particle} particles
particles to which to apply this force.

{pv.Force.spring} constant(x)
Sets or gets the spring constant. The default value is 0.1; greater values will result in stronger tension. The spring tension is automatically normalized using the inverse square root of the maximum link degree of attached nodes.
Parameters:
{number} x
the new spring constant.
Returns:
{pv.Force.spring} this, or the current spring constant.

{pv.Force.spring} damping(x)
The spring damping factor, in the range [0,1]. Damping functions identically to drag forces, damping spring bounciness by applying a force in the opposite direction of attached nodes' velocities. The default value is 0.1. The spring damping is automatically normalized using the inverse square root of the maximum link degree of attached nodes.
Parameters:
{number} x
the new spring damping factor.
Returns:
{pv.Force.spring} this, or the current spring damping factor.

{pv.Force.spring} length(x)
The spring rest length. The default value is 20 pixels.
Parameters:
{number} x
the new spring rest length.
Returns:
{pv.Force.spring} this, or the current spring rest length.

{pv.Force.spring} links(x)
Sets or gets the links associated with this spring force. Unlike other forces (such as charge and drag forces) which may be applied globally, spring forces are only applied between linked particles. Therefore, an array of links must be specified before this force can be applied; the links should be an array of pv.Layout.Network.Links.
Parameters:
{array} x
the new array of links.
Returns:
{pv.Force.spring} this, or the current array of links.

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