public abstract class TwoBodyForce extends TargetedForce
Force between two specified Particles, which extends
TargetedForce and simplifies implementation of custom Forces. A TwoBodyForce deals
with all of the mechanics of getting at the two "ends" of Force and reduces the details of
what a user needs to specify down to creating the force Vector3Ds that act on the
ends. If the forces are of the standard equal-and-opposite variety, only the force on one
end needs to be provided.| Modifier and Type | Class and Description |
|---|---|
protected static class |
TwoBodyForce.ForcePair
Class that wraps Vector3D forces to apply to the two ends of this TwoBodyForce.
|
| Modifier | Constructor and Description |
|---|---|
protected |
TwoBodyForce(Particle oneEnd,
Particle theOtherEnd)
Creates a two-body force between the two given particles.
|
| Modifier and Type | Method and Description |
|---|---|
TwoBodyForce |
apply()
|
protected static TwoBodyForce.ForcePair |
equalAndOpposite(Vector3D forceOnOneEnd)
Creates a force pair for when the forces to be applied are equal and opposite.
|
protected abstract TwoBodyForce.ForcePair |
forcePair()
Should apply the force to the pair of particles.
|
Particle |
getOneEnd()
Reports the particle at
oneEnd. |
Particle |
getTheOtherEnd()
Reports the particle at
theOtherEnd. |
protected TwoBodyForce |
setOneEnd(Particle p)
Sets
oneEnd to the give particle. |
protected TwoBodyForce |
setTheOtherEnd(Particle p)
Sets
theOtherEnd to the give particle. |
protected static TwoBodyForce.ForcePair |
specifyBoth(Vector3D forceOnOneEnd,
Vector3D forceOnTheOtherEnd)
Creates a
TwoBodyForce.ForcePair from two not necessarily equal and opposite forces. |
TwoBodyForce |
turnOff()
Turns this force off.
|
TwoBodyForce |
turnOn()
Turns this force on.
|
TwoBodyForce |
turnOn(boolean isOn)
Turns this force on or off.
|
applyisOff, isOnprotected TwoBodyForce(Particle oneEnd, Particle theOtherEnd) throws java.lang.NullPointerException
Particle is mutated by this operation, though later use of the apply()
method will mutate the Particle.force vector.public final Particle getTheOtherEnd()
theOtherEnd. Mutating this Particle is permitted.theOtherEndpublic TwoBodyForce apply()
oneEnd and theOtherEnd, which modifies their
Particle.force values.
Users extending this class to create custom Forces need only implement forcePair(),
taking advantage of the static packaging method equalAndOpposite(Vector3D) or
specifyBoth(Vector3D, Vector3D) to create the TwoBodyForce.ForcePair.public TwoBodyForce turnOff()
turnOff in interface ForceturnOff in class AbstractForcepublic TwoBodyForce turnOn()
turnOn in interface ForceturnOn in class AbstractForcepublic TwoBodyForce turnOn(boolean isOn)
turnOn in interface ForceturnOn in class AbstractForceisOn - This force is turned on if true, otherwise it is turned off.protected TwoBodyForce setOneEnd(Particle p) throws java.lang.NullPointerException
oneEnd to the give particle.p - The particle at one end of this Force; cannot be nulljava.lang.NullPointerException - if the particle is null.protected TwoBodyForce setTheOtherEnd(Particle p) throws java.lang.NullPointerException
theOtherEnd to the give particle.p - The particle at the other end of this Force; cannot be nulljava.lang.NullPointerException - if the particle is null.protected static TwoBodyForce.ForcePair specifyBoth(Vector3D forceOnOneEnd, Vector3D forceOnTheOtherEnd) throws java.lang.NullPointerException
TwoBodyForce.ForcePair from two not necessarily equal and opposite forces.forceOnOneEnd - the force to be applied to oneEndforceOnTheOtherEnd - the force to be applied to theOtherEndjava.lang.NullPointerException - if either Vector3D==nullprotected static TwoBodyForce.ForcePair equalAndOpposite(Vector3D forceOnOneEnd) throws java.lang.NullPointerException
forceOnOneEnd - the force on oneEndjava.lang.NullPointerException - if forceOnOneEnd is nullprotected abstract TwoBodyForce.ForcePair forcePair()
TwoBodyForce.ForcePair are provided within this class: equalAndOpposite(Vector3D)
or specifyBoth(Vector3D, Vector3D).TwoBodyForce.ForcePair specifying the forces to apply to oneEnd and theOtherEnd.