sim.physics2D.physicalObject
Class MobileObject2D

java.lang.Object
  extended by SimplePortrayal2D
      extended by sim.physics2D.physicalObject.PhysicalObject2D
          extended by sim.physics2D.physicalObject.MobileObject2D
Direct Known Subclasses:
Robot

public abstract class MobileObject2D
extends PhysicalObject2D

MobileObject2D represents a physical object that can move.


Field Summary
protected  double coefficientOfFriction
           
protected  double coefficientOfStaticFriction
           
protected  double mass
           
protected  double massMomentOfInertia
           
 
Fields inherited from class sim.physics2D.physicalObject.PhysicalObject2D
coefficientOfRestitution, index, physicsState, shape
 
Constructor Summary
MobileObject2D()
           
 
Method Summary
 void addForce(Double2D force)
          Apply a force to the MobileObject
 void addFrictionForce()
          Calculates and adds the static and dynamic friction forces on the object based on the coefficients of friction.
 void addTorque(double torque)
          Apply a torque to the MobileObject
 double getAngularVelocity()
          How fast the object is rotating in radians per second.
 double getCoefficientOfFriction()
          Positive value representing the coefficient of friction of the object with the background surface.
 double getCoefficientOfStaticFriction()
          Positive value representing the coefficient of static friction of the object with the background surface.
 Double2D getForceAccumulator()
          Returns a vector that represents a combination of all the forces applied to it
 double getMass()
          Returns the object's mass
 double getMassInverse()
          1 / mass.
 double getMassMomentOfInertiaInverse()
          1 / massMomentOfInertia.
 double getTorqueAccumulator()
          Returns a number that represents a combination of all the torques applied to it
 Double2D getVelocity()
          Returns the object's velocity
 void resetLastPose()
          Move the object back to its previous location
 void restorePose()
          Restores an object to its current location
 void setAngularVelocity(double angularVelocity)
          How fast the object is rotating in radians per second.
 void setCoefficientOfFriction(double coefficientOfFriction)
          Positive value representing the coefficient of friction of the object with the background surface.
 void setCoefficientOfStaticFriction(double coefficientOfStaticFriction)
          Positive value representing the coefficient of static friction of the object with the background surface.
 void setMass(double mass)
          Sets an object's mass.
 void setShape(Shape shape, double mass)
          Set the shape of the object which determines how it is displayed, when it is colliding with another object, and how its mass moment of inertia is calculated
 void setVelocity(Double2D velocity)
          Updates the object's velocity
 void updatePose(double percent)
          Updates the pose to where the object would be in only a percentage of a time step.
 
Methods inherited from class sim.physics2D.physicalObject.PhysicalObject2D
draw, getCoefficientOfRestitution, getIndex, getOrientation, getPosition, getShape, handleCollision, setCoefficientOfRestitution, setIndex, setPose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

coefficientOfFriction

protected double coefficientOfFriction

coefficientOfStaticFriction

protected double coefficientOfStaticFriction

mass

protected double mass

massMomentOfInertia

protected double massMomentOfInertia
Constructor Detail

MobileObject2D

public MobileObject2D()
Method Detail

getMass

public double getMass()
Returns the object's mass


setMass

public void setMass(double mass)
Sets an object's mass. The mass moment of inertia is calculated by the object's associated shape


addForce

public void addForce(Double2D force)
Apply a force to the MobileObject


addTorque

public void addTorque(double torque)
Apply a torque to the MobileObject


getCoefficientOfFriction

public double getCoefficientOfFriction()
Positive value representing the coefficient of friction of the object with the background surface. 0 is no friction


setCoefficientOfFriction

public void setCoefficientOfFriction(double coefficientOfFriction)
Positive value representing the coefficient of friction of the object with the background surface. 0 is no friction


getCoefficientOfStaticFriction

public double getCoefficientOfStaticFriction()
Positive value representing the coefficient of static friction of the object with the background surface. 0 is no static friction


setCoefficientOfStaticFriction

public void setCoefficientOfStaticFriction(double coefficientOfStaticFriction)
Positive value representing the coefficient of static friction of the object with the background surface. 0 is no static friction


setShape

public void setShape(Shape shape,
                     double mass)
Set the shape of the object which determines how it is displayed, when it is colliding with another object, and how its mass moment of inertia is calculated


updatePose

public void updatePose(double percent)
Updates the pose to where the object would be in only a percentage of a time step. Useful for searching for exact moment of collision.

Specified by:
updatePose in class PhysicalObject2D

resetLastPose

public void resetLastPose()
Move the object back to its previous location

Specified by:
resetLastPose in class PhysicalObject2D

restorePose

public void restorePose()
Restores an object to its current location

Specified by:
restorePose in class PhysicalObject2D

getVelocity

public Double2D getVelocity()
Returns the object's velocity

Specified by:
getVelocity in class PhysicalObject2D

setVelocity

public void setVelocity(Double2D velocity)
Updates the object's velocity


getAngularVelocity

public double getAngularVelocity()
How fast the object is rotating in radians per second. A positive angular velocity means the object is rotating counter clockwise

Specified by:
getAngularVelocity in class PhysicalObject2D

setAngularVelocity

public void setAngularVelocity(double angularVelocity)
How fast the object is rotating in radians per second. A positive angular velocity means the object is rotating counter clockwise


getForceAccumulator

public Double2D getForceAccumulator()
Returns a vector that represents a combination of all the forces applied to it


getTorqueAccumulator

public double getTorqueAccumulator()
Returns a number that represents a combination of all the torques applied to it


getMassInverse

public double getMassInverse()
1 / mass. Used in collision response

Specified by:
getMassInverse in class PhysicalObject2D

getMassMomentOfInertiaInverse

public double getMassMomentOfInertiaInverse()
1 / massMomentOfInertia. Used in collision response

Specified by:
getMassMomentOfInertiaInverse in class PhysicalObject2D

addFrictionForce

public void addFrictionForce()
Calculates and adds the static and dynamic friction forces on the object based on the coefficients of friction.