|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsim.physics2D.PhysicsState
public class PhysicsState
PhysicsState holds the state of the physical objects in the system. The state consists of the state vector which holds the positions and velocities for all objects, the external forces vector which holds the force and torque accumulators for all objects, and the mass inverse matrix which holds the mass and mass moment of intertia inverses for all objects. Each of these variables is stored in blocks of 3 variables - x, y, and orientation. An object's position, external force, and mass inverse block starts at its index times 3. An object's velocity block starts at the number of objects in the system plus its index times 3. PhysicsState implements the "singleton" pattern so that any object can get a reference to the current PhysicsState object.
Field Summary | |
---|---|
Bag |
physObjs
|
Method Summary | |
---|---|
void |
addBody(PhysicalObject2D mobj)
Adds a physical object to the system, expanding all state matrices and vectors to accomodate it. |
void |
addExternalForce(Double2D force,
int index)
Adds a force to an object's force accumulator in the external forces vector |
void |
addExternalTorque(double torque,
int index)
Adds a torque to an object's torque accumulator in the external forces vector |
void |
backupCurrentPosition()
Copies the "current state" vector into the "saved state" vector. |
void |
clearAllForces()
Clears all forces and torques |
double |
getAngularVelocity(int index)
Returns an object's angular velocity |
Double2D |
getExternalForce(int index)
Returns an object's force accumulator |
Vector |
getExternalForcesVector()
Returns the external forces vector that holds the force and torque accumluators for every object in the system |
double |
getExternalTorque(int index)
Returns an object's torque accumulator |
static PhysicsState |
getInstance()
Returns the current PhysicsState instance |
double |
getLastAngularVelocity(int index)
Returns an object's angular velocity 1 timestep ago |
Angle |
getLastOrientation(int index)
Returns an object's orientation 1 timestep ago |
Double2D |
getLastPosition(int index)
Returns an object's last position 1 timestep ago |
Double2D |
getLastVelocity(int index)
Returns an object's linear velocity one timestep ago |
double |
getMassInverse(int index)
Returns an object's mass inverse |
DiagonalMatrix |
getMassInverseMatrix()
Returns the diagonal mass inverse matrix that contains the mass and mass moment of inertia inverses for all objects in the system |
double |
getMassMomentOfInertiaInverse(int index)
Returns an object's mass moment inertia inverse |
Angle |
getOrientation(int index)
Returns an object's orientation |
Double2D |
getPosition(int index)
Returns an object's position |
double |
getSavedAngularVelocity(int index)
Returns an object's backed up angular velocity |
Angle |
getSavedOrientation(int index)
Returns an object's backed up orientation |
Double2D |
getSavedPosition(int index)
Returns an object's backed up position. |
Double2D |
getSavedVelocity(int index)
Returns an object's backed up linear velocity |
Vector |
getStateVector()
Returns the state vector that contains the positions and velocities of all objects in the system |
Vector |
getStateVectorCopy()
Returns a copy of the state vector |
Double2D |
getVelocity(int index)
Returns an object's linear velocity |
int |
numObjs()
Returns the number of physical objects in the system |
static PhysicsState |
reset()
Resets the PhysicsState |
void |
restore()
Restores the state of the object to the last time "backupCurrentPosition" was run. |
void |
revertPosition()
Sets the state of the objects to what they were at the end of the previous timestep. |
void |
saveLastState()
Copies the "current state" vector into the "last state" vector. |
void |
setAngularVelocity(double angularVelocity,
int index)
Updates an object's angular velocity variable in the state vector |
void |
setMassInverse(double massInverse,
double massMomentOfInertiaInverse,
int index)
Updates an object's mass inverse variables in the mass inverse matrix |
void |
setOrientation(Angle orientation,
int index)
Updates an object's orientation variable in the state vector |
void |
setPosition(Double2D position,
int index)
Updates an object's position variables in the state vector |
void |
setStateVector(Vector stateVector)
Updates the state vector |
void |
setVelocity(Double2D velocity,
int index)
Updates an object's linear velocity variables in the state vector |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public Bag physObjs
Method Detail |
---|
public static PhysicsState getInstance()
public static PhysicsState reset()
public Vector getStateVector()
public void setStateVector(Vector stateVector)
public Vector getStateVectorCopy()
public void saveLastState()
public void revertPosition()
public void backupCurrentPosition()
public void restore()
public void setPosition(Double2D position, int index)
public Double2D getPosition(int index)
public Double2D getLastPosition(int index)
public Double2D getSavedPosition(int index)
public void setOrientation(Angle orientation, int index)
public Angle getOrientation(int index)
public Angle getLastOrientation(int index)
public Angle getSavedOrientation(int index)
public void setVelocity(Double2D velocity, int index)
public Double2D getVelocity(int index)
public Double2D getLastVelocity(int index)
public Double2D getSavedVelocity(int index)
public void setAngularVelocity(double angularVelocity, int index)
public double getAngularVelocity(int index)
public double getLastAngularVelocity(int index)
public double getSavedAngularVelocity(int index)
public Vector getExternalForcesVector()
public void addExternalForce(Double2D force, int index)
public Double2D getExternalForce(int index)
public void addExternalTorque(double torque, int index)
public double getExternalTorque(int index)
public void clearAllForces()
public DiagonalMatrix getMassInverseMatrix()
public void setMassInverse(double massInverse, double massMomentOfInertiaInverse, int index)
public double getMassInverse(int index)
public double getMassMomentOfInertiaInverse(int index)
public int numObjs()
public void addBody(PhysicalObject2D mobj)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |