net.jinx.physics
Class PhysicalObject

java.lang.Object
  extended by net.jinx.physics.PhysicalObject

public class PhysicalObject
extends java.lang.Object


Constructor Summary
PhysicalObject()
           
 
Method Summary
 void accumulateForce(Vector force)
          Applies a non-rotational force to this PhysicalObject.
 void accumulateForce(Vector force, Vector p)
          Applies a possibly rotational force to this PhysicalObject.
 Contact[] finalContacts()
          Provides the final Contacts for this PhysicalObject, after all calculations for position have been completed by a Universe.
 Vector getDeltaPosition()
           
 Vector getDeltaVelocity()
           
 float getMass()
          Returns the mass of this PhysicalObject.
 Vector getPosition()
          Provides the position of the center of mass for this PhysicalObject.
 Tag getTag(java.lang.String name)
          Gets the Tag associated with the given name.
 Vector getVelocity()
          Provides the velocity of this PhysicalObject.
 boolean hasContact(Contact c)
           
 Contact lastContact()
          Provides the most recent (possibly incomplete) Contact still being used for calculating position on this PhysicalObject.
 float lastContactTime()
          Provides the time value of the most recent (possibly incomplete) Contact still being used for calculating position on this PhysicalObject.
 Contact lastFinishedContact()
          Provides the most recent complete Contact still being used for calculating position on this PhysicalObject.
 float lastFinishedContactTime()
          Provides the time value of the most recent complete Contact still being used for calculating position on this PhysicalObject.
 Vector positionAt(float i, float deltaTime)
           
 void removeTag(java.lang.String name)
          Removes the Tag with the given name.
 void removeTag(Tag tag)
          Removes the Tag with the same name as Tag.
 void setDeltaPosition(Vector deltaPosition)
          This is change in position over the time step used, not velocity!
 void setDeltaVelocity(Vector deltaVelocity)
          This is change in velocity over the time step used, not plain acceleration!
 void setMass(float mass)
          Sets the mass of this PhysicalObject.
 void setPosition(Vector position)
          Sets the position of the center of mass for this PhysicalObject object.
 void setVelocity(Vector velocity)
          Sets the velocity of this PhysicalObject.
 void tag(Tag tag)
          Attaches a Tag to this PhysicalObject, replacing any existing Tag with the same name.
 Vector velocityAt(float i, float deltaTime)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PhysicalObject

public PhysicalObject()
Method Detail

setPosition

public void setPosition(Vector position)
Sets the position of the center of mass for this PhysicalObject object.

Parameters:
position - the center of mass in world coordinates.

getPosition

public Vector getPosition()
Provides the position of the center of mass for this PhysicalObject.

Returns:
the center of mass in world coordinates.

positionAt

public Vector positionAt(float i,
                         float deltaTime)

velocityAt

public Vector velocityAt(float i,
                         float deltaTime)

setDeltaPosition

public void setDeltaPosition(Vector deltaPosition)
This is change in position over the time step used, not velocity!

Parameters:
deltaPosition - the change in position for the time step.

getDeltaPosition

public Vector getDeltaPosition()

setVelocity

public void setVelocity(Vector velocity)
Sets the velocity of this PhysicalObject.

Parameters:
velocity - the new velocity.

setDeltaVelocity

public void setDeltaVelocity(Vector deltaVelocity)
This is change in velocity over the time step used, not plain acceleration!

Parameters:
deltaVelocity - the change in velocity for the time step.

getDeltaVelocity

public Vector getDeltaVelocity()

getVelocity

public Vector getVelocity()
Provides the velocity of this PhysicalObject.

Returns:
the velocity as a Vector.

setMass

public void setMass(float mass)
Sets the mass of this PhysicalObject.

Parameters:
mass - the new mass for this PhysicalObject.

getMass

public float getMass()
Returns the mass of this PhysicalObject.

Returns:
the mass of this PhysicalObject.

tag

public void tag(Tag tag)
Attaches a Tag to this PhysicalObject, replacing any existing Tag with the same name.


getTag

public Tag getTag(java.lang.String name)
Gets the Tag associated with the given name.

Parameters:
name - the name of the tag.
Returns:
the Tag or null.

removeTag

public void removeTag(java.lang.String name)
Removes the Tag with the given name.

Parameters:
name - the name of the Tag.

removeTag

public void removeTag(Tag tag)
Removes the Tag with the same name as Tag.

Parameters:
tag - the Tag.

accumulateForce

public void accumulateForce(Vector force)
Applies a non-rotational force to this PhysicalObject. This should only be called by Force instances. If you need a force applied, you have to apply it via a Force, since certain types of Integrator objects will apply the same forces multiple times with different positions (RK4Integrator does this).

Parameters:
force - the force itself, in Newtons.

accumulateForce

public void accumulateForce(Vector force,
                            Vector p)
Applies a possibly rotational force to this PhysicalObject. This should only be called by Force instances. If you need a force applied, you have to apply it via a Force, since certain types of Integrator objects will apply the same forces multiple times with different positions (RK4Integrator does this).

Parameters:
force - the force itself, in Newtons.
p - the point in the PhysicalObject's object space.

hasContact

public boolean hasContact(Contact c)

lastContact

public Contact lastContact()
Provides the most recent (possibly incomplete) Contact still being used for calculating position on this PhysicalObject. Final Contacts are not available this way.

Returns:
the Contact with the highest time value.
Throws:
java.util.NoSuchElementException - if there are no Contacts still in use.

lastFinishedContact

public Contact lastFinishedContact()
Provides the most recent complete Contact still being used for calculating position on this PhysicalObject. Final Contacts are not available this way.

Returns:
the Contact with the highest time value.
Throws:
java.util.NoSuchElementException - if there are no Contacts still in use.

lastContactTime

public float lastContactTime()
Provides the time value of the most recent (possibly incomplete) Contact still being used for calculating position on this PhysicalObject. Time values for final Contacts are not available this way.

Returns:
the highest time value.
Throws:
java.util.NoSuchElementException - if there are no Contacts still in use.

lastFinishedContactTime

public float lastFinishedContactTime()
Provides the time value of the most recent complete Contact still being used for calculating position on this PhysicalObject. Time values for final Contacts are not available this way.

Returns:
the highest time value.
Throws:
java.util.NoSuchElementException - if there are no Contacts still in use.

finalContacts

public Contact[] finalContacts()
Provides the final Contacts for this PhysicalObject, after all calculations for position have been completed by a Universe. They will be in order based on when they occured, from first to last.

Returns:
the array of Contacts.