|
||||||||||
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.Attraction
public class Attraction
This class implements TwoBodyForce to represent an inverse-square law force with a force constant and minimal distance. The minimal distance is necessary to avoid numerical instability associated with division by very small values. Providing a positive k creates an attractive force, a negative k creates a repulsive force
A typical use of attraction would be to implement planetary gravitation. The gravitational force G*m_1*m_2 / r^2 could be implemented as simply as supplying G (scaled appropriately to mass and distance units used elsewhere in the system), and an appropriate minimal separation to the scale of the problem.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.gicentre.utils.network.traer.physics.TwoBodyForce |
---|
TwoBodyForce.ForcePair |
Constructor Summary | |
---|---|
Attraction(Particle oneEnd,
Particle theOtherEnd,
float k,
float distanceMin)
Creates an Attraction between oneEnd and theOtherEnd, with scale k and minimum distance distanceMin. |
Method Summary | |
---|---|
protected TwoBodyForce.ForcePair |
forcePair()
Implements the Attraction force calculation. |
float |
getMinimumDistance()
Reports the minimum separation distance above which the attraction is applied. |
float |
getStrength()
Reports the strength of this Attraction. |
Attraction |
setMinimumDistance(float d)
Sets the minimum separation distance above which the attraction is applied. |
Attraction |
setStrength(float k)
Sets the strength of this Attraction. |
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 Attraction(Particle oneEnd, Particle theOtherEnd, float k, float distanceMin) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
oneEnd
- The particle at one end.theOtherEnd
- The particle at the other end.k
- the force scale between the two particles.distanceMin
- the minimum distance between particles above which the force acts.
java.lang.NullPointerException
- if either particle is null.
java.lang.IllegalArgumentException
- if distanceMin is <=0.Method Detail |
---|
public final float getMinimumDistance()
public final Attraction setMinimumDistance(float d) throws java.lang.IllegalArgumentException
d
- the new minimum distance
java.lang.IllegalArgumentException
- if d<=0public final Attraction setStrength(float k)
k
- the strength of the Attraction.
public final float getStrength()
protected TwoBodyForce.ForcePair forcePair()
forcePair
in class TwoBodyForce
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |