gizmoball.physics
Class PhysicsTorus

java.lang.Object
  extended by gizmoball.physics.PhysicsTorus
All Implemented Interfaces:
PhysicsObject, PrimitivesCollection

public class PhysicsTorus
extends java.lang.Object
implements PhysicsObject

A PhysicsTorus is a wrapper class for a three dimensional representation of a torus.

Specification Fields :
torus : Torus // the torus that is wrapped in this

Constructor Summary
PhysicsTorus(double radiusFromCenter, double radiusOfTube, Vect3 center, Vect3 orientation, double reflectionCoeff, double mass, Vect3 velocity)
          Creates a new PhysicsTorus without rotation or texture
PhysicsTorus(double radiusFromCenter, double radiusOfTube, Vect3 center, Vect3 orientation, double reflectionCoeff, double mass, Vect3 velocity, java.lang.String texture)
          Creates a new PhysicsTorus without rotation
PhysicsTorus(double radiusFromCenter, double radiusOfTube, Vect3 center, Vect3 orientation, double reflectionCoeff, double mass, Vect3 rotCenter, Vect3 rotOmega, Vect3 velocity)
          Creates a new PhysicsTorus without texture
PhysicsTorus(double radiusFromCenter, double radiusOfTube, Vect3 center, Vect3 orientation, double reflectionCoeff, double mass, Vect3 rotCenter, Vect3 rotOmega, Vect3 velocity, java.lang.String texture)
          Creates a new PhysicsTorus
 
Method Summary
 boolean containsPoint(Vect3 p)
          Returns whether p is in this.
 Vect3 getBCenter()
           
 Vect3Pair getBoundingBox()
           
 double getBRadius()
           
 java.util.Collection<LateralCylinder> getLateralCylinders()
           
 double getMass()
           
 java.util.Collection<PlaneCircle> getPlaneCircles()
           
 java.util.Collection<PlanePolygon> getPlanePolygons()
           
 Vect3 getPosition()
           
 double getReflectionCoeff()
           
 Vect3 getRotCenter()
           
 Vect3 getRotOmega()
           
 java.util.Collection<Sphere> getSpheres()
           
 java.util.Collection<Torus> getTori()
           
 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PhysicsTorus

public PhysicsTorus(double radiusFromCenter,
                    double radiusOfTube,
                    Vect3 center,
                    Vect3 orientation,
                    double reflectionCoeff,
                    double mass,
                    Vect3 rotCenter,
                    Vect3 rotOmega,
                    Vect3 velocity,
                    java.lang.String texture)
Creates a new PhysicsTorus

Parameters:
radiusFromCenter - the radius of the torus about its center
radiusOfTube - the radius of a cross-section of the torus tube
center - the center of the torus
orientation - a vector normal to the plane of the center of the torus
reflectionCoeff - the coefficient of reflection of the torus
mass - the mass of the torus
rotCenter - the center of rotation of the torus
rotOmega - the angular velocity of the torus
velocity - the velocity of rotCenter
texture - the texture of the torus
Requires:
(center != null) && (orientation != null) && (rotCenter != null) && (rotOmega != null) && (velocity != null) && (mass >= 0) && (0 <= reflectionCoeff <= 1) && (radiusOfTube >= 0) && (radiusFromCenter >= 0) && (orientation.rho > 0)
Effects:
creates a PhysicsTorus pt such that: pt.torus.center = center && pt.torus.orientation = orientation && pt.torus.radiusFromCenter = radiusFromCenter && pt.torus.radiusOfTube = radiusOfTube && pt.reflectionCoeff = reflectionCoeff && pt.mass = mass && pt.rotCenter = rotCenter && pt.rotOmega = rotOmega && pt.velocity = velocity && pt.bcenter = center && pt.bradius = radiusFromCenter + radiusOfTube + 0.1

PhysicsTorus

public PhysicsTorus(double radiusFromCenter,
                    double radiusOfTube,
                    Vect3 center,
                    Vect3 orientation,
                    double reflectionCoeff,
                    double mass,
                    Vect3 rotCenter,
                    Vect3 rotOmega,
                    Vect3 velocity)
Creates a new PhysicsTorus without texture

Parameters:
radiusFromCenter - the radius of the torus about its center
radiusOfTube - the radius of a cross-section of the torus tube
center - the center of the torus
orientation - a vector normal to the plane of the center of the torus
reflectionCoeff - the coefficient of reflection of the torus
mass - the mass of the torus
rotCenter - the center of rotation of the torus
rotOmega - the angular velocity of the torus
velocity - the velocity of rotCenter
Requires:
(center != null) && (orientation != null) && (rotCenter != null) && (rotOmega != null) && (velocity != null) && (mass >= 0) && (0 <= reflectionCoeff <= 1) && (radiusOfTube >= 0) && (radiusFromCenter >= 0) && (orientation.rho > 0)
Effects:
creates a PhysicsTorus pt such that: pt.torus.center = center && pt.torus.orientation = orientation && pt.torus.radiusFromCenter = radiusFromCenter && pt.torus.radiusOfTube = radiusOfTube && pt.reflectionCoeff = reflectionCoeff && pt.mass = mass && pt.rotCenter = rotCenter && pt.rotOmega = rotOmega && pt.velocity = velocity && pt.bcenter = center && pt.bradius = radiusFromCenter + radiusOfTube + 0.1

PhysicsTorus

public PhysicsTorus(double radiusFromCenter,
                    double radiusOfTube,
                    Vect3 center,
                    Vect3 orientation,
                    double reflectionCoeff,
                    double mass,
                    Vect3 velocity,
                    java.lang.String texture)
Creates a new PhysicsTorus without rotation

Effects:
creates a new PhysicsTorus such that: rotCenter = center && rotOmega = Vect3.ZERO

PhysicsTorus

public PhysicsTorus(double radiusFromCenter,
                    double radiusOfTube,
                    Vect3 center,
                    Vect3 orientation,
                    double reflectionCoeff,
                    double mass,
                    Vect3 velocity)
Creates a new PhysicsTorus without rotation or texture

Effects:
creates a new PhysicsTorus such that: rotCenter = center && rotOmega = Vect3.ZERO
Method Detail

containsPoint

public boolean containsPoint(Vect3 p)
Description copied from interface: PhysicsObject
Returns whether p is in this.

Specified by:
containsPoint in interface PhysicsObject
Returns:
true if the distance from p to this is less than GameConstants.TOLERANCE

getBCenter

public Vect3 getBCenter()
Specified by:
getBCenter in interface PhysicsObject
Returns:
this.bcenter

getBRadius

public double getBRadius()
Specified by:
getBRadius in interface PhysicsObject
Returns:
this.bradius

getMass

public double getMass()
Specified by:
getMass in interface PhysicsObject
Returns:
this.mass

getPosition

public Vect3 getPosition()
Specified by:
getPosition in interface PhysicsObject
Returns:
this.position

getReflectionCoeff

public double getReflectionCoeff()
Specified by:
getReflectionCoeff in interface PhysicsObject
Returns:
this.reflectionCoeff

getRotCenter

public Vect3 getRotCenter()
Specified by:
getRotCenter in interface PhysicsObject
Returns:
this.rotCenter

getRotOmega

public Vect3 getRotOmega()
Specified by:
getRotOmega in interface PhysicsObject
Returns:
this.rotOmega

getVelocity

public Vect3 getVelocity()
Specified by:
getVelocity in interface PhysicsObject
Returns:
this.velocity

minDistanceToObjectFromP

public double minDistanceToObjectFromP(Vect3 p)
Description copied from interface: PhysicsObject
Returns the minimum distance from p to this

Specified by:
minDistanceToObjectFromP in interface PhysicsObject
Returns:
the minimum distance from p to this

reflect

public Vect3 reflect(PhysicsSphere ps)
Specified by:
reflect in interface PhysicsObject
Returns:
the velocity of ps reflected off of this

setMass

public void setMass(double m)
Specified by:
setMass in interface PhysicsObject

setPosition

public void setPosition(Vect3 pos)
Specified by:
setPosition in interface PhysicsObject

setReflectionCoeff

public void setReflectionCoeff(double rc)
Specified by:
setReflectionCoeff in interface PhysicsObject

setRotCenter

public void setRotCenter(Vect3 rc)
Specified by:
setRotCenter in interface PhysicsObject

setRotOmega

public void setRotOmega(Vect3 ro)
Specified by:
setRotOmega in interface PhysicsObject

setVelocity

public void setVelocity(Vect3 vel)
Specified by:
setVelocity in interface PhysicsObject

rotateAboutAxis

public void rotateAboutAxis(Vect3 center,
                            Vect3 axis,
                            double angle)
Specified by:
rotateAboutAxis in interface PhysicsObject

timeUntilCollision

public double timeUntilCollision(PhysicsSphere ball,
                                 double lookahead)
Description copied from interface: PhysicsObject
Returns the time until a collision between ball and this

Specified by:
timeUntilCollision in interface PhysicsObject
Returns:
the time until collision or POSITIVE_INFINITY if the collision will not occur

update

public void update(double timestep)
Updates the state of this after the passage of timestep.

Specified by:
update in interface PhysicsObject
Requires:
timestep >= 0
Effects:
this.rotCenter_post = this.rotCenter_pre + this.velocity * timestep this.position_post = this.rotCenter_post + this.rotOmega x (this.position_pre - this.rotCenter_pre)* timestep

getLateralCylinders

public java.util.Collection<LateralCylinder> getLateralCylinders()
Specified by:
getLateralCylinders in interface PrimitivesCollection
Returns:
this.lateralCylinders

getPlaneCircles

public java.util.Collection<PlaneCircle> getPlaneCircles()
Specified by:
getPlaneCircles in interface PrimitivesCollection
Returns:
this.planeCircles

getPlanePolygons

public java.util.Collection<PlanePolygon> getPlanePolygons()
Specified by:
getPlanePolygons in interface PrimitivesCollection
Returns:
this.planePolygons

getSpheres

public java.util.Collection<Sphere> getSpheres()
Specified by:
getSpheres in interface PrimitivesCollection
Returns:
this.spheres

getTori

public java.util.Collection<Torus> getTori()
Specified by:
getTori in interface PrimitivesCollection
Returns:
this.tori

getBoundingBox

public Vect3Pair getBoundingBox()
Specified by:
getBoundingBox in interface PhysicsObject
Returns:
a bounding box consisting of one Vect3 with smaller coordinates and one Vect3 with larger coordinates