fi.utu.cs.physics
Class Boundary

java.lang.Object
  |
  +--fi.utu.cs.physics.Particle
        |
        +--fi.utu.cs.physics.Boundary
Direct Known Subclasses:
BoundaryCurve, BoundaryLine

public abstract class Boundary
extends Particle

A static physical boundary which can be open or closed. The boundary can be owned by an instance of the class Universe. The boundary can be either corporeal or ethereal, which determines whether it can be collided or not (i.e., only the corporeal boundaries can be collided).

Since:
1.1
See Also:
Universe, Body

Field Summary
protected static EpsilonComparator boundaryEpsilon
          An epsilon comparator for boundary calculations.
 
Constructor Summary
protected Boundary()
          Constructs a boundary that has no owner.
 
Method Summary
 boolean isCrossed(Body other, double dt)
          Checks whether the boundary will be crossed by the body other within the next dt seconds.
protected abstract  boolean isCrossedByBoundingBox(double x1, double y1, double x2, double y2, double r)
          Returns true, if the bounding box of the path (x1, y1)-(x2, y2) of a circle with a radius r crosses the boundary; otherwise, returns false.
protected abstract  boolean isCrossedByLine(double x1, double y1, double x2, double y2)
          Returns true, if the line (x1, y1)-(x2, y2) crosses the boundary; otherwise, returns false.
 
Methods inherited from class fi.utu.cs.physics.Particle
addCollisionNotification, clearCollisionNotifications, elasticCollision, getOwner, inelasticCollision, isCollisionNotified, isCollisionNotified, isCorporeal, removeCollisionNotification, setCorporeal, setEthereal, setOwner, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

boundaryEpsilon

protected static final EpsilonComparator boundaryEpsilon
An epsilon comparator for boundary calculations.

Constructor Detail

Boundary

protected Boundary()
Constructs a boundary that has no owner.

Method Detail

isCrossedByBoundingBox

protected abstract boolean isCrossedByBoundingBox(double x1,
                                                  double y1,
                                                  double x2,
                                                  double y2,
                                                  double r)
Returns true, if the bounding box of the path (x1, y1)-(x2, y2) of a circle with a radius r crosses the boundary; otherwise, returns false.


isCrossedByLine

protected abstract boolean isCrossedByLine(double x1,
                                           double y1,
                                           double x2,
                                           double y2)
Returns true, if the line (x1, y1)-(x2, y2) crosses the boundary; otherwise, returns false.


isCrossed

public boolean isCrossed(Body other,
                         double dt)
Checks whether the boundary will be crossed by the body other within the next dt seconds.

See Also:
Body.advance(double), isCrossedByBoundingBox(double,double,double,double,double), isCrossedByLine(double,double,double,double)