gizmoball.physics
Class PhysicsEngine

java.lang.Object
  extended by gizmoball.physics.PhysicsEngine

public class PhysicsEngine
extends java.lang.Object

PhysicsEngine provides static methods for collision detection.


Method Summary
static Vect3Pair ballBallCollision(PhysicsSphere ball1, PhysicsSphere ball2)
           
static Collision getFirstCollision(java.util.List<Ball> balls, java.util.List<Gizmo> gizmos, double lookahead, double mintime)
          Finds the first collision between the balls and the gizmos+balls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFirstCollision

public static Collision getFirstCollision(java.util.List<Ball> balls,
                                          java.util.List<Gizmo> gizmos,
                                          double lookahead,
                                          double mintime)
Finds the first collision between the balls and the gizmos+balls. Stops and returns as soon as it finds one at least as soon as mintime.

Returns:
the first collision between some PhysicsSphere b in balls and some PhysicsModel o in objects
Requires:
balls != null && objects != null

ballBallCollision

public static Vect3Pair ballBallCollision(PhysicsSphere ball1,
                                          PhysicsSphere ball2)
Returns:
a Vect3Pair, where the first Vect3 is the velocity of the first sphere after the collision and the second Vect3 is the velocity of the second sphere after the collision.
Requires:
ball1.mass > 0 && ball2.mass > 0 && ball1.mass != Double.PositiveInfinity && ball2.mass != Double.PositiveInfinity && ball1 and ball2 are at point of impact
Effects:
computes the resulting velocities