sysModel.env
Class ASquareEnv.Direction

java.lang.Object
  extended by sysModel.env.ASquareEnv.Direction
Enclosing class:
ASquareEnv

public class ASquareEnv.Direction
extends java.lang.Object

Concrete direction class.


Field Summary
private  double _dx
          Direction delta x.
private  double _dy
          Direction delta y.
private  double EPSILON
           
 
Constructor Summary
ASquareEnv.Direction()
          Creates a new direction facing north.
ASquareEnv.Direction(ASquareEnv.Direction other)
          Constructor.
ASquareEnv.Direction(double dx, double dy)
          Constructor.
 
Method Summary
 ASquareEnv.Direction duplicate()
          Return a new object which has the same direction.
 double getAngle()
          Return the angle between (0,-1) and this direction.
 double getDeltaX()
          Return the direction delta x.
 double getDeltaY()
          Return the direction delta y.
 ASquareEnv.Direction parse(Lexer l)
          Parses a direction.
 void reverseDirection()
          Reverse this direction.
 void rotateGraphics(java.awt.Graphics2D g)
          Rotate the graphics object by the angle between (0,-1) and this direction.
 boolean same(ASquareEnv.Direction other)
          Return true of this direction is the same as the other.
 java.lang.String toString()
          Overridden toString method.
 void turnLeft()
          Turn this direction PI/2 radians to the left.
 void turnLeft(double radians)
          Turn this direction to the left.
 void turnRight()
          Turn this direction PI/2 radians to the right.
 void turnRight(double radians)
          Turn this direction to the right.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EPSILON

private final double EPSILON
See Also:
Constant Field Values

_dx

private double _dx
Direction delta x.


_dy

private double _dy
Direction delta y.

Constructor Detail

ASquareEnv.Direction

public ASquareEnv.Direction(ASquareEnv.Direction other)
Constructor.

Parameters:
other - other direction

ASquareEnv.Direction

public ASquareEnv.Direction(double dx,
                            double dy)
Constructor.

Parameters:
dx - delta x
dy - delta y

ASquareEnv.Direction

public ASquareEnv.Direction()
Creates a new direction facing north.

Method Detail

getDeltaX

public double getDeltaX()
Return the direction delta x.

Returns:
double direction delta x

getDeltaY

public double getDeltaY()
Return the direction delta y.

Returns:
double direction delta y

duplicate

public ASquareEnv.Direction duplicate()
Return a new object which has the same direction.

Returns:
new object with same direction

reverseDirection

public void reverseDirection()
Reverse this direction.


same

public boolean same(ASquareEnv.Direction other)
Return true of this direction is the same as the other.

Parameters:
other - other direction
Returns:
true if the directions are the same

turnLeft

public void turnLeft(double radians)
Turn this direction to the left.

Parameters:
radians - radians to turn

turnLeft

public void turnLeft()
Turn this direction PI/2 radians to the left.


turnRight

public void turnRight(double radians)
Turn this direction to the right.

Parameters:
radians - radians to turn

turnRight

public void turnRight()
Turn this direction PI/2 radians to the right.


toString

public java.lang.String toString()
Overridden toString method.

Overrides:
toString in class java.lang.Object
Returns:
string representation

parse

public ASquareEnv.Direction parse(Lexer l)
Parses a direction.

Parameters:
l - parser to read from
Returns:
parsed direction

rotateGraphics

public void rotateGraphics(java.awt.Graphics2D g)
Rotate the graphics object by the angle between (0,-1) and this direction.

Parameters:
g - graphics object to rotate

getAngle

public double getAngle()
Return the angle between (0,-1) and this direction.

Returns:
angle in radians