noope.laws
Class SphereCollision

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

public class SphereCollision
extends ParticlePairLaw

This law models collisions of spherical entitys. The entitys are assumed to be perfectly spherical with no spin. If collision is detected, it is carried out instantaneously, using conservation of momentum and Newton's coefficient of restitution. We are calling Entity.setVelocity(Vector3D) to do this.

Version:
27 March 2001
Author:
Miklos Reiter

Fields inherited from class noope.laws.Law
physics
 
Constructor Summary
SphereCollision(BlockReader br, int lawnumber, Physics phys)
          Initializes a new SphereCollision law object from the given BlockReader with the given lawnumber.
 
Method Summary
 void actOnPair(Entity ent1, Entity ent2)
          Acts on the pair of entities ent1 and ent2.
 LawPropertyRecord constructNewPropertyRecord(BlockReader br, Entity e)
          Returns a new SphereCollisionPropertyRecord.
 
Methods inherited from class noope.laws.ParticlePairLaw
act
 
Methods inherited from class noope.laws.Law
dispose, getName, getNumber, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SphereCollision

public SphereCollision(BlockReader br,
                       int lawnumber,
                       Physics phys)
                throws BRLoadingException
Initializes a new SphereCollision law object from the given BlockReader with the given lawnumber.
Method Detail

actOnPair

public void actOnPair(Entity ent1,
                      Entity ent2)
Acts on the pair of entities ent1 and ent2. Uses addForce and step to change the Entity's velocity. Maybe, we can implement a Entity.setVelocity method in future.
Overrides:
actOnPair in class ParticlePairLaw

constructNewPropertyRecord

public LawPropertyRecord constructNewPropertyRecord(BlockReader br,
                                                    Entity e)
                                             throws BRLoadingException
Returns a new SphereCollisionPropertyRecord. A SphereCollisionPropertyRecord stores the radius of the spherical Entity.
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