JSci.physics
Class RigidBody2D

java.lang.Object
  extended byJSci.physics.Particle
      extended byJSci.physics.AbstractClassicalParticle
          extended byJSci.physics.ClassicalParticle2D
              extended byJSci.physics.RigidBody2D
All Implemented Interfaces:
java.io.Serializable

public class RigidBody2D
extends ClassicalParticle2D

The RigidBody2D class provides an object for encapsulating rigid bodies that live in 2D.

See Also:
Serialized Form

Field Summary
protected  double ang
          Angle (orientation).
protected  double angMass
          Moment of inertia.
protected  double angVel
          Angular velocity.
 
Fields inherited from class JSci.physics.ClassicalParticle2D
mass, vx, vy, x, y
 
Constructor Summary
RigidBody2D()
          Constructs a rigid body.
 
Method Summary
 RigidBody2D angularAccelerate(double a, double dt)
          Accelerates this particle.
 RigidBody2D angularCollide(RigidBody2D p, double e)
          Collides this particle with another.
 RigidBody2D applyForce(double fx, double fy, double x, double y, double dt)
          Applies a force acting at a point away from the centre of mass.
 RigidBody2D applyTorque(double T, double dt)
          Applies a torque to this particle.
 RigidBody2D collide(RigidBody2D p, double theta, double e)
          Collides this particle with another.
 double energy()
          Returns the kinetic and rotational energy.
 double getAngle()
          Returns the angle (orientation) of this body.
 double getAngularMomentum()
           
 double getAngularVelocity()
          Returns the angular velocity.
 double getMomentOfInertia()
          Returns the moment of inertia.
 ClassicalParticle2D move(double dt)
          Evolves this particle forward according to its kinematics.
 RigidBody2D rotate(double dt)
          Evolves this particle forward according to its rotational kinematics.
 void setAngle(double angle)
          Sets the angle (orientation) of this body.
 void setAngularMomentum(double angleMom)
           
 void setAngularVelocity(double angleVel)
          Sets the angular velocity.
 void setMomentOfInertia(double MoI)
          Sets the moment of inertia.
 
Methods inherited from class JSci.physics.ClassicalParticle2D
accelerate, applyForce, collide, getMass, getMomentum, getPosition, getVelocity, getXMomentum, getXPosition, getXVelocity, getYMomentum, getYPosition, getYVelocity, gravitate, setMass, setMomentum, setPosition, setVelocity, setXPosition, setYPosition, speed, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

angMass

protected double angMass
Moment of inertia.


ang

protected double ang
Angle (orientation).


angVel

protected double angVel
Angular velocity.

Constructor Detail

RigidBody2D

public RigidBody2D()
Constructs a rigid body.

Method Detail

setMomentOfInertia

public void setMomentOfInertia(double MoI)
Sets the moment of inertia.


getMomentOfInertia

public double getMomentOfInertia()
Returns the moment of inertia.


setAngle

public void setAngle(double angle)
Sets the angle (orientation) of this body.

Parameters:
angle - an angle in radians.

getAngle

public double getAngle()
Returns the angle (orientation) of this body.

Returns:
an angle in radians.

setAngularVelocity

public void setAngularVelocity(double angleVel)
Sets the angular velocity.


getAngularVelocity

public double getAngularVelocity()
Returns the angular velocity.


setAngularMomentum

public void setAngularMomentum(double angleMom)

getAngularMomentum

public double getAngularMomentum()

energy

public double energy()
Returns the kinetic and rotational energy.

Overrides:
energy in class ClassicalParticle2D

move

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

Overrides:
move in class ClassicalParticle2D
Returns:
this.

rotate

public RigidBody2D rotate(double dt)
Evolves this particle forward according to its rotational kinematics. This method changes the particle's orientation.

Returns:
this.

angularAccelerate

public RigidBody2D angularAccelerate(double a,
                                     double dt)
Accelerates this particle. This method changes the particle's angular velocity. It is additive, that is angularAccelerate(a1, dt).angularAccelerate(a2, dt) is equivalent to angularAccelerate(a1+a2, dt).

Returns:
this.

applyTorque

public RigidBody2D applyTorque(double T,
                               double dt)
Applies a torque to this particle. This method changes the particle's angular velocity. It is additive, that is applyTorque(T1, dt).applyTorque(T2, dt) is equivalent to applyTorque(T1+T2, dt).

Returns:
this.

applyForce

public RigidBody2D applyForce(double fx,
                              double fy,
                              double x,
                              double y,
                              double dt)
Applies a force acting at a point away from the centre of mass. Any resultant torques are also applied. This method changes the particle's angular velocity.

Parameters:
x - x-coordinate from centre of mass.
y - y-coordinate from centre of mass.
Returns:
this.

collide

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

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

angularCollide

public RigidBody2D angularCollide(RigidBody2D p,
                                  double e)
Collides this particle with another. This method calculates the resultant angular velocities.

Parameters:
e - coefficient of restitution.
Returns:
this.