|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gicentre.utils.network.traer.physics.AbstractForce
org.gicentre.utils.network.traer.physics.TargetedForce
org.gicentre.utils.network.traer.physics.TwoBodyForce
org.gicentre.utils.network.traer.physics.Spring
public class Spring
Class for representing a physical spring by extending TwoBodyForce to calculate
the force with a spring constant (ks), damping factor (d), and an
ideal length (l). Thus, the positions of the Particles on either end
obey the equation:
ddot(r) = -k/m * (r-l) - d/m * dot(r)
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.gicentre.utils.network.traer.physics.TwoBodyForce |
|---|
TwoBodyForce.ForcePair |
| Constructor Summary | |
|---|---|
Spring(Particle oneEnd,
Particle theOtherEnd,
float ks,
float d,
float l)
Creates a spring with the given properties between the given particles. |
|
| Method Summary | |
|---|---|
float |
currentLength()
Gets the current Spring length; uses the end particle positions to do so. |
float |
damping()
Reports the damping constant of the spring d; Will always be greater than 0. |
TwoBodyForce.ForcePair |
forcePair()
Calculates the spring forces on each of the particles at either end of the spring. |
float |
restLength()
Reports the ideal length, l; always more than 0. |
Spring |
setDamping(float d)
Sets the damping constant of the spring d. |
Spring |
setRestLength(float l)
Sets the ideal length of the spring. |
Spring |
setStrength(float ks)
Sets the strength of the spring ks; must be greater than 0. |
float |
strength()
Reports the strength of the spring ks; always more than 0. |
| Methods inherited from class org.gicentre.utils.network.traer.physics.TwoBodyForce |
|---|
apply, equalAndOpposite, getOneEnd, getTheOtherEnd, setOneEnd, setTheOtherEnd, specifyBoth, turnOff, turnOn, turnOn |
| Methods inherited from class org.gicentre.utils.network.traer.physics.TargetedForce |
|---|
apply |
| Methods inherited from class org.gicentre.utils.network.traer.physics.AbstractForce |
|---|
isOff, isOn |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Spring(Particle oneEnd,
Particle theOtherEnd,
float ks,
float d,
float l)
throws java.lang.NullPointerException,
java.lang.IllegalArgumentException
oneEnd - the one end Particle; cannot be nulltheOtherEnd - the other end Particle; cannot be nullks - the spring constant.d - the damping constant.l - the ideal length of the spring.
java.lang.NullPointerException - if either Particle is null, via TwoBodyForce.TwoBodyForce(Particle, Particle)
java.lang.IllegalArgumentException - if l is not positive, via setRestLength(float).
java.lang.IllegalArgumentException - if ks not positive, via setStrength(float).
java.lang.IllegalArgumentException - if d less than 0, via setDamping(float).| Method Detail |
|---|
public final float currentLength()
public final float restLength()
l; always more than 0.
public final Spring setRestLength(float l)
throws java.lang.IllegalArgumentException
l - the new rest length; must be positive.
java.lang.IllegalArgumentException - if rest length is negativepublic final float strength()
ks; always more than 0.
ks, the spring constant
public final Spring setStrength(float ks)
throws java.lang.IllegalArgumentException
ks; must be greater than 0.
ks - the new spring constant; must be greater than 0.
java.lang.IllegalArgumentException - if ks is not positive.public final float damping()
d; Will always be greater than 0.
d, the damping constant.
public final Spring setDamping(float d)
throws java.lang.IllegalArgumentException
d.
d - the new damping constant. Must not be negative but can be 0 for no damping.
java.lang.IllegalArgumentException - if d is negative.public TwoBodyForce.ForcePair forcePair()
forcePair in class TwoBodyForce
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||