physics
Class GeometryImpl

java.lang.Object
  extended by physics.GeometryImpl
All Implemented Interfaces:
GeometryInterface
Direct Known Subclasses:
SimpleGeometry

public class GeometryImpl
extends java.lang.Object
implements GeometryInterface

GeometryImpl is the default implementation of GeometryInterface. Most callers will not use GeometryImpl directly, but will use the singleton Geometry instead.

GeometryImpl uses two parameters to tune its behavior.

See Also:
Geometry

Field Summary
protected  double maximumForesight
           
protected  int searchSlices
           
 
Constructor Summary
GeometryImpl()
           
GeometryImpl(double maximumForesight, int searchSlices)
           
 
Method Summary
 Vect applyReflectionCoeff(Vect incidentVect, Vect reflectedVect, double rCoeff)
          Specified by Geometry.applyReflectionCoeff
 double distanceSquared(double x1, double y1, double x2, double y2)
          Specified by Geometry.distanceSquared
 double distanceSquared(Vect v1, Vect v2)
          Specified by Geometry.distanceSquared
 double minQuadraticSolution(double a, double b, double c)
          Specified by Geometry.minQuadraticSolution
 Vect perpendicularPoint(LineSegment line, Vect point)
          Specified by Geometry.perpendicularPoint
 Vect perpendicularPointWholeLine(LineSegment line, Vect point)
          Specified by Geometry.perpendicularPointWholeLine
 Geometry.DoublePair quadraticSolution(double a, double b, double c)
          Specified by Geometry.quadraticSolution
 Geometry.VectPair reflectBalls(Vect center1, double mass1, Vect velocity1, Vect center2, double mass2, Vect velocity2)
          Specified by Geometry.reflectBalls
 Vect reflectCircle(Vect circle, Vect ball, Vect velocity)
          Specified by Geometry.reflectCircle
 Vect reflectCircle(Vect circle, Vect ball, Vect velocity, double reflectionCoeff)
          Specified by Geometry.reflectCircle
 Vect reflectRotatingCircle(Circle circle, Vect center, double angularVelocity, Circle ball, Vect velocity)
          Specified by Geometry.reflectRotatingCircle
 Vect reflectRotatingCircle(Circle circle, Vect center, double angularVelocity, Circle ball, Vect velocity, double reflectionCoeff)
          Specified by Geometry.reflectRotatingCircle
 Vect reflectRotatingWall(LineSegment line, Vect center, double angularVelocity, Circle ball, Vect velocity)
          Specified by Geometry.reflectRotatingWall
 Vect reflectRotatingWall(LineSegment line, Vect center, double angularVelocity, Circle ball, Vect velocity, double reflectionCoeff)
          Specified by Geometry.reflectRotatingWall
 Vect reflectWall(LineSegment line, Vect velocity)
          Specified by Geometry.reflectWall
 Vect reflectWall(LineSegment line, Vect velocity, double reflectionCoeff)
          Specified by Geometry.reflectWall
protected  IntervalList restrictSearchInterval(IntervalList intervals, double inner_radius, double outer_radius, double phi_1, double phi_2, double omega, Vect center, Circle ball, Vect velocity)
          Given the path of a ball and the path of something rotating in a circle, restricts the possible time periods during which they might collide by doing some crazy confusing analysis originally concocted by Professor Ernst.
 Circle rotateAround(Circle circle, Vect cor, Angle a)
          Specified by Geometry.rotateAround
 LineSegment rotateAround(LineSegment line, Vect cor, Angle a)
          Specified by Geometry.rotateAround
 Vect rotateAround(Vect point, Vect cor, Angle a)
          Specified by Geometry.rotateAround
 double timeUntilBallBallCollision(Circle ball1, Vect vel1, Circle ball2, Vect vel2)
          Specified by Geometry.timeUntilBallBallCollision
 double timeUntilCircleCollision(Circle circle, Circle ball, Vect velocity)
          Specified by Geometry.timeUntilCircleCollision
 Geometry.DoublePair timeUntilCircleCollision(Circle circle, Vect point, Vect velocity)
          Specified by Geometry.timeUntilCircleCollision
 double timeUntilRotatingCircleCollision(Circle circle, Vect center, double angularVelocity, Circle ball, Vect velocity)
          Specified by Geometry.timeUntilRotatingCircleCollision
 double timeUntilRotatingWallCollision(LineSegment line, Vect center, double angularVelocity, Circle ball, Vect velocity)
          Specified by Geometry.timeUntilRotatingWallCollision
 double timeUntilWallCollision(LineSegment line, Circle ball, Vect velocity)
          Specified by Geometry.timeUntilWallCollision
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maximumForesight

protected final double maximumForesight

searchSlices

protected final int searchSlices
Constructor Detail

GeometryImpl

public GeometryImpl()

GeometryImpl

public GeometryImpl(double maximumForesight,
                    int searchSlices)
Method Detail

quadraticSolution

public Geometry.DoublePair quadraticSolution(double a,
                                             double b,
                                             double c)
Description copied from interface: GeometryInterface
Specified by Geometry.quadraticSolution

Specified by:
quadraticSolution in interface GeometryInterface
See Also:
Geometry.quadraticSolution(double, double, double)

minQuadraticSolution

public double minQuadraticSolution(double a,
                                   double b,
                                   double c)
Description copied from interface: GeometryInterface
Specified by Geometry.minQuadraticSolution

Specified by:
minQuadraticSolution in interface GeometryInterface
See Also:
Geometry.minQuadraticSolution(double, double, double)

perpendicularPoint

public Vect perpendicularPoint(LineSegment line,
                               Vect point)
Description copied from interface: GeometryInterface
Specified by Geometry.perpendicularPoint

Specified by:
perpendicularPoint in interface GeometryInterface
See Also:
Geometry.perpendicularPoint(physics.LineSegment, physics.Vect)

perpendicularPointWholeLine

public Vect perpendicularPointWholeLine(LineSegment line,
                                        Vect point)
Description copied from interface: GeometryInterface
Specified by Geometry.perpendicularPointWholeLine

Specified by:
perpendicularPointWholeLine in interface GeometryInterface
See Also:
Geometry.perpendicularPointWholeLine(physics.LineSegment, physics.Vect)

applyReflectionCoeff

public Vect applyReflectionCoeff(Vect incidentVect,
                                 Vect reflectedVect,
                                 double rCoeff)
Description copied from interface: GeometryInterface
Specified by Geometry.applyReflectionCoeff

Specified by:
applyReflectionCoeff in interface GeometryInterface
See Also:
Geometry.applyReflectionCoeff(physics.Vect, physics.Vect, double)

timeUntilWallCollision

public double timeUntilWallCollision(LineSegment line,
                                     Circle ball,
                                     Vect velocity)
Description copied from interface: GeometryInterface
Specified by Geometry.timeUntilWallCollision

Specified by:
timeUntilWallCollision in interface GeometryInterface
See Also:
Geometry.timeUntilWallCollision(physics.LineSegment, physics.Circle, physics.Vect)

reflectWall

public Vect reflectWall(LineSegment line,
                        Vect velocity,
                        double reflectionCoeff)
Description copied from interface: GeometryInterface
Specified by Geometry.reflectWall

Specified by:
reflectWall in interface GeometryInterface
See Also:
Geometry.reflectWall(physics.LineSegment, physics.Vect, double)

reflectWall

public Vect reflectWall(LineSegment line,
                        Vect velocity)
Description copied from interface: GeometryInterface
Specified by Geometry.reflectWall

Specified by:
reflectWall in interface GeometryInterface
See Also:
Geometry.reflectWall(physics.LineSegment, physics.Vect, double)

distanceSquared

public double distanceSquared(Vect v1,
                              Vect v2)
Description copied from interface: GeometryInterface
Specified by Geometry.distanceSquared

Specified by:
distanceSquared in interface GeometryInterface
See Also:
Geometry.distanceSquared(physics.Vect, physics.Vect)

distanceSquared

public double distanceSquared(double x1,
                              double y1,
                              double x2,
                              double y2)
Description copied from interface: GeometryInterface
Specified by Geometry.distanceSquared

Specified by:
distanceSquared in interface GeometryInterface
See Also:
Geometry.distanceSquared(physics.Vect, physics.Vect)

timeUntilCircleCollision

public double timeUntilCircleCollision(Circle circle,
                                       Circle ball,
                                       Vect velocity)
Description copied from interface: GeometryInterface
Specified by Geometry.timeUntilCircleCollision

Specified by:
timeUntilCircleCollision in interface GeometryInterface
See Also:
Geometry.timeUntilCircleCollision(physics.Circle, physics.Circle, physics.Vect)

reflectCircle

public Vect reflectCircle(Vect circle,
                          Vect ball,
                          Vect velocity,
                          double reflectionCoeff)
Description copied from interface: GeometryInterface
Specified by Geometry.reflectCircle

Specified by:
reflectCircle in interface GeometryInterface
See Also:
Geometry.reflectCircle(physics.Vect, physics.Vect, physics.Vect, double)

reflectCircle

public Vect reflectCircle(Vect circle,
                          Vect ball,
                          Vect velocity)
Description copied from interface: GeometryInterface
Specified by Geometry.reflectCircle

Specified by:
reflectCircle in interface GeometryInterface
See Also:
Geometry.reflectCircle(physics.Vect, physics.Vect, physics.Vect, double)

rotateAround

public Vect rotateAround(Vect point,
                         Vect cor,
                         Angle a)
Description copied from interface: GeometryInterface
Specified by Geometry.rotateAround

Specified by:
rotateAround in interface GeometryInterface
See Also:
Geometry.rotateAround(physics.Vect, physics.Vect, physics.Angle)

rotateAround

public LineSegment rotateAround(LineSegment line,
                                Vect cor,
                                Angle a)
Description copied from interface: GeometryInterface
Specified by Geometry.rotateAround

Specified by:
rotateAround in interface GeometryInterface
See Also:
Geometry.rotateAround(physics.Vect, physics.Vect, physics.Angle)

rotateAround

public Circle rotateAround(Circle circle,
                           Vect cor,
                           Angle a)
Description copied from interface: GeometryInterface
Specified by Geometry.rotateAround

Specified by:
rotateAround in interface GeometryInterface
See Also:
Geometry.rotateAround(physics.Vect, physics.Vect, physics.Angle)

timeUntilCircleCollision

public Geometry.DoublePair timeUntilCircleCollision(Circle circle,
                                                    Vect point,
                                                    Vect velocity)
Description copied from interface: GeometryInterface
Specified by Geometry.timeUntilCircleCollision

Specified by:
timeUntilCircleCollision in interface GeometryInterface
See Also:
Geometry.timeUntilCircleCollision(physics.Circle, physics.Circle, physics.Vect)

restrictSearchInterval

protected IntervalList restrictSearchInterval(IntervalList intervals,
                                              double inner_radius,
                                              double outer_radius,
                                              double phi_1,
                                              double phi_2,
                                              double omega,
                                              Vect center,
                                              Circle ball,
                                              Vect velocity)
Given the path of a ball and the path of something rotating in a circle, restricts the possible time periods during which they might collide by doing some crazy confusing analysis originally concocted by Professor Ernst. Subclass SimpleGeometry disables these optimizations.

See Also:
SimpleGeometry

timeUntilRotatingWallCollision

public double timeUntilRotatingWallCollision(LineSegment line,
                                             Vect center,
                                             double angularVelocity,
                                             Circle ball,
                                             Vect velocity)
Description copied from interface: GeometryInterface
Specified by Geometry.timeUntilRotatingWallCollision

Specified by:
timeUntilRotatingWallCollision in interface GeometryInterface
See Also:
Geometry.timeUntilRotatingWallCollision(physics.LineSegment, physics.Vect, double, physics.Circle, physics.Vect)

reflectRotatingWall

public Vect reflectRotatingWall(LineSegment line,
                                Vect center,
                                double angularVelocity,
                                Circle ball,
                                Vect velocity)
Description copied from interface: GeometryInterface
Specified by Geometry.reflectRotatingWall

Specified by:
reflectRotatingWall in interface GeometryInterface
See Also:
Geometry.reflectRotatingWall(physics.LineSegment, physics.Vect, double, physics.Circle, physics.Vect)

reflectRotatingWall

public Vect reflectRotatingWall(LineSegment line,
                                Vect center,
                                double angularVelocity,
                                Circle ball,
                                Vect velocity,
                                double reflectionCoeff)
Description copied from interface: GeometryInterface
Specified by Geometry.reflectRotatingWall

Specified by:
reflectRotatingWall in interface GeometryInterface
See Also:
Geometry.reflectRotatingWall(physics.LineSegment, physics.Vect, double, physics.Circle, physics.Vect)

timeUntilRotatingCircleCollision

public double timeUntilRotatingCircleCollision(Circle circle,
                                               Vect center,
                                               double angularVelocity,
                                               Circle ball,
                                               Vect velocity)
Description copied from interface: GeometryInterface
Specified by Geometry.timeUntilRotatingCircleCollision

Specified by:
timeUntilRotatingCircleCollision in interface GeometryInterface
See Also:
Geometry.timeUntilRotatingCircleCollision(physics.Circle, physics.Vect, double, physics.Circle, physics.Vect)

reflectRotatingCircle

public Vect reflectRotatingCircle(Circle circle,
                                  Vect center,
                                  double angularVelocity,
                                  Circle ball,
                                  Vect velocity)
Description copied from interface: GeometryInterface
Specified by Geometry.reflectRotatingCircle

Specified by:
reflectRotatingCircle in interface GeometryInterface
See Also:
Geometry.reflectRotatingCircle(physics.Circle, physics.Vect, double, physics.Circle, physics.Vect)

reflectRotatingCircle

public Vect reflectRotatingCircle(Circle circle,
                                  Vect center,
                                  double angularVelocity,
                                  Circle ball,
                                  Vect velocity,
                                  double reflectionCoeff)
Description copied from interface: GeometryInterface
Specified by Geometry.reflectRotatingCircle

Specified by:
reflectRotatingCircle in interface GeometryInterface
See Also:
Geometry.reflectRotatingCircle(physics.Circle, physics.Vect, double, physics.Circle, physics.Vect)

timeUntilBallBallCollision

public double timeUntilBallBallCollision(Circle ball1,
                                         Vect vel1,
                                         Circle ball2,
                                         Vect vel2)
Description copied from interface: GeometryInterface
Specified by Geometry.timeUntilBallBallCollision

Specified by:
timeUntilBallBallCollision in interface GeometryInterface
See Also:
Geometry.timeUntilBallBallCollision(physics.Circle, physics.Vect, physics.Circle, physics.Vect)

reflectBalls

public Geometry.VectPair reflectBalls(Vect center1,
                                      double mass1,
                                      Vect velocity1,
                                      Vect center2,
                                      double mass2,
                                      Vect velocity2)
Description copied from interface: GeometryInterface
Specified by Geometry.reflectBalls

Specified by:
reflectBalls in interface GeometryInterface
See Also:
Geometry.reflectBalls(physics.Vect, double, physics.Vect, physics.Vect, double, physics.Vect)