JSci.physics
Class ClassicalParticle2D

java.lang.Object
  extended by JSci.physics.Particle
      extended by JSci.physics.AbstractClassicalParticle
          extended by JSci.physics.ClassicalParticle2D
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
RigidBody2D

public class ClassicalParticle2D
extends AbstractClassicalParticle

The ClassicalParticle2D class provides an object for encapsulating classical point particles that live in 2D.

See Also:
Serialized Form

Field Summary
protected  double mass
          Mass.
protected  double vx
          Velocity coordinates.
protected  double vy
          Velocity coordinates.
protected  double x
          Position coordinates.
protected  double y
          Position coordinates.
 
Constructor Summary
ClassicalParticle2D()
          Constructs a classical particle.
 
Method Summary
 ClassicalParticle2D accelerate(double ax, double ay, double dt)
          Accelerates this particle.
 ClassicalParticle2D applyForce(double Fx, double Fy, double dt)
          Applies a force to this particle.
 ClassicalParticle2D collide(ClassicalParticle2D p, double theta)
          Collides this particle with another (elastic collision).
 double energy()
          Returns the kinetic energy.
 double getMass()
          Returns the mass of this particle.
 AbstractDoubleVector getMomentum()
           
 AbstractDoubleVector getPosition()
           
 AbstractDoubleVector getVelocity()
           
 double getXMomentum()
           
 double getXPosition()
           
 double getXVelocity()
           
 double getYMomentum()
           
 double getYPosition()
           
 double getYVelocity()
           
 ClassicalParticle2D gravitate(ClassicalParticle2D p, double dt)
          Evolves two particles under their mutual gravitational attraction.
 ClassicalParticle2D move(double dt)
          Evolves this particle forward according to its kinematics.
 void setMass(double m)
          Sets the mass of this particle.
 void setMomentum(double xMom, double yMom)
          Sets the momentum of this particle.
 void setPosition(double xPos, double yPos)
          Sets the position of this particle.
 void setVelocity(double xVel, double yVel)
          Sets the velocity of this particle.
 void setXPosition(double xPos)
           
 void setYPosition(double yPos)
           
 double speed()
          Returns the speed of this particle.
 ClassicalParticle2D translate(double dt)
          Evolves this particle forward according to its linear kinematics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mass

protected double mass
Mass.


x

protected double x
Position coordinates.


y

protected double y
Position coordinates.


vx

protected double vx
Velocity coordinates.


vy

protected double vy
Velocity coordinates.

Constructor Detail

ClassicalParticle2D

public ClassicalParticle2D()
Constructs a classical particle.

Method Detail

setMass

public void setMass(double m)
Sets the mass of this particle.


getMass

public double getMass()
Returns the mass of this particle.

Specified by:
getMass in class AbstractClassicalParticle

setPosition

public void setPosition(double xPos,
                        double yPos)
Sets the position of this particle.


getPosition

public AbstractDoubleVector getPosition()
Specified by:
getPosition in class AbstractClassicalParticle

setXPosition

public void setXPosition(double xPos)

getXPosition

public double getXPosition()

setYPosition

public void setYPosition(double yPos)

getYPosition

public double getYPosition()

setVelocity

public void setVelocity(double xVel,
                        double yVel)
Sets the velocity of this particle.


getVelocity

public AbstractDoubleVector getVelocity()
Specified by:
getVelocity in class AbstractClassicalParticle

getXVelocity

public double getXVelocity()

getYVelocity

public double getYVelocity()

speed

public double speed()
Returns the speed of this particle.

Overrides:
speed in class AbstractClassicalParticle

setMomentum

public void setMomentum(double xMom,
                        double yMom)
Sets the momentum of this particle.


getMomentum

public AbstractDoubleVector getMomentum()
Overrides:
getMomentum in class AbstractClassicalParticle

getXMomentum

public double getXMomentum()

getYMomentum

public double getYMomentum()

energy

public double energy()
Returns the kinetic energy.

Overrides:
energy in class AbstractClassicalParticle

move

public ClassicalParticle2D move(double dt)
Evolves this particle forward according to its kinematics. This method changes the particle's position.

Returns:
this.

translate

public ClassicalParticle2D translate(double dt)
Evolves this particle forward according to its linear kinematics. This method changes the particle's position.

Returns:
this.

accelerate

public ClassicalParticle2D accelerate(double ax,
                                      double ay,
                                      double dt)
Accelerates this particle. This method changes the particle's velocity. It is additive, that is accelerate(a1, dt).accelerate(a2, dt) is equivalent to accelerate(a1+a2, dt).

Returns:
this.

applyForce

public ClassicalParticle2D applyForce(double Fx,
                                      double Fy,
                                      double dt)
Applies a force to this particle. This method changes the particle's velocity. It is additive, that is applyForce(F1, dt).applyForce(F2, dt) is equivalent to applyForce(F1+F2, dt).

Returns:
this.

gravitate

public ClassicalParticle2D gravitate(ClassicalParticle2D p,
                                     double dt)
Evolves two particles under their mutual gravitational attraction. This method changes the velocity of both particles.

Returns:
this.

collide

public ClassicalParticle2D collide(ClassicalParticle2D p,
                                   double theta)
Collides this particle with another (elastic collision). This method calculates the resultant velocities.

Parameters:
theta - centre of mass deflection angle.
Returns:
this.