gizmoball.physics
Interface PhysicsObject

All Superinterfaces:
PrimitivesCollection
All Known Implementing Classes:
PhysicsCircle, PhysicsLateralCylinder, PhysicsPolygon, PhysicsSphere, PhysicsTorus

public interface PhysicsObject
extends PrimitivesCollection

A PhysicsObject represents a translating and rotating physics object in 3D space along with its associated bounding sphere.

A PhysicsObject wraps PlanePolygon, PlaneCircle, Sphere, LateralCylinder, and Torus, the basic physics primitives in the Physics3D library.

A PhysicsObject rotates about a rotation center in 3 space with some angular velocity. This rotation center moves with some velocity. A PhysicsObject is able to update its own state in the absence of external forces.

A PhysicsObject detects collisions between PhysicsSphereS and itself.

Specification Fields

Method Summary
 boolean containsPoint(Vect3 p)
          Returns whether p is in this.
 Vect3 getBCenter()
           
 Vect3Pair getBoundingBox()
           
 double getBRadius()
           
 double getMass()
           
 Vect3 getPosition()
           
 double getReflectionCoeff()
           
 Vect3 getRotCenter()
           
 Vect3 getRotOmega()
           
 Vect3 getVelocity()
           
 double minDistanceToObjectFromP(Vect3 p)
          Returns the minimum distance from p to this
 Vect3 reflect(PhysicsSphere ps)
           
 void rotateAboutAxis(Vect3 center, Vect3 axis, double angle)
           
 void setMass(double m)
           
 void setPosition(Vect3 pos)
           
 void setReflectionCoeff(double rc)
           
 void setRotCenter(Vect3 rc)
           
 void setRotOmega(Vect3 ro)
           
 void setVelocity(Vect3 vel)
           
 double timeUntilCollision(PhysicsSphere ball, double lookahead)
          Returns the time until a collision between ball and this
 void update(double timestep)
          Updates the state of this after the passage of timestep.
 
Methods inherited from interface gizmoball.physics.PrimitivesCollection
getLateralCylinders, getPlaneCircles, getPlanePolygons, getSpheres, getTori
 

Method Detail

minDistanceToObjectFromP

double minDistanceToObjectFromP(Vect3 p)
Returns the minimum distance from p to this

Returns:
the minimum distance from p to this
Requires:
p!= null

timeUntilCollision

double timeUntilCollision(PhysicsSphere ball,
                          double lookahead)
Returns the time until a collision between ball and this

Returns:
the time until collision or POSITIVE_INFINITY if the collision will not occur
Effects:
computes the time until ball and this, travelling at their current specified velocities, collide. If no collision will occur POSITIVE_INFINITY is returned. This method assumes that both objects will travel at constant velocity until impact.

containsPoint

boolean containsPoint(Vect3 p)
Returns whether p is in this.

Returns:
true if the distance from p to this is less than GameConstants.TOLERANCE
Requires:
p!= null

getBCenter

Vect3 getBCenter()
Returns:
this.bcenter

getBRadius

double getBRadius()
Returns:
this.bradius

getRotCenter

Vect3 getRotCenter()
Returns:
this.rotCenter

getVelocity

Vect3 getVelocity()
Returns:
this.velocity

getRotOmega

Vect3 getRotOmega()
Returns:
this.rotOmega

getPosition

Vect3 getPosition()
Returns:
this.position

getMass

double getMass()
Returns:
this.mass

getReflectionCoeff

double getReflectionCoeff()
Returns:
this.reflectionCoeff

setReflectionCoeff

void setReflectionCoeff(double rc)
Requires:
0 <= rc <= 1
Effects:
this.reflectionCoeff = rc

setMass

void setMass(double m)
Requires:
m >= 0 || m = Double.PositiveInfinity
Effects:
this.mass = m

setRotCenter

void setRotCenter(Vect3 rc)
Requires:
rc != null
Effects:
this.rotCenter = rc

setVelocity

void setVelocity(Vect3 vel)
Requires:
vel != null
Effects:
this.velocity = vel

setRotOmega

void setRotOmega(Vect3 ro)
Requires:
ro != null
Effects:
this.rotOmega = ro

setPosition

void setPosition(Vect3 pos)
Requires:
pos != null
Effects:
this.position = pos

rotateAboutAxis

void rotateAboutAxis(Vect3 center,
                     Vect3 axis,
                     double angle)
Requires:
pos != null
Effects:
rotates this about the axis through center and axis by angle

update

void update(double timestep)
Updates the state of this after the passage of timestep. Uses the Geometry3D library for rotations

Requires:
timestep >= 0
Effects:
this.rotCenter_post = this.rotCenter_pre + this.velocity * timestep this.position_post = this.rotCenter_post + (this.position_pre - this.rotCenter_pre) rotated for timestep

reflect

Vect3 reflect(PhysicsSphere ps)
Returns:
the velocity of ps reflected off of this

getBoundingBox

Vect3Pair getBoundingBox()
Returns:
a bounding box consisting of one Vect3 with smaller coordinates and one Vect3 with larger coordinates