vooga.physicsEngine
Class PhysicalParameters

java.lang.Object
  extended by vooga.physicsEngine.geometry.GeometricParameters
      extended by vooga.physicsEngine.PhysicalParameters
Direct Known Subclasses:
GamePhysicalParameters

public class PhysicalParameters
extends GeometricParameters

Class that encapsulates the parameters of a physical body. This extends GeometricParameters because it not only includes the shape, position, angular position (geometric parameters), but also velocities, mass, moment of inertia, and other physical quantities.

Author:
Peng Shi

Field Summary
 
Fields inherited from class vooga.physicsEngine.geometry.GeometricParameters
shape
 
Constructor Summary
PhysicalParameters(Shape shape)
          Called by outside users of physics module to create an encapsulation of a physical object with given Shape
 
Method Summary
 void applyAngularImpulse(double angularImpulse)
          Apply an instantaneous angular impulse on the object
 void applyImpulse(Vector2f impulse)
          Apply an instantaneous impulse on the object
 void endFrame()
          Called every time updatePosition is called for the body
 double getAngularVelocity()
           
 java.util.Set<PhysicalParameters> getCollideSet()
          Return the set of PhysicalParameters that the object is currently in collision with.
 Vector2f getConstantAcceleration()
           
 double getConstantTorque()
           
 double getDamping()
           
 double getElasticity()
           
 double getFrictionCoefficient()
           
protected  double getInvI()
           
protected  double getInvMass()
           
 double getMass()
           
 double getMomentOfInertia()
          If the moment of inertia is not explicitly set, then this will return an estimate based on the mass and the shape of the object.
 double getRotationalDamping()
           
 Vector2f getVelocity()
           
 boolean inCollisionWith(PhysicalParameters param)
          Check if the last time the physics engine updated the object, the object collided.
 void incrementAngularVelocity(double delta)
          Adds to the current angular velocity.
 void incrementVelocity(Vector2f difference)
          Adds to the current velocity.
 boolean isMovable()
           
protected  void notifyCollided(PhysicalParameters param)
          Called when this PhysicalParameters collides with another.
 void setAngularVelocity(double angularVelocity)
           
 void setConstantAcceleration(Vector2f constantAcceleration)
          Apply a constant acceleration on the object.
 void setConstantForce(Vector2f constantForce)
           
 void setConstantTorque(double constantTorque)
          Apply a constant torque to the object.
 void setDamping(double damping)
          Set the air translational damping of the object.
 void setElasticity(double elasticity)
           
 void setFrictionCoefficient(double frictionCoefficient)
           
 void setMass(double mass)
           
 void setMomentOfInertia(double i)
           
 void setMovable(boolean movable)
          Makes an object movable or immovable.
 void setRotationalDamping(double rotationalDamping)
          Sets the rotational damping of the object.
 void setVelocity(Vector2f velocity)
           
 void startFrame()
          Called at the beginning when processPhysics is called for the body
 
Methods inherited from class vooga.physicsEngine.geometry.GeometricParameters
drawShape, getAbsoluteCoordinate, getAngularPosition, getCentroidPosition, getJavaShape, getShape, getTransformedArea, incrementAngularPosition, incrementPosition, setAngularPosition, setCentroidPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PhysicalParameters

public PhysicalParameters(Shape shape)
Called by outside users of physics module to create an encapsulation of a physical object with given Shape

Parameters:
shape -
Method Detail

notifyCollided

protected void notifyCollided(PhysicalParameters param)
Called when this PhysicalParameters collides with another.

Parameters:
param - the other Physicalparameters object that collided

inCollisionWith

public boolean inCollisionWith(PhysicalParameters param)
Check if the last time the physics engine updated the object, the object collided.

Parameters:
param -
Returns:

setVelocity

public void setVelocity(Vector2f velocity)
Parameters:
velocity - the velocity to set

getVelocity

public Vector2f getVelocity()
Returns:
the velocity

setAngularVelocity

public void setAngularVelocity(double angularVelocity)
Parameters:
angularVelocity - the angularVelocity to set

getAngularVelocity

public double getAngularVelocity()
Returns:
the angularVelocity

setMomentOfInertia

public void setMomentOfInertia(double i)
Parameters:
i - the moment of inertia

getMomentOfInertia

public double getMomentOfInertia()
If the moment of inertia is not explicitly set, then this will return an estimate based on the mass and the shape of the object.

Returns:
the moment of inertia

setElasticity

public void setElasticity(double elasticity)
Parameters:
elasticity - the elasticity to set

getElasticity

public double getElasticity()
Returns:
the elasticity

setFrictionCoefficient

public void setFrictionCoefficient(double frictionCoefficient)
Parameters:
frictionCoefficient - the frictionCoefficient to set

getFrictionCoefficient

public double getFrictionCoefficient()
Returns:
the frictionCoefficient

setConstantForce

public void setConstantForce(Vector2f constantForce)
Parameters:
constantForce - the force to set

getConstantAcceleration

public Vector2f getConstantAcceleration()
Returns:
the force

setConstantAcceleration

public void setConstantAcceleration(Vector2f constantAcceleration)
Apply a constant acceleration on the object. This is for if one wants to add gravity only to specific objects. For gravity, a magnitude of 0.00003 should be appropriate.

Parameters:
constantAcceleration -

setMass

public void setMass(double mass)
Parameters:
mass - the mass to set

getMass

public double getMass()
Returns:
the mass

getInvMass

protected double getInvMass()
Returns:

getInvI

protected double getInvI()
Returns:

startFrame

public void startFrame()
Called at the beginning when processPhysics is called for the body


endFrame

public void endFrame()
Called every time updatePosition is called for the body


setMovable

public void setMovable(boolean movable)
Makes an object movable or immovable. The physics engine will not seek to modify the position/rotation of an immovable object. (Essentially makes the object have infinite mass, infinite moment of inertia.)

Parameters:
movable - the movable to set

isMovable

public boolean isMovable()
Returns:
whether the Physicalparameters is movable

setConstantTorque

public void setConstantTorque(double constantTorque)
Apply a constant torque to the object.

Parameters:
constantTorque - the constantTorque to set

getConstantTorque

public double getConstantTorque()
Returns:
the constantTorque

incrementVelocity

public void incrementVelocity(Vector2f difference)
Adds to the current velocity.

Parameters:
difference - the delta change

incrementAngularVelocity

public void incrementAngularVelocity(double delta)
Adds to the current angular velocity.

Parameters:
delta -

applyImpulse

public void applyImpulse(Vector2f impulse)
Apply an instantaneous impulse on the object


applyAngularImpulse

public void applyAngularImpulse(double angularImpulse)
Apply an instantaneous angular impulse on the object


setDamping

public void setDamping(double damping)
Set the air translational damping of the object. (Damping of 1 makes object immovable, and damping of 0 removes all damping).

Parameters:
damping - the damping to set

getDamping

public double getDamping()
Returns:
the air translational damping of the object

getRotationalDamping

public double getRotationalDamping()
Returns:
the rotational damping of the object.

setRotationalDamping

public void setRotationalDamping(double rotationalDamping)
Sets the rotational damping of the object. Roughly, the angularVelocity of the object will undergo exponential decay with this parameter. 0 means no damping and 1 means complete damping (no rotation).

Parameters:
rotationalDamping - the rotationalDamping to set

getCollideSet

public java.util.Set<PhysicalParameters> getCollideSet()
Return the set of PhysicalParameters that the object is currently in collision with.

Returns: