hermes.physics
Class ImpulseCollision

java.lang.Object
  extended by hermes.physics.ImpulseCollision

public class ImpulseCollision
extends java.lang.Object

This class is used to store the data for an impulse-based collision between two beings.
Intended for internal use, you do not need to understand or use this class!
It will accumulate an impulse for a collision between two beings, and apply it equally to each when the collision is resolved.


Constructor Summary
ImpulseCollision(MassedBeing being1, MassedBeing being2, PVector projection, float elasticity)
          Sets up a collision between beings
 
Method Summary
 void addImpulse()
          add an impulse to the beings, calculated between them, based on their current mass and velocity, to the beings
 void addImpulse(PVector impulse, MassedBeing origin)
          add an impulse to the collision
 void applyDisplacement()
          applies the projective displacement to each being
 void applyImpulses()
          applies the stored impulse to each being clears the impulse vector
 void calculateDisplacement()
          calculates the projective displacement on each being
 PVector getImpulse()
          returns the accumulated impulse vector
 PVector getProjection()
          the projection vector from being1 to being2
 boolean hasBeing(MassedBeing being)
          whether the one of the beings in this collision is the specified being
 void setProjection(PVector projection)
          sets the projection vector for the collision
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImpulseCollision

public ImpulseCollision(MassedBeing being1,
                        MassedBeing being2,
                        PVector projection,
                        float elasticity)
Sets up a collision between beings

Parameters:
being1 - the first being (impulses and projections are from being1 to being2)
being2 - the second being
projection - the projection vector from being1 to being2
Method Detail

getProjection

public PVector getProjection()
the projection vector from being1 to being2

Returns:
the projection vector

setProjection

public void setProjection(PVector projection)
sets the projection vector for the collision

Parameters:
projection - the projection vector

getImpulse

public PVector getImpulse()
returns the accumulated impulse vector

Returns:
the impulse

addImpulse

public void addImpulse(PVector impulse,
                       MassedBeing origin)
add an impulse to the collision

Parameters:
impulse - the impulse to add
origin - the origin of the impulse (should be being1 or being2)

addImpulse

public void addImpulse()
add an impulse to the beings, calculated between them, based on their current mass and velocity, to the beings


applyImpulses

public void applyImpulses()
applies the stored impulse to each being clears the impulse vector


calculateDisplacement

public void calculateDisplacement()
calculates the projective displacement on each being


applyDisplacement

public void applyDisplacement()
applies the projective displacement to each being


hasBeing

public boolean hasBeing(MassedBeing being)
whether the one of the beings in this collision is the specified being

Parameters:
being - the being to check for
Returns:
whether being is in this collision