net.jinx.physics.collision
Class SphereCollisionDetector

java.lang.Object
  extended by net.jinx.physics.collision.SphereCollisionDetector
All Implemented Interfaces:
CollisionDetector

public class SphereCollisionDetector
extends java.lang.Object
implements CollisionDetector


Constructor Summary
SphereCollisionDetector()
           
 
Method Summary
 void added(PhysicalObject obj)
          Called by Universe to notify that a PhysicalObject has been added to the simulation.
 Contact firstContact(PhysicalObject o1, PhysicalObject o2, float initial, float deltaTime, Universe u)
           
 java.util.Set firstContacts(PhysicalObject obj, float initial, float deltaTime, Universe u)
          Checks for collisions between PhysicalObject instances previously added via the added(PhysicalObject) method and obj.
static float getRadius(PhysicalObject obj)
          Provides the radius of a PhysicalObject that's been tagged as a sphere for collision detection purposes.
static boolean isSphere(PhysicalObject obj)
           
 void removed(PhysicalObject obj)
          Called by Universe to notify that a PhysicalObject has been removed from the simulation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SphereCollisionDetector

public SphereCollisionDetector()
Method Detail

isSphere

public static boolean isSphere(PhysicalObject obj)

getRadius

public static float getRadius(PhysicalObject obj)
Provides the radius of a PhysicalObject that's been tagged as a sphere for collision detection purposes.

Parameters:
obj - the PhysicalObject.
Returns:
the radius.
Throws:
java.lang.IllegalArgumentException - if sphere isn't tagged with a SphereCollisionTag.

added

public void added(PhysicalObject obj)
Description copied from interface: CollisionDetector
Called by Universe to notify that a PhysicalObject has been added to the simulation.

Specified by:
added in interface CollisionDetector
Parameters:
obj - the PhysicalObject that was added.

removed

public void removed(PhysicalObject obj)
Description copied from interface: CollisionDetector
Called by Universe to notify that a PhysicalObject has been removed from the simulation.

Specified by:
removed in interface CollisionDetector
Parameters:
obj - the PhysicalObject that was removed.

firstContacts

public java.util.Set firstContacts(PhysicalObject obj,
                                   float initial,
                                   float deltaTime,
                                   Universe u)
Description copied from interface: CollisionDetector
Checks for collisions between PhysicalObject instances previously added via the added(PhysicalObject) method and obj. How it does this is unimportant, but some kind of Tag for a bounding volume is likely required.

Specified by:
firstContacts in interface CollisionDetector
Parameters:
obj - the object that collisions are being detected for.
u - the Universe that collisions are being detected in.
Returns:
a Set containing all the first Contacts that occured simultaneously. This may be an empty Set if no Contacts occured.

firstContact

public Contact firstContact(PhysicalObject o1,
                            PhysicalObject o2,
                            float initial,
                            float deltaTime,
                            Universe u)