physics3d
Class Geometry3D

java.lang.Object
  extended by physics3d.Geometry3D

public class Geometry3D
extends Object

The Geometry3D library contains procedural abstractions which are useful in modeling the physical interactions between various 3 dimensional objects.

The library is described in terms of these concepts:

The intended use of the Geometry3D library is as follows:

  1. The client calls the timeUntilCollision() methods to calculate the times at which the ball(s) will collide with each of the bouncers or with another ball. The minimum of all these times (call it "mintime") is the time of the next collision.
  2. The client updates the position of the ball(s) and the bouncers to account for mintime passing. At this point, the ball and the object it is about to hit are exactly adjacent to one another.
  3. The client calls the appropriate reflect() method to calculate the change in the ball's velocity.
  4. The client updates the ball's velocity and repeats back to step 1.

The timeUntilCollision() methods assume constant ball velocity. That is, no force will be acting on the ball, so it will follow a straight-line path. Therefore, if external forces (such as gravity or friction) need to be accounted for, the client must do so before or after the of the "time until / update position / reflect" series of steps - never inbetween those three steps.

Important note: The methods which deal with plane polygon, plane circle and lateral cylinder bouncers do NOT deal with the edges of these surfaces. To ensure realistic behavior, shapes should be constructed from a combination of plane polygons, plane circles, lateral cylinders, spheres and tori. To connect plane polygons together, have zero radius cylinders at the edges and zero radius spheres on the points. To connect plane circles to lateral cylinders, put a zero tube raius torus on the ring.

For example: A ball is located at (0,0,1.5) and is moving in the (1,1,0) direction towards a unit cube parallel to all 3 axes with minimum (x,y,z) = (1,1,1) The ball will hit the ends of both faces at a 45 degree angle and something REALLY WEIRD will happen. However, if a cylinder with zero radius is placed along the edges of the cube, then the ball will bounce off the cylinder in the expected manner. Likewise for points and tori.

Specification Fields

Field Summary
protected  double maximumForesight
           
protected  int numSubIntervals
           
 
Constructor Summary
Geometry3D()
           
Geometry3D(double maximumForesight, int numSubIntervals)
           
 
Method Summary
 Vect3 applyReflectionCoeff(Vect3 incidentVect, Vect3 reflectedVect, double rCoeff)
          Accounts for the effects of inelastic collisions given the intial and resulting velocities of the collision assuming elasticity.
 Vect3 findCylinderNormalToBall(LateralCylinder cyl, Sphere ball)
           
 Vect3 findSphereNormalToBall(Sphere sphere, Sphere ball)
           
 Vect3 findTorusNormalToBall(Torus torus, Sphere ball)
           
 double getMaximumForesight()
           
 int getNumSubIntervals()
           
 double minQuadraticSolution(double a, double b, double c)
           
 Vect3 pointWherePlaneIntersectsLine(Plane plane, Line line)
          METHODS FOR STATIONARY OBJECTS
 Vect3 reflect(PhysicsShape nextShape, Sphere ball, Vect3 velocity, double coref)
          convenience method: calls the appropriate reflect method
 Vect3 reflectLateralCylinder(LateralCylinder cyl, Sphere ball, Vect3 velocity)
          Computes the new velocity of a ball reflecting off of a lateral cylinder.
 Vect3 reflectLateralCylinder(LateralCylinder cyl, Sphere ball, Vect3 velocity, double reflectionCoeff)
          Computes the new velocity of a ball reflecting off of a lateral cylinder.
 Vect3 reflectPlaneCircle(PlaneCircle circle, Sphere ball, Vect3 velocity)
          Computes the new velocity of a ball reflecting off of a plane circle.
 Vect3 reflectPlaneCircle(PlaneCircle circle, Sphere ball, Vect3 velocity, double reflectionCoeff)
          Computes the new velocity of a ball reflecting off of a plane circle.
 Vect3 reflectPlanePolygon(PlanePolygon polygon, Sphere ball, Vect3 velocity)
          Computes the new velocity of a ball reflecting off of a plane polygon.
 Vect3 reflectPlanePolygon(PlanePolygon polygon, Sphere ball, Vect3 velocity, double reflectionCoeff)
          Computes the new velocity of a ball reflecting off of a plane polygon.
 Vect3 reflectRotating(PhysicsShape nextShape, Vect3 center, Vect3 angularVel, Sphere ball, Vect3 velocity, double coref)
          convenience method: calls the appropriate reflect method
 Vect3 reflectRotatingLateralCylinder(LateralCylinder cyl, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity)
          Computes the new velocity of a sphere reflected off of a rotating lateral cylinder.
 Vect3 reflectRotatingLateralCylinder(LateralCylinder cyl, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity, double reflectionCoeff)
          Computes the new velocity of a sphere reflected off of a rotating lateral cylinder.
 Vect3 reflectRotatingPlaneCircle(PlaneCircle circle, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity)
          Computes the new velocity of a sphere reflected off of a rotating plane circle.
 Vect3 reflectRotatingPlaneCircle(PlaneCircle circle, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity, double reflectionCoeff)
          Computes the new velocity of a sphere reflected off of a rotating plane circle.
 Vect3 reflectRotatingPlanePolygon(PlanePolygon polygon, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity)
          Computes the new velocity of a sphere reflected off of a rotating plane polygon.
 Vect3 reflectRotatingPlanePolygon(PlanePolygon polygon, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity, double reflectionCoeff)
          Computes the new velocity of a sphere reflected off of a rotating plane polygon.
 Vect3 reflectRotatingSphere(Sphere sphere, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity)
          Computes the new velocity of a sphere reflected off of a rotating sphere.
 Vect3 reflectRotatingSphere(Sphere sphere, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity, double reflectionCoeff)
          Computes the new velocity of a sphere reflected off of a rotating sphere.
 Vect3 reflectRotatingTorus(Torus torus, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity)
          Computes the new velocity of a sphere reflected off of a rotating torus.
 Vect3 reflectRotatingTorus(Torus torus, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity, double reflectionCoeff)
          Computes the new velocity of a sphere reflected off of a rotating torus.
 Vect3 reflectSphere(Sphere sphere, Sphere ball, Vect3 velocity)
          Computes the new velocity of a ball reflecting off of a sphere.
 Vect3 reflectSphere(Sphere sphere, Sphere ball, Vect3 velocity, double reflectionCoeff)
          Computes the new velocity of a ball reflecting off of a sphere.
 Vect3Pair reflectSpheres(Sphere sphere1, double mass1, Vect3 velocity1, Sphere sphere2, double mass2, Vect3 velocity2)
          Computes the resulting velocities of two spheres which collide.
 Vect3 reflectTorus(Torus torus, Sphere ball, Vect3 velocity)
          Computes the new velocity of a ball reflecting off of a torus.
 Vect3 reflectTorus(Torus torus, Sphere ball, Vect3 velocity, double reflectionCoeff)
          Computes the new velocity of a ball reflecting off of a torus.
 void setForesightAndSubintervals(double maximumForesight, int numSubIntervals)
          Modifies the behavior of this class to use the specified maximumForesight & numSubIntervals.
 double timeUntilCollision(PhysicsShape nextShape, Sphere ball, Vect3 velocity)
          convenience method: calls the appropriate timeUntilCollision method
 double timeUntilLateralCylinderCollision(LateralCylinder cyl, Sphere ball, Vect3 velocity)
          Computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified lateral cylinder.
 double timeUntilPlaneCircleCollision(PlaneCircle circle, Sphere ball, Vect3 velocity)
          Computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified plane circle.
 double timeUntilPlanePolygonCollision(PlanePolygon polygon, Sphere ball, Vect3 velocity)
          Computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified plane polygon.
 double timeUntilRotatingCollision(PhysicsShape shape, Vect3 center, Vect3 angularVel, Sphere ballShape, Vect3 velocity)
           
 double timeUntilRotatingLateralCylinderCollision(LateralCylinder cyl, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity)
          Computes the time until a ball travelling at a specified velocity collides with a rotating lateral cylinder.
 double timeUntilRotatingPlaneCircleCollision(PlaneCircle circle, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity)
          Computes the time until a ball travelling at a specified velocity collides with a rotating plane circle.
 double timeUntilRotatingPlanePolygonCollision(PlanePolygon polygon, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity)
          Computes the time until a ball travelling at a specified velocity collides with a rotating plane polygon.
 double timeUntilRotatingSphereCollision(Sphere sphere, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity)
          Computes the time until a ball travelling at a specified velocity collides with a rotating sphere.
 double timeUntilRotatingTorusCollision(Torus torus, Vect3 center, Vect3 angularVelocity, Sphere ball, Vect3 velocity)
          Computes the time until a ball travelling at a specified velocity collides with a rotating torus.
 double timeUntilSphereCollision(Sphere sphere, Sphere ball, Vect3 velocity)
          Computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified sphere.
 double timeUntilSphereSphereCollision(Sphere sphere1, Vect3 vel1, Sphere sphere2, Vect3 vel2)
          Computes the time until two spheres collide.
 double timeUntilTorusCollision(Torus torus, Sphere ball, Vect3 velocity)
          Computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified torus.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maximumForesight

protected double maximumForesight

numSubIntervals

protected int numSubIntervals
Constructor Detail

Geometry3D

public Geometry3D()
Effects:
Constructs a Geometry3D with the default tuning parameters as described in the class overview.

Geometry3D

public Geometry3D(double maximumForesight,
                  int numSubIntervals)
Requires:
(maximumForesight >= 0.0) && (numSubIntervals >= 1)
Effects:
Constructs a Geometry3D with the specified tuning parameters as described in the class overview.
Method Detail

setForesightAndSubintervals

public void setForesightAndSubintervals(double maximumForesight,
                                        int numSubIntervals)
Modifies the behavior of this class to use the specified maximumForesight & numSubIntervals.

Parameters:
maximumForesight - The maximal time in the future that a collision will be searched for. Collisions may still be returned that happen farther than maximumForesight in the future, but no extra effort will be made to find them.
numSubIntervals - used to find roots of polynomials. Finding roots is linear in time with the number of sub intervals, but too few intervals could lead to missing a root.

getMaximumForesight

public double getMaximumForesight()
Returns:
the maximum foresight measured in seconds, used for geometry calculations

getNumSubIntervals

public int getNumSubIntervals()
Returns:
the number of subintervals used when searching an interval for a collision. This affects all rotating methods and the stationary torus collision.

minQuadraticSolution

public double minQuadraticSolution(double a,
                                   double b,
                                   double c)

applyReflectionCoeff

public Vect3 applyReflectionCoeff(Vect3 incidentVect,
                                  Vect3 reflectedVect,
                                  double rCoeff)
Accounts for the effects of inelastic collisions given the intial and resulting velocities of the collision assuming elasticity.

Parameters:
incidentVect - the intial velocity of the ball
reflectedVect - the resulting velocity after the collision assuming elasticity.
rCoeff - the reflection coefficent.
Returns:
the resulting velocity after an inelastic collision.
Requires:
rCoeff >= 0
Effects:
given an initial velocity, incidentVect, and the velocity resulting from an elastic collision, reflectedVect, and a reflection coefficient, rCoeff, returns the resulting velocity of the collision had it been inelastic with the given reflection coefficient. If the reflection coefficient is 1.0, the resulting velocity will be equal to reflectedVect. A reflection coefficient of 0 implies that the collision will absorb any energy that was reflected in the elastic case.

pointWherePlaneIntersectsLine

public Vect3 pointWherePlaneIntersectsLine(Plane plane,
                                           Line line)
METHODS FOR STATIONARY OBJECTS


timeUntilPlanePolygonCollision

public double timeUntilPlanePolygonCollision(PlanePolygon polygon,
                                             Sphere ball,
                                             Vect3 velocity)
Computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified plane polygon.

Parameters:
polygon - a plane polygon representing the circle with which the ball may collide
ball - a sphere representing the size and initial location of the ball
velocity - the velocity of the ball before impact
Returns:
the time until collision or POSITIVE_INFINITY if the collision will not occur
See Also:
Double.POSITIVE_INFINITY
Requires:
ball.radius > 0
Effects:
computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified plane polygon. If no collision will occur POSITIVE_INFINITY is returned. This method assumes the ball travels with constant velocity until impact.

reflectPlanePolygon

public Vect3 reflectPlanePolygon(PlanePolygon polygon,
                                 Sphere ball,
                                 Vect3 velocity,
                                 double reflectionCoeff)
Computes the new velocity of a ball reflecting off of a plane polygon.

Parameters:
polygon - the plane polygon which is being hit
ball - the ball
velocity - the velocity of the ball before impact
reflectionCoeff - the reflection coefficient
Returns:
the velocity of the ball after impacting the given plane polygon
Requires:
reflectionCoeff >= 0
Effects:
computes the new velocity of a ball reflecting off of a plane polygon. The velocity resulting from this method corresponds to a collision against a surface with the given reflection coefficient. A reflection coefficient of 1 indicates a perfectly elastic collision. This method assumes that the ball is at the point of impact.

reflectPlanePolygon

public Vect3 reflectPlanePolygon(PlanePolygon polygon,
                                 Sphere ball,
                                 Vect3 velocity)
Computes the new velocity of a ball reflecting off of a plane polygon.

Parameters:
polygon - the plane polygon which is being hit
ball - the ball
velocity - the velocity of the ball before impact
Returns:
the velocity of the ball after impacting the given plane polygon
Effects:
computes the new velocity of a ball reflecting off of a plane polygon. The velocity resulting from this method corresponds to a perfectly elastic collision. This method assumes that the ball is at the point of impact.

timeUntilPlaneCircleCollision

public double timeUntilPlaneCircleCollision(PlaneCircle circle,
                                            Sphere ball,
                                            Vect3 velocity)
Computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified plane circle.

Parameters:
circle - a plane circle representing the circle with which the ball may collide
ball - a sphere representing the size and initial location of the ball
velocity - the velocity of the ball before impact
Returns:
the time until collision or POSITIVE_INFINITY if the collision will not occur
See Also:
Double.POSITIVE_INFINITY
Requires:
ball.radius > 0
Effects:
computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified plane circle. If no collision will occur POSITIVE_INFINITY is returned. This method assumes the ball travels with constant velocity until impact.

reflectPlaneCircle

public Vect3 reflectPlaneCircle(PlaneCircle circle,
                                Sphere ball,
                                Vect3 velocity,
                                double reflectionCoeff)
Computes the new velocity of a ball reflecting off of a plane circle.

Parameters:
circle - the plane circle which is being hit
ball - the ball
velocity - the velocity of the ball before impact
reflectionCoeff - the reflection coefficient
Returns:
the velocity of the ball after impacting the given plane circle
Requires:
reflectionCoeff >= 0
Effects:
computes the new velocity of a ball reflecting off of a plane circle. The velocity resulting from this method corresponds to a collision against a surface with the given reflection coefficient. A reflection coefficient of 1 indicates a perfectly elastic collision. This method assumes that the ball is at the point of impact.

reflectPlaneCircle

public Vect3 reflectPlaneCircle(PlaneCircle circle,
                                Sphere ball,
                                Vect3 velocity)
Computes the new velocity of a ball reflecting off of a plane circle.

Parameters:
circle - the plane circle which is being hit
ball - the ball
velocity - the velocity of the ball before impact
Returns:
the velocity of the ball after impacting the given plane circle
Effects:
computes the new velocity of a ball reflecting off of a plane circle. The velocity resulting from this method corresponds to a perfectly elastic collision. This method assumes that the ball is at the point of impact.

timeUntilSphereCollision

public double timeUntilSphereCollision(Sphere sphere,
                                       Sphere ball,
                                       Vect3 velocity)
Computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified sphere.

Parameters:
sphere - a sphere representing the circle with which the ball may collide
ball - a sphere representing the size and initial location of the ball
velocity - the velocity of the ball before impact
Returns:
the time until collision or POSITIVE_INFINITY if the collision will not occur
See Also:
Double.POSITIVE_INFINITY
Requires:
ball.radius > 0
Effects:
computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified sphere. If no collision will occur POSITIVE_INFINITY is returned. This method assumes the ball travels with constant velocity until impact.

findSphereNormalToBall

public Vect3 findSphereNormalToBall(Sphere sphere,
                                    Sphere ball)
Returns:
the unit vector that points from the center of the sphere to the center of the ball.
Requires:
sphere != null, ball != null, sphere and ball have different centers.

reflectSphere

public Vect3 reflectSphere(Sphere sphere,
                           Sphere ball,
                           Vect3 velocity,
                           double reflectionCoeff)
Computes the new velocity of a ball reflecting off of a sphere.

Parameters:
sphere - the sphere which is being hit
ball - the ball
velocity - the velocity of the ball before impact
reflectionCoeff - the reflection coefficient
Returns:
the velocity of the ball after impacting the given sphere
Requires:
reflectionCoeff >= 0
Effects:
computes the new velocity of a ball reflecting off of a sphere. The velocity resulting from this method corresponds to a collision against a surface with the given reflection coefficient. A reflection coefficient of 1 indicates a perfectly elastic collision. This method assumes that the ball is at the point of impact.

reflectSphere

public Vect3 reflectSphere(Sphere sphere,
                           Sphere ball,
                           Vect3 velocity)
Computes the new velocity of a ball reflecting off of a sphere.

Parameters:
sphere - the sphere which is being hit
ball - the ball
velocity - the velocity of the ball before impact
Returns:
the velocity of the ball after impacting the given sphere
Effects:
computes the new velocity of a ball reflecting off of a sphere. The velocity resulting from this method corresponds to a perfectly elastic collision. This method assumes that the ball is at the point of impact.

timeUntilLateralCylinderCollision

public double timeUntilLateralCylinderCollision(LateralCylinder cyl,
                                                Sphere ball,
                                                Vect3 velocity)
Computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified lateral cylinder.

Parameters:
cyl - a lateral cylinder representing the circle with which the ball may collide
ball - a sphere representing the size and initial location of the ball
velocity - the velocity of the ball before impact
Returns:
the time until collision or POSITIVE_INFINITY if the collision will not occur
See Also:
Double.POSITIVE_INFINITY
Requires:
ball.radius > 0
Effects:
computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified lateral cylinder. If no collision will occur POSITIVE_INFINITY is returned. This method assumes the ball travels with constant velocity until impact.

findCylinderNormalToBall

public Vect3 findCylinderNormalToBall(LateralCylinder cyl,
                                      Sphere ball)
Returns:
the outward pointing unit vector perpendicular to the axis of cyl to the center of the ball (regardless of whether that point is contained within the cylinder)
Requires:
cyl != null, ball != null, center of ball does not lie on the axis of the cylinder.

reflectLateralCylinder

public Vect3 reflectLateralCylinder(LateralCylinder cyl,
                                    Sphere ball,
                                    Vect3 velocity,
                                    double reflectionCoeff)
Computes the new velocity of a ball reflecting off of a lateral cylinder.

Parameters:
cyl - the lateral cylinder which is being hit
ball - the ball
velocity - the velocity of the ball before impact
reflectionCoeff - the reflection coefficient
Returns:
the velocity of the ball after impacting the given lateral cylinder
Requires:
reflectionCoeff >= 0
Effects:
computes the new velocity of a ball reflecting off of a lateral cylinder. The velocity resulting from this method corresponds to a collision against a surface with the given reflection coefficient. A reflection coefficient of 1 indicates a perfectly elastic collision. This method assumes that the ball is at the point of impact.

reflectLateralCylinder

public Vect3 reflectLateralCylinder(LateralCylinder cyl,
                                    Sphere ball,
                                    Vect3 velocity)
Computes the new velocity of a ball reflecting off of a lateral cylinder.

Parameters:
cyl - the lateral cylinder which is being hit
ball - the ball
velocity - the velocity of the ball before impact
Returns:
the velocity of the ball after impacting the given lateral cylinder
Effects:
computes the new velocity of a ball reflecting off of a lateral cylinder. The velocity resulting from this method corresponds to a perfectly elastic collision. This method assumes that the ball is at the point of impact.

timeUntilTorusCollision

public double timeUntilTorusCollision(Torus torus,
                                      Sphere ball,
                                      Vect3 velocity)
Computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified torus.

Parameters:
torus - a torus representing the circle with which the ball may collide
ball - a sphere representing the size and initial location of the ball
velocity - the velocity of the ball before impact
Returns:
the time until collision or POSITIVE_INFINITY if the collision will not occur
See Also:
Double.POSITIVE_INFINITY
Requires:
ball.radius > 0
Effects:
computes the time until a ball represented by a sphere, travelling at a specified velocity collides with a specified torus. If no collision will occur POSITIVE_INFINITY is returned. This method assumes the ball travels with constant velocity until impact.

findTorusNormalToBall

public Vect3 findTorusNormalToBall(Torus torus,
                                   Sphere ball)
Returns:
if(ball.getCenter()) lies on the line determined by the torus centerPoint and orientation, then returns a unit vector with the same direction as the torus's orientation. Otherwise returns the outward pointing unit vector from the closest point on torus to the center of the ball
Requires:
torus != null, ball != null, the center of ball does not lie on the circle of radius torus.radiusFromCenter contained in the plane that is perpendicular to torus.orientation

reflectTorus

public Vect3 reflectTorus(Torus torus,
                          Sphere ball,
                          Vect3 velocity,
                          double reflectionCoeff)
Computes the new velocity of a ball reflecting off of a torus.

Parameters:
torus - the torus which is being hit
ball - the ball
velocity - the velocity of the ball before impact
reflectionCoeff - the reflection coefficient
Returns:
the velocity of the ball after impacting the given torus
Requires:
reflectionCoeff >= 0
Effects:
computes the new velocity of a ball reflecting off of a torus. The velocity resulting from this method corresponds to a collision against a surface with the given reflection coefficient. A reflection coefficient of 1 indicates a perfectly elastic collision. This method assumes that the ball is at the point of impact.

reflectTorus

public Vect3 reflectTorus(Torus torus,
                          Sphere ball,
                          Vect3 velocity)
Computes the new velocity of a ball reflecting off of a torus.

Parameters:
torus - the torus which is being hit
ball - the ball
velocity - the velocity of the ball before impact
Returns:
the velocity of the ball after impacting the given torus
Effects:
computes the new velocity of a ball reflecting off of a torus. The velocity resulting from this method corresponds to a perfectly elastic collision. This method assumes that the ball is at the point of impact.

timeUntilRotatingPlanePolygonCollision

public double timeUntilRotatingPlanePolygonCollision(PlanePolygon polygon,
                                                     Vect3 center,
                                                     Vect3 angularVelocity,
                                                     Sphere ball,
                                                     Vect3 velocity)
Computes the time until a ball travelling at a specified velocity collides with a rotating plane polygon.

Parameters:
polygon - a plane polygon representing the initial location and size of the rotating plane polygon
center - the point around which the plane polygon is rotating
angularVelocity - the angular velocity with which polygon is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - a sphere representing the size and initial position of the ball
velocity - the velocity of the ball before impact
See Also:
Double.POSITIVE_INFINITY
Effects:
computes the time until a spherical ball travelling at a specified velocity collides with a specified plane polygon that is rotating about a given center of rotation at a given angular velocity. If no collision will occurr POSITIVE_INFINITY is returned. This method assumes the ball will travel with constant velocity until impact.


reflectRotatingPlanePolygon

public Vect3 reflectRotatingPlanePolygon(PlanePolygon polygon,
                                         Vect3 center,
                                         Vect3 angularVelocity,
                                         Sphere ball,
                                         Vect3 velocity)
Computes the new velocity of a sphere reflected off of a rotating plane polygon.

Parameters:
polygon - the rotating plane polygon
center - the point about which polygon is rotating
angularVelocity - the angular velocity with which polygon is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - the size and position of the sphere before impact
velocity - the velocity of the sphere before impact
Returns:
the velocity of the sphere after impacting the rotating plane polygon
Requires:
the sphere is at the point of impact
Effects:
computes the new velocity of a sphere reflected off of a plane polygon which is rotating with constant angular velocity around a point. The velocity resulting from this method corresponds to a perfectly elastic collision.

reflectRotatingPlanePolygon

public Vect3 reflectRotatingPlanePolygon(PlanePolygon polygon,
                                         Vect3 center,
                                         Vect3 angularVelocity,
                                         Sphere ball,
                                         Vect3 velocity,
                                         double reflectionCoeff)
Computes the new velocity of a sphere reflected off of a rotating plane polygon.

Parameters:
polygon - the rotating plane polygon
center - the point about which polygon is rotating
angularVelocity - the angular velocity with which polygon is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - the size and position of the sphere before impact
velocity - the velocity of the sphere before impact
reflectionCoeff - the reflection coefficient
Returns:
the velocity of the sphere after impacting the rotating plane polygon
Requires:
the sphere is at the point of impact
Effects:
computes the new velocity of a sphere reflected off of a plane polygon which is rotating with constant angular velocity around a point. The velocity resulting from this method corresponds to a collision against a surface with the given reflection coefficient. A reflection coefficient of 1.0 indicates a perfectly elastic collision.

timeUntilRotatingPlaneCircleCollision

public double timeUntilRotatingPlaneCircleCollision(PlaneCircle circle,
                                                    Vect3 center,
                                                    Vect3 angularVelocity,
                                                    Sphere ball,
                                                    Vect3 velocity)
Computes the time until a ball travelling at a specified velocity collides with a rotating plane circle.

Parameters:
circle - a plane circle representing the initial location and size of the rotating plane circle
center - the point around which the plane circle is rotating
angularVelocity - the angular velocity with which circle is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - a sphere representing the size and initial position of the ball
velocity - the velocity of the ball before impact
See Also:
Double.POSITIVE_INFINITY
Effects:
computes the time until a spherical ball travelling at a specified velocity collides with a specified plane circle that is rotating about a given center of rotation at a given angular velocity. If no collision will occurr POSITIVE_INFINITY is returned. This method assumes the ball will travel with constant velocity until impact.


reflectRotatingPlaneCircle

public Vect3 reflectRotatingPlaneCircle(PlaneCircle circle,
                                        Vect3 center,
                                        Vect3 angularVelocity,
                                        Sphere ball,
                                        Vect3 velocity)
Computes the new velocity of a sphere reflected off of a rotating plane circle.

Parameters:
circle - the rotating plane circle
center - the point about which circle is rotating
angularVelocity - the angular velocity with which circle is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - the size and position of the sphere before impact
velocity - the velocity of the sphere before impact
Returns:
the velocity of the sphere after impacting the rotating plane circle
Requires:
the sphere is at the point of impact
Effects:
computes the new velocity of a sphere reflected off of a plane circle which is rotating with constant angular velocity around a point. The velocity resulting from this method corresponds to a perfectly elastic collision.

reflectRotatingPlaneCircle

public Vect3 reflectRotatingPlaneCircle(PlaneCircle circle,
                                        Vect3 center,
                                        Vect3 angularVelocity,
                                        Sphere ball,
                                        Vect3 velocity,
                                        double reflectionCoeff)
Computes the new velocity of a sphere reflected off of a rotating plane circle.

Parameters:
circle - the rotating plane circle
center - the point about which circle is rotating
angularVelocity - the angular velocity with which circle is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - the size and position of the sphere before impact
velocity - the velocity of the sphere before impact
reflectionCoeff - the reflection coefficient
Returns:
the velocity of the sphere after impacting the rotating plane circle
Requires:
the sphere is at the point of impact
Effects:
computes the new velocity of a sphere reflected off of a plane circle which is rotating with constant angular velocity around a point. The velocity resulting from this method corresponds to a collision against a surface with the given reflection coefficient. A reflection coefficient of 1.0 indicates a perfectly elastic collision.

timeUntilRotatingSphereCollision

public double timeUntilRotatingSphereCollision(Sphere sphere,
                                               Vect3 center,
                                               Vect3 angularVelocity,
                                               Sphere ball,
                                               Vect3 velocity)
Computes the time until a ball travelling at a specified velocity collides with a rotating sphere.

Parameters:
sphere - a sphere representing the initial location and size of the rotating sphere
center - the point around which the sphere is rotating
angularVelocity - the angular velocity with which sphere is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - a sphere representing the size and initial position of the ball
velocity - the velocity of the ball before impact
See Also:
Double.POSITIVE_INFINITY
Effects:
computes the time until a spherical ball travelling at a specified velocity collides with a specified sphere that is rotating about a given center of rotation at a given angular velocity. If no collision will occurr POSITIVE_INFINITY is returned. This method assumes the ball will travel with constant velocity until impact.


reflectRotatingSphere

public Vect3 reflectRotatingSphere(Sphere sphere,
                                   Vect3 center,
                                   Vect3 angularVelocity,
                                   Sphere ball,
                                   Vect3 velocity)
Computes the new velocity of a sphere reflected off of a rotating sphere.

Parameters:
sphere - the rotating sphere
center - the point about which sphere is rotating
angularVelocity - the angular velocity with which sphere is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - the size and position of the sphere before impact
velocity - the velocity of the sphere before impact
Returns:
the velocity of the sphere after impacting the rotating sphere
Requires:
the sphere is at the point of impact
Effects:
computes the new velocity of a sphere reflected off of a sphere which is rotating with constant angular velocity around a point. The velocity resulting from this method corresponds to a perfectly elastic collision.

reflectRotatingSphere

public Vect3 reflectRotatingSphere(Sphere sphere,
                                   Vect3 center,
                                   Vect3 angularVelocity,
                                   Sphere ball,
                                   Vect3 velocity,
                                   double reflectionCoeff)
Computes the new velocity of a sphere reflected off of a rotating sphere.

Parameters:
sphere - the rotating sphere
center - the point about which sphere is rotating
angularVelocity - the angular velocity with which sphere is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - the size and position of the sphere before impact
velocity - the velocity of the sphere before impact
reflectionCoeff - the reflection coefficient
Returns:
the velocity of the sphere after impacting the rotating sphere
Requires:
the sphere is at the point of impact
Effects:
computes the new velocity of a sphere reflected off of a sphere which is rotating with constant angular velocity around a point. The velocity resulting from this method corresponds to a collision against a surface with the given reflection coefficient. A reflection coefficient of 1.0 indicates a perfectly elastic collision.

timeUntilRotatingLateralCylinderCollision

public double timeUntilRotatingLateralCylinderCollision(LateralCylinder cyl,
                                                        Vect3 center,
                                                        Vect3 angularVelocity,
                                                        Sphere ball,
                                                        Vect3 velocity)
Computes the time until a ball travelling at a specified velocity collides with a rotating lateral cylinder.

Parameters:
cyl - a lateral cylinder representing the initial location and size of the rotating lateral cylinder
center - the point around which the lateral cylinder is rotating
angularVelocity - the angular velocity with which cyl is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - a sphere representing the size and initial position of the ball
velocity - the velocity of the ball before impact
See Also:
Double.POSITIVE_INFINITY
Effects:
computes the time until a spherical ball travelling at a specified velocity collides with a specified lateral cylinder that is rotating about a given center of rotation at a given angular velocity. If no collision will occurr POSITIVE_INFINITY is returned. This method assumes the ball will travel with constant velocity until impact.


reflectRotatingLateralCylinder

public Vect3 reflectRotatingLateralCylinder(LateralCylinder cyl,
                                            Vect3 center,
                                            Vect3 angularVelocity,
                                            Sphere ball,
                                            Vect3 velocity)
Computes the new velocity of a sphere reflected off of a rotating lateral cylinder.

Parameters:
cyl - the rotating lateral cylinder
center - the point about which cyl is rotating
angularVelocity - the angular velocity with which cyl is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - the size and position of the sphere before impact
velocity - the velocity of the sphere before impact
Returns:
the velocity of the sphere after impacting the rotating lateral cylinder
Requires:
the sphere is at the point of impact
Effects:
computes the new velocity of a sphere reflected off of a lateral cylinder which is rotating with constant angular velocity around a point. The velocity resulting from this method corresponds to a perfectly elastic collision.

reflectRotatingLateralCylinder

public Vect3 reflectRotatingLateralCylinder(LateralCylinder cyl,
                                            Vect3 center,
                                            Vect3 angularVelocity,
                                            Sphere ball,
                                            Vect3 velocity,
                                            double reflectionCoeff)
Computes the new velocity of a sphere reflected off of a rotating lateral cylinder.

Parameters:
cyl - the rotating lateral cylinder
center - the point about which cyl is rotating
angularVelocity - the angular velocity with which cyl is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - the size and position of the sphere before impact
velocity - the velocity of the sphere before impact
reflectionCoeff - the reflection coefficient
Returns:
the velocity of the sphere after impacting the rotating lateral cylinder
Requires:
the sphere is at the point of impact
Effects:
computes the new velocity of a sphere reflected off of a lateral cylinder which is rotating with constant angular velocity around a point. The velocity resulting from this method corresponds to a collision against a surface with the given reflection coefficient. A reflection coefficient of 1.0 indicates a perfectly elastic collision.

timeUntilRotatingTorusCollision

public double timeUntilRotatingTorusCollision(Torus torus,
                                              Vect3 center,
                                              Vect3 angularVelocity,
                                              Sphere ball,
                                              Vect3 velocity)
Computes the time until a ball travelling at a specified velocity collides with a rotating torus.

Parameters:
torus - a torus representing the initial location and size of the rotating torus
center - the point around which the torus is rotating
angularVelocity - the angular velocity with which torus is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - a sphere representing the size and initial position of the ball
velocity - the velocity of the ball before impact
See Also:
Double.POSITIVE_INFINITY
Effects:
computes the time until a spherical ball travelling at a specified velocity collides with a specified torus that is rotating about a given center of rotation at a given angular velocity. If no collision will occurr POSITIVE_INFINITY is returned. This method assumes the ball will travel with constant velocity until impact.


reflectRotatingTorus

public Vect3 reflectRotatingTorus(Torus torus,
                                  Vect3 center,
                                  Vect3 angularVelocity,
                                  Sphere ball,
                                  Vect3 velocity)
Computes the new velocity of a sphere reflected off of a rotating torus.

Parameters:
torus - the rotating torus
center - the point about which torus is rotating
angularVelocity - the angular velocity with which torus is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - the size and position of the sphere before impact
velocity - the velocity of the sphere before impact
Returns:
the velocity of the sphere after impacting the rotating torus
Requires:
the sphere is at the point of impact
Effects:
computes the new velocity of a sphere reflected off of a torus which is rotating with constant angular velocity around a point. The velocity resulting from this method corresponds to a perfectly elastic collision.

reflectRotatingTorus

public Vect3 reflectRotatingTorus(Torus torus,
                                  Vect3 center,
                                  Vect3 angularVelocity,
                                  Sphere ball,
                                  Vect3 velocity,
                                  double reflectionCoeff)
Computes the new velocity of a sphere reflected off of a rotating torus.

Parameters:
torus - the rotating torus
center - the point about which torus is rotating
angularVelocity - the angular velocity with which torus is rotating about center, where the length is measured in radians per second, and the direction is perpendicular to the axis of rotation using the right hand rule (the standard convention).
ball - the size and position of the sphere before impact
velocity - the velocity of the sphere before impact
reflectionCoeff - the reflection coefficient
Returns:
the velocity of the sphere after impacting the rotating torus
Requires:
the sphere is at the point of impact
Effects:
computes the new velocity of a sphere reflected off of a torus which is rotating with constant angular velocity around a point. The velocity resulting from this method corresponds to a collision against a surface with the given reflection coefficient. A reflection coefficient of 1.0 indicates a perfectly elastic collision.

timeUntilSphereSphereCollision

public double timeUntilSphereSphereCollision(Sphere sphere1,
                                             Vect3 vel1,
                                             Sphere sphere2,
                                             Vect3 vel2)
Computes the time until two spheres collide.

Parameters:
sphere1 - a sphere representing the size and initial position of the first sphere.
vel1 - the velocity of the first sphere before impact
sphere2 - a sphere representing the size and initial position of the second sphere.
vel2 - the velocity of the second sphere before impact
Returns:
the time until collision or POSITIVE_INFINITY if the collision will not occur
See Also:
Double.POSITIVE_INFINITY
Effects:
computes the time until two spheres, travelling at specified constant velocities, collide. If no collision will occur POSITIVE_INFINITY is returned. This method assumes that both spheres will travel at constant velocity until impact.

reflectSpheres

public Vect3Pair reflectSpheres(Sphere sphere1,
                                double mass1,
                                Vect3 velocity1,
                                Sphere sphere2,
                                double mass2,
                                Vect3 velocity2)
Computes the resulting velocities of two spheres which collide.

Parameters:
sphere1 - the first sphere
mass1 - the mass of the first sphere
velocity1 - the velocity of the first sphere before impact
sphere2 - the second sphere
mass2 - the mass of the second sphere
velocity2 - the velocity of the second sphere before impact
Returns:
a Vect3Pair, where the first Vect3 is the velocity of the first sphere after the collision and the second Vect3 is the velocity of the second sphere after the collision.
Requires:
mass1 > 0 && mass2 > 0 && the distance between the two spheres is approximately equal to the sum of their radii; that is, the spheres are positioned at the point of impact.
Effects:
computes the resulting velocities of two spheres which collide.

timeUntilCollision

public double timeUntilCollision(PhysicsShape nextShape,
                                 Sphere ball,
                                 Vect3 velocity)
convenience method: calls the appropriate timeUntilCollision method


reflect

public Vect3 reflect(PhysicsShape nextShape,
                     Sphere ball,
                     Vect3 velocity,
                     double coref)
convenience method: calls the appropriate reflect method


reflectRotating

public Vect3 reflectRotating(PhysicsShape nextShape,
                             Vect3 center,
                             Vect3 angularVel,
                             Sphere ball,
                             Vect3 velocity,
                             double coref)
convenience method: calls the appropriate reflect method


timeUntilRotatingCollision

public double timeUntilRotatingCollision(PhysicsShape shape,
                                         Vect3 center,
                                         Vect3 angularVel,
                                         Sphere ballShape,
                                         Vect3 velocity)