noope.laws
Class Gravity

java.lang.Object
  |
  +--noope.laws.Law
        |
        +--noope.laws.ParticlePairLaw
              |
              +--noope.laws.Gravity

public class Gravity
extends ParticlePairLaw

Used to implement Newton's inverse square law of gravity

Version:
26 March 2001, changed by Miklos Reiter to be subclass of ParticlePairLaw
Author:
The NOOPE team

Field Summary
static double defaultG
          This is the default universal gravitational constant having the value 6.6732e-11.
 
Fields inherited from class noope.laws.Law
physics
 
Constructor Summary
Gravity(BlockReader br, int lawnumber, Physics phys)
          Construct a Gravity Law from the supplied BlockReader, with the supplied lawnumber.
 
Method Summary
 void actOnPair(Entity ent1, Entity ent2)
          This evaluates the gravitational force for the given pair of entitys and calls addForce appropriately for each of them.
 LawPropertyRecord constructNewPropertyRecord(BlockReader br, Entity ent)
          Returns a new GravityPropertyRecord, calling its constructor with (br, ent).
 java.lang.String toString()
          Return a string representation of this Gravity object, for debugging purposes.
 
Methods inherited from class noope.laws.ParticlePairLaw
act
 
Methods inherited from class noope.laws.Law
dispose, getName, getNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultG

public static final double defaultG
This is the default universal gravitational constant having the value 6.6732e-11.
Constructor Detail

Gravity

public Gravity(BlockReader br,
               int lawnumber,
               Physics phys)
        throws BRLoadingException
Construct a Gravity Law from the supplied BlockReader, with the supplied lawnumber. After calling the inherited constructor, the Gravity constructor tries to load G as the first Entry of BlockReader. If it fails, it assumes we're working with the defaultG constant, which has a value of 6.6732e-11.
Parameters:
br - BlockReader used to initialise object
lawnumber - Number of this law
Method Detail

actOnPair

public void actOnPair(Entity ent1,
                      Entity ent2)
This evaluates the gravitational force for the given pair of entitys and calls addForce appropriately for each of them.
Overrides:
actOnPair in class ParticlePairLaw

constructNewPropertyRecord

public LawPropertyRecord constructNewPropertyRecord(BlockReader br,
                                                    Entity ent)
                                             throws BRLoadingException
Returns a new GravityPropertyRecord, calling its constructor with (br, ent). The GravityPropertyRecord constructor then tries to load "gravitationalMass" as the first entry of br; if it fails, it sets the gravitationalMass to the inertialMass of ent; if that fails, it raises an exception.
Overrides:
constructNewPropertyRecord in class Law
Following copied from class: noope.laws.Law
Parameters:
br - BlockReader used to read properties from
ent - is the instance of Entity, this LawPropertyRecord will be constructed for

toString

public java.lang.String toString()
Return a string representation of this Gravity object, for debugging purposes.
Overrides:
toString in class Law