hermes.physics
Class Physics
java.lang.Object
hermes.physics.Physics
public class Physics
- extends java.lang.Object
A utility class for physics.
Method Summary |
static PVector |
calculateImpulse(MassedBeing being1,
MassedBeing being2,
float elasticity,
PVector normal)
Calculates the impulse from a collision between Massed Beings, without accounting for rotation. |
static PVector |
calculateImpulse(PVector v1,
PVector v2,
float m1,
float m2,
float elasticity,
PVector normal)
Calculates the impulse from a collision between objects, without accounting for rotation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Physics
public Physics()
calculateImpulse
public static PVector calculateImpulse(PVector v1,
PVector v2,
float m1,
float m2,
float elasticity,
PVector normal)
- Calculates the impulse from a collision between objects, without accounting for rotation.
- Parameters:
v1
- the velocity of the first objectv2
- the velocity of the second objectm1
- the mass of the first objectm2
- the mass of the second objectelasticity
- the elasticity of collision, 1.0 is perfectly elastic
(objects will bounce, all energy is conserved), 0.0 is completely inelastic
(they will stop, no conservation of kinetic energy)normal
- vector pointing from body 1 into body 2 along the axis of collision
does NOT need to be of unit length (use the projection vector)
- Returns:
- the impulse from body 1 on body 2 (impulse from 2 on 1 is merely the reverse of this)
this is calculated by the equation:
-(1-e)(v2 - v1) . n
j = -----------------------------------
n . n(1/m1 + 1/m2)
where e is elasticity and n is the normal
calculateImpulse
public static PVector calculateImpulse(MassedBeing being1,
MassedBeing being2,
float elasticity,
PVector normal)
- Calculates the impulse from a collision between Massed Beings, without accounting for rotation.
- Parameters:
being1
- the first beingbeing2
- the second beingelasticity
- the elasticity of collision, 1.0 is perfectly elastic
(objects will bounce, all energy is conserved), 0.0 is completely inelastic
(they will stop, no conservation of kinetic energy)normal
- vector pointing from being1 to being2 along the axis of collision
(use the projection vector between their shapes)
- Returns:
- impulse from being1 on being2