language-independent name of this object
body to attach to start point of the Spring
attachment point in body coords of body1
body to attach to end point of the Spring
attachment point in body coords of body2
length of spring when it has no force
Optional
stiffness: numberamount of force per unit distance of stretch
Optional
compressOnly: booleanSets the spring to 'compress only mode' which behaves normally if the spring is in compression but disconnects from the second attachment point during extension.
Private
attach1_attachment point in body coords for body1
Private
attach2_attachment point in body coords for body2
Private
body1_body to attach point1 to
Private
body2_body to attach point2 to
Static
IDCounter used for naming SimObjects.
Ensures this ForceLaw is not connected to anything and so can be garbage collected. For example, if this ForceLaw is an Observer, this will stop observing its Subject.
Returns list of MassObjects being affected by this ForceLaw.
list of MassObjects being affected by this ForceLaw
Returns the RigidBody that start point of the spring is attached to.
the RigidBody that start point of the spring is attached to.
Returns the RigidBody that end point of the spring is attached to.
the RigidBody that end point of the spring is attached to.
Returns a rectangle that contains this SimObject in world coordinates.
rectangle that contains this SimObject in world coordinates
Returns the expiration time, when this SimObject should be removed from the SimList. This is intended for temporary SimObjects that illustrate, for example, contact forces or collisions.
the expiration time, in time frame of the Simulation clock
Name of this SimObject, either the language-independent name for scripting purposes or the localized name for display to user.
The language-independent name should be the same as the English version but capitalized and with spaces and dashes replaced by underscore, see Util.toName, nameEquals.
The name should give an idea of the role of the SimObject in the simulation. This allows us to to treat an object in a special way depending on its name. For example, we might use the name to decide what type of DisplayObject to create to represent the SimObject.
Optional
opt_localized: booleantrue
means return the localized version of the name;
default is false
which means return the language independent name.
name of this SimObject
Whether this implements the MassObject interface.
Whether this implements the MassObject interface.
Whether this SimObject has the given name, adjusting for transformation to the language-independent form of the name, as is done by Util.toName.
the English or language-independent version of the name
whether this SimObject has the given name (adjusted to language-independent form)
Sets the expiration time, when this SimObject should be removed from the SimList. This is intended for temporary SimObjects that illustrate, for example, contact forces or collisions.
the expiration time, in time frame of the Simulation clock
Returns true if the given SimObject is similar to this SimObject for display purposes. SimObjects are similar when they are the same type and nearly the same size and location. Mainly used when showing forces - to avoid adding too many objects to the display. See SimList.getSimilar.
the SimObject to compare to
Optional
_opt_tolerance: numberthe amount the object components can differ by
true if this SimObject is similar to obj
for display purposes
Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.
For an object whose main purpose is to represent another Printable object, it is
recommended to include the result of calling toStringShort
on that other object.
For example, calling toStringShort()
on a DisplayShape might return something like
this:
DisplayShape{polygon:Polygon{'chain3'}}
a minimal string representation of this object.
Generated using TypeDoc
Represents a spring attached between two MassObjects, generates a Force which depends on how the Spring is stretched. Damping is proportional to the relative velocity of the two objects.
To attach one end to a fixed point you can attach to an infinite mass MassObject or a Scrim.
Compress-only mode
The
compressOnly
argument of the constructor sets the spring to compress only mode which behaves normally if the spring is in compression (the length is less than the rest length) but it temporarily disconnects from the second attachment point during extension (when the length is more than rest length). During extension, the Spring's start point is at the first attachment point onbody1
, but the end point is rest-length away from start point in the direction of the second attachment point.