fi.utu.cs.physics
Class BoundaryLine

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

public class BoundaryLine
extends Boundary

A boundary line.

Since:
1.1

Field Summary
static int HORIZONTAL
          A horizontal boundary line.
static int OTHER
          Non-vertical and non-horizontal boundary line.
static int VERTICAL
          A vertical boundary line.
 
Fields inherited from class fi.utu.cs.physics.Boundary
boundaryEpsilon
 
Constructor Summary
BoundaryLine(double px1, double py1, double px2, double py2)
          Constructs a boundary line from point (px1, py1) to point (px2, py2).
BoundaryLine(Point2 p1, Point2 p2)
          Constructs a boundary line from point p1 to point p2.
 
Method Summary
 void elasticCollision(Body other)
          Realizes an elastic collision for the static boundary and the body other.
 Point2[] getEndPoints()
          Returns a two-element array comprising the end points.
 int getType()
          Returns the type of the boundary line.
 void inelasticCollision(Body other)
          Realizes an inelastic collision for the static boundary and the body other.
protected  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 line; otherwise, returns false.
protected  boolean isCrossedByLine(double x1, double y1, double x2, double y2)
          Returns true, if the line (x1, y1)-(x2, y2) crosses the boundary line; otherwise, returns false.
 java.lang.String toString()
          Returns a string that contains the values of the attributes.
 
Methods inherited from class fi.utu.cs.physics.Boundary
isCrossed
 
Methods inherited from class fi.utu.cs.physics.Particle
addCollisionNotification, clearCollisionNotifications, getOwner, isCollisionNotified, isCollisionNotified, isCorporeal, removeCollisionNotification, setCorporeal, setEthereal, setOwner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OTHER

public static final int OTHER
Non-vertical and non-horizontal boundary line.

See Also:
Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
A horizontal boundary line.

See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
A vertical boundary line.

See Also:
Constant Field Values
Constructor Detail

BoundaryLine

public BoundaryLine(double px1,
                    double py1,
                    double px2,
                    double py2)
Constructs a boundary line from point (px1, py1) to point (px2, py2).


BoundaryLine

public BoundaryLine(Point2 p1,
                    Point2 p2)
Constructs a boundary line from point p1 to point p2.

Method Detail

getEndPoints

public Point2[] getEndPoints()
Returns a two-element array comprising the end points.


getType

public int getType()
Returns the type of the boundary line.

See Also:
HORIZONTAL, VERTICAL, OTHER

isCrossedByBoundingBox

protected 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 line; otherwise, returns false.

Specified by:
isCrossedByBoundingBox in class Boundary

isCrossedByLine

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

Specified by:
isCrossedByLine in class Boundary

elasticCollision

public void elasticCollision(Body other)
Realizes an elastic collision for the static boundary and the body other. The linear momentum and kinetic energy of the body is conserved in the collision.

Specified by:
elasticCollision in class Particle
See Also:
Particle.inelasticCollision(Body)

inelasticCollision

public void inelasticCollision(Body other)
Realizes an inelastic collision for the static boundary and the body other. The linear momentum is conserved but kinetic energy is lost in the collision.

Specified by:
inelasticCollision in class Particle
See Also:
Particle.elasticCollision(Body)

toString

public java.lang.String toString()
Returns a string that contains the values of the attributes.

Overrides:
toString in class Particle