| Package | org.MARS.dynamics.force.spring |
| Class | public class Spring |
| Inheritance | Spring SimpleForceGenerator |
| Implements | IForceGenerator |
| Subclasses | Bungee, RigidBodySpring |
Due to the need for spring forces to update within an ISimulatable's integration, there is 1 Spring element per force generation. So, despite needing 2 elements to connect, only the first element has the spring force generated for. The supporting methods clone, invert and the static method createDoubleSidedSpring are used to ease this duality.
In the future a more monolithic approach may be taken to integration such that more complex forces can be calculated only once per step.
TODO: commentSee also
| Property | Defined by | ||
|---|---|---|---|
| restLength : Number [write-only]
| Spring | ||
| Property | Defined by | ||
|---|---|---|---|
| damp : Number damping
| Spring | ||
| element1 : ISimulatable
element to generate spring force on
| Spring | ||
| element2 : ISimulatable
element to connect "other" end of spring to
| Spring | ||
![]() | _force : Vector
force to apply to element(s)
| SimpleForceGenerator | |
| k : Number spring coefficient (0 - 1.0)
| Spring | ||
| _restLength : Number the spring's happy length (where no force is generated
| Spring | ||
| Method | Defined by | ||
|---|---|---|---|
|
Constructs a new Spring
| Spring | ||
|
Clone's a Spring for use with another element
| Spring | ||
|
createDoubleSidedSpring(element1:ISimulatable, element2:ISimulatable, k:Number = 0.01, damp:Number = 0.1):void
[static]
Creates forces for both elements
| Spring | ||
|
generate(element:ISimulatable):void
| Spring | ||
| Spring | |||
| Spring | |||
|
invert():void
Inverts the spring so that the force is applied to element2 instead of 1
| Spring | ||
| damp | property |
protected var damp:Numberdamping
| element1 | property |
protected var element1:ISimulatableelement to generate spring force on
| element2 | property |
protected var element2:ISimulatableelement to connect "other" end of spring to
| k | property |
protected var k:Numberspring coefficient (0 - 1.0)
| _restLength | property |
protected var _restLength:Numberthe spring's happy length (where no force is generated
| restLength | property |
restLength:Number [write-only]Implementation
public function set restLength(value:Number):void
| Spring | () | constructor |
public function Spring(element1:ISimulatable, element2:ISimulatable, k:Number = 0.01, damp:Number = 0.4)Constructs a new Spring
Parameterselement1:ISimulatable — element to generate spring force on
|
|
element2:ISimulatable — element to connect other end of spring to
|
|
k:Number (default = 0.01) — spring constant
|
|
damp:Number (default = 0.4) — damping coefficient
|
| clone | () | method |
public function clone(invert:Boolean = true):SpringClone's a Spring for use with another element
Parametersinvert:Boolean (default = true) — specifies whether to invert the spring so that the force gets applied
to element2
|
Spring —
the newly cloned Spring
|
| createDoubleSidedSpring | () | method |
public static function createDoubleSidedSpring(element1:ISimulatable, element2:ISimulatable, k:Number = 0.01, damp:Number = 0.1):voidCreates forces for both elements
Parameterselement1:ISimulatable |
|
element2:ISimulatable |
|
k:Number (default = 0.01) |
|
damp:Number (default = 0.1) |
| generate | () | method |
| getPoint1InWorldSpace | () | method |
| getPoint2InWorldSpace | () | method |
| invert | () | method |
public function invert():voidInverts the spring so that the force is applied to element2 instead of 1