fi.utu.cs.physics
Class MomentaryBody

java.lang.Object
  |
  +--fi.utu.cs.physics.Particle
        |
        +--fi.utu.cs.physics.Body
              |
              +--fi.utu.cs.physics.MomentaryBody

public abstract class MomentaryBody
extends Body

A moving physical body with mass, dimensionality and a finite lifetime. The lifetime is decreased each time the advance method is called. When lifetime becomes less than zero, the die method is executed.


Constructor Summary
protected MomentaryBody(double m, double r, double lt)
          Constructs a body with the mass m, the radius r and the lifetime lt.
protected MomentaryBody(double m, double r, double lt, Point2 p)
          Constructs a body with the mass m, the radius r, the lifetime lt and the position p.
protected MomentaryBody(double m, double r, double lt, Point2 p, Vector2 v)
          Constructs a body with the mass m, the radius r, the lifetime lt, the position p and the velocity v.
protected MomentaryBody(double m, double r, double lt, Point2 p, Vector2 v, Vector2 a)
          Constructs a body with the mass m, the radius r, the lifetime lt, the position p, the velocity v and the acceleration a.
 
Method Summary
 void advance(double dt)
          Advances the time dt seconds and updates the position, velocity and lifetime of the body accordingly.
abstract  void die()
          Realizes the death of this body.
 double getLifetime()
          Returns the remaining lifetime of this body.
 void setLifetime(double lt)
          Sets the lifetime to lt seconds.
 java.lang.String toString()
          Returns a string that contains the values of the attributes.
 
Methods inherited from class fi.utu.cs.physics.Body
elasticCollision, futurePosition, futureVelocity, getAcceleration, getMass, getPosition, getRadius, getVelocity, inelasticCollision, isColliding, isOverlapping, setAcceleration, setAcceleration, setMass, setPosition, setPosition, setRadius, setVelocity, setVelocity
 
Methods inherited from class fi.utu.cs.physics.Particle
addCollisionNotification, clearCollisionNotifications, getOwner, isCollisionNotified, isCollisionNotified, isCorporeal, removeCollisionNotification, setCorporeal, setEthereal, setOwner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MomentaryBody

protected MomentaryBody(double m,
                        double r,
                        double lt)
Constructs a body with the mass m, the radius r and the lifetime lt. The body resides in the origin and has a zero velocity and a zero acceleration. The body is corporeal and has no owner.


MomentaryBody

protected MomentaryBody(double m,
                        double r,
                        double lt,
                        Point2 p)
Constructs a body with the mass m, the radius r, the lifetime lt and the position p. The body has a zero velocity and a zero acceleration. The body is corporeal and has no owner.


MomentaryBody

protected MomentaryBody(double m,
                        double r,
                        double lt,
                        Point2 p,
                        Vector2 v)
Constructs a body with the mass m, the radius r, the lifetime lt, the position p and the velocity v. The body has a zero acceleration. The body is corporeal and has no owner.


MomentaryBody

protected MomentaryBody(double m,
                        double r,
                        double lt,
                        Point2 p,
                        Vector2 v,
                        Vector2 a)
Constructs a body with the mass m, the radius r, the lifetime lt, the position p, the velocity v and the acceleration a. The body is corporeal and has no owner.

Method Detail

getLifetime

public double getLifetime()
Returns the remaining lifetime of this body.


setLifetime

public void setLifetime(double lt)
Sets the lifetime to lt seconds.


advance

public void advance(double dt)
Advances the time dt seconds and updates the position, velocity and lifetime of the body accordingly.

Overrides:
advance in class Body
See Also:
Body.advance(double)

die

public abstract void die()
Realizes the death of this body.


toString

public java.lang.String toString()
Returns a string that contains the values of the attributes.

Overrides:
toString in class Body