These pages are auto-generated from self-documenting comments embedded in class files.
For more information on breve and steve, refer to the breve homepage.

## Object : Spring

This class is included as part of the file Spring.tz.
To use this class in a simulation, include the line "@use Spring."

### Class description:

> 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.

### Class methods:

> Connecting Real Objects Using a Spring

> - connect
> - get-current-length

> Getting and Setting Spring Parameters

> - get-force
> - get-length
> - get-links
> - set-contract-only
> - set-damping
> - set-expand-and-contract
> - set-expand-only
> - set-length
> - set-maximum-force
> - set-pattern
> - set-strength

`connect from springLink1 (object) to springLink2 (object) from-point point1 = (0, 0, 0) (vector) to-point point2 = (0, 0, 0) (vector) with-length springLength = 0 (float) with-strength springStrength = 100 (float) with-damping springDamping = 0.01 (float)`

> 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.

`get-current-length`

> This method returns the current (stretched or compressed) length of the spring, as opposed to the "natural" length.

`get-force`

> 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.

`get-length`

> 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.

`get-links`

> Returns a list with two items, the links which are joined by this spring.

`set-contract-only`

> 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.

`set-damping to newDamping (double)`

> Sets the spring's damping to newDamping.

`set-expand-and-contract`

> 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.

`set-expand-only`

> 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.

`set-length to newLength (double)`

> Sets the spring's length to newLength.

`set-maximum-force to newMax (double)`

> 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.

`set-pattern to patternString (string)`

> 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.

`set-strength to newStrength (double)`

> Sets the spring's strength to newStrength.

Documentation created Thu Jul 3 18:18:12 2008