LinearSpring Class
A spring, connecting two bodies.
The Spring explicitly adds force and angularForce to the bodies.
Constructor
LinearSpring
-
bodyA
-
bodyB
-
[options]
Parameters:
-
bodyA
Body -
bodyB
Body -
[options]
Object optional-
[restLength]
Number optionalA number > 0. Default is the current distance between the world anchor points.
-
[stiffness=100]
Number optionalSpring constant (see Hookes Law). A number >= 0.
-
[damping=1]
Number optionalA number >= 0. Default: 1
-
[worldAnchorA]
Array optionalWhere to hook the spring to body A, in world coordinates. Overrides the option "localAnchorA" if given.
-
[worldAnchorB]
Array optional -
[localAnchorA]
Array optionalWhere to hook the spring to body A, in local body coordinates. Defaults to the body center.
-
[localAnchorB]
Array optional
-
Item Index
Properties
Methods
applyForce
()
Apply the spring force to the connected bodies.
getWorldAnchorA
-
result
Get the anchor point on body A, in world coordinates.
Parameters:
-
result
ArrayThe vector to store the result in.
getWorldAnchorB
-
result
Get the anchor point on body B, in world coordinates.
Parameters:
-
result
ArrayThe vector to store the result in.
setWorldAnchorA
-
worldAnchorA
Set the anchor point on body A, using world coordinates.
Parameters:
-
worldAnchorA
Array
setWorldAnchorB
-
worldAnchorB
Set the anchor point on body B, using world coordinates.
Parameters:
-
worldAnchorB
Array
Properties
damping
Number
Damping of the spring.
localAnchorA
Array
Anchor for bodyA in local bodyA coordinates.
localAnchorB
Array
Anchor for bodyB in local bodyB coordinates.
restLength
Number
Rest length of the spring.
stiffness
Number
Stiffness of the spring.