strength of gravity force
Optional
opt_simList: SimListoptional SimList to observe for when objects are added; also adds all existing bodies on that SimList.
Adds any MassObjects with finite mass among the given list of SimObjects.
set of SimObjects to possibly add
Adds the SimObject to list of objects that Gravity2Law applies forces to, but only if it has positive finite mass. *
the SimObject to possibly add
Adds the given Observer to this Subject's list of Observers, so that the Observer
will be notified of changes in this Subject. An Observer may call Subject.addObserver
during its observe
method.
the Observer to add
Adds the Parameter to the list of this Subject's available Parameters.
the Parameter to add
if a Parameter with the same name already exists.
Notifies all Observers that this Subject has changed by calling observe on each Observer.
An Observer may call addObserver or removeObserver during its observe
method.
a SubjectEvent with information relating to the change
Notifies all Observers that the Parameter with the given name has changed by calling observe on each Observer.
the language-independent or English name of the Parameter that has changed
if there is no Parameter with the given name
Connect to the given SimList, so that the force applies to all objects in the SimList. Also adds all existing bodies on that SimList. *
the SimList to connect with
Ensures this ForceLaw is not connected to anything and so can be garbage collected. For example, if this ForceLaw is an Observer, this will stop observing its Subject.
Returns list of MassObjects being affected by this ForceLaw.
list of MassObjects being affected by this ForceLaw
Protected
getReturns whether broadcasting is enabled for this Subject. See setBroadcast.
whether broadcasting is enabled for this Subject
Returns the ParameterBoolean with the given name.
the language-independent or English name of the ParameterBoolean
the ParameterBoolean with the given name
if there is no ParameterBoolean with the given name
Returns the ParameterNumber with the given name.
the language-independent or English name of the ParameterNumber
the ParameterNumber with the given name
if there is no ParameterNumber with the given name
Returns the ParameterString with the given name.
the language-independent or English name of the ParameterString
the ParameterString with the given name
if there is no ParameterString with the given name
Returns potential energy from gravity of the collection of MassObjects. Finds potential energy for each pair of objects and adds all these. Zero potential energy for each pair of objects is when they are at the minimum possible distance, as given by their MassObject.getMinHeight methods. If both objects have zero minimum radius, then this method will throw an exception.
what is the potential energy of gravity?
suppose 2 point mass objects m1, m2 are separated by r. Then they move so that they
are separated by 0.
Assume that m2 is fixed in space, so only m1 moves. The force on m1 is
G m1 m2 / r^2
So the work done is the integral of force times distance:
integral (G m1 m2 / x^2 ) dx from r to 0
- G m1 m2 / x from r to 0 = G m1 m2 / r
Check that this corresponds to potential energy of gravity near earths surface:
Suppose m1 moves from r2, slightly closer to r1.
Then the change in potential energy is (sign is probably off:)
G m1 m2 (1/r2 - 1/r1) = G m1 m2 (r1 - r2 / r1 r2)
At earths surface r1 and r2 are practically the same number:
Let r2 = R + e2 and r1 = R + e1, where e2 << R and e1 << R.
Then change in PE = G m1 m2 (e2 - e1 / R^2)
This matches the rule: PE = m g y, so that change in PE is m g (y2 - y1)
where g = G m2 / R^2 and m2 = mass of the earth, R = radius of the earth.
Actually it looks like this is correct:
PE = - G m1 m2 / r
At infinite separation, the PE is zero, and the PE becomes a bigger negative number as the objects approach.
For each pair, the zero energy is reached when they are at their closest possible separation. Take whatever that number for PE is (a negative number) and subtract this from the PE to get a positive PE that goes to zero as the objects approach each other. As long as one of the objects has a non-zero minimum radius, then we can get a non-infinite number for the minimum PE.
the potential energy due to this ForceLaw
Notifies this Observer that a change has occurred in the Subject.
contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter
Removes the Observer from this Subject's list of Observers. An Observer may
call removeObserver
during its observe
method.
the Observer to detach from list of Observers
Removes the Parameter from the list of this Subject's available Parameters.
the Parameter to remove
Specifies the set of MassObjects to apply forces on.
the set of MassObjects to apply forces on.
Protected
setSets whether this Subject will broadcast events, typically used to temporarily disable broadcasting. Intended to be used in situations where a subclass overrides a method that broadcasts an event. This allows the subclass to prevent the superclass broadcasting that event, so that the subclass can broadcast the event when the method is completed.
whether this Subject should broadcast events
the previous value
Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.
For an object whose main purpose is to represent another Printable object, it is
recommended to include the result of calling toStringShort
on that other object.
For example, calling toStringShort()
on a DisplayShape might return something like
this:
DisplayShape{polygon:Polygon{'chain3'}}
a minimal string representation of this object.
Generated using TypeDoc
Applies gravitational force between each pair of objects proportional to the inverse square of distance between them. The equation for the force is
for two objects with masses
m1, m2
separated by distancer
, with strength of gravityG
.The set of objects can be specified with the addBody method, or the Gravity2Law can observe a SimList and automatically add all bodies that have mass to the set of objects.
Parameters Created
GRAVITY
, see setGravity