A Spring is used to create an elastic connection between two Real objects. Springs define only a connection between objects and are not physical objects themselves. Thus, Springs can pass through each other without colliding.A number of paramters can be specified for springs. The length parameter specifies the length of the spring when it is completely relaxed. The spring will always apply a force to attempt to expand or contract to the specified length. The strength parameter specifies the amount of force that is applied to try to attain the spring's natural length. Finally, the damping parameter specifies the friction or damping proportional to the spring's velocity.
If physical realism is important, springs should be used with caution. As the strength and damping constants of the spring increase, springs can generate enormous forces that will cause numerical overflows or other undesirable behavior. Keep spring strength and damping constants as low as possible to avoid this behavior.
The Spring class is new as of version 2.1.
Connects the spring from springLink1 to springLink2.
The optional arguments point1 and point2 specify the locations on the objects to which the springs are attached. The default values are (0, 0, 0).
If the length arugment is omitted, length defaults to 0.
This method returns the current (stretched or compressed) length of the spring, as opposed to the "natural" length.
Returns the amount of force applied by this spring at the last timestep. The returned value is a double representing the magnitude of the force. The direction of the force is determined by the locations of the links to which the spring is attached.
This method returns the natural length of the spring. See also get-current-length which returns the current (stretched or compressed) length of the spring.
Returns a list with two items, the links which are joined by this spring.
Setting a spring as "contract only" means that the spring will contract if it is expanded larger than its natural length, but will not expand if it is pushed to smaller lengths. This makes the spring behavior more like a rope. See also set-expand-only and set-expand-and-contract.
Sets the spring's damping to newDamping.
This sets a spring to apply forces to expand when the spring is pushed smaller than the natural length, and contract when the spring is pulled to be larger than the natural length. This is the default behavior of a spring.
Setting a spring as "expand only" means that the spring will expand if it is pushed smaller than its natural length, but will not contract if it is stretched to be larger.
Sets the spring's length to newLength.
Sets an optional maximum force that the spring can apply. This can be used as a safegaurd to prevent unrealistically large forces from causing instability in simulations.
If the maximum force value is set to 0, which is the default, then the springs forces are unlimited.
Sets the drawing style of this spring. patternString is a string of 16 spaces and/or dashes which specify the line pattern to be drawn. A thickly dashed spring, for example, would use the pattern "-------- ". The string " " can be used to make the spring invisible. If no style is given, a dotted line is drawn.
Sets the spring's strength to newStrength.