|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.horstmann.violet.framework.Direction
public class Direction
This class describes a direction in the 2D plane. A direction is a vector of length 1 with an angle between 0 (inclusive) and 360 degrees (exclusive). There is also a degenerate direction of length 0.
Field Summary | |
---|---|
static Direction |
EAST
|
static Direction |
NORTH
|
static Direction |
SOUTH
|
static Direction |
WEST
|
Constructor Summary | |
---|---|
Direction(double dx,
double dy)
Constructs a direction (normalized to length 1). |
|
Direction(java.awt.geom.Point2D p,
java.awt.geom.Point2D q)
Constructs a direction between two points |
Method Summary | |
---|---|
double |
getX()
Gets the x-component of this direction |
double |
getY()
Gets the y-component of this direction |
Direction |
turn(double angle)
Turns this direction by an angle. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Direction NORTH
public static final Direction SOUTH
public static final Direction EAST
public static final Direction WEST
Constructor Detail |
---|
public Direction(double dx, double dy)
dx
- the x-value of the directiondy
- the corresponding y-value of the directionpublic Direction(java.awt.geom.Point2D p, java.awt.geom.Point2D q)
p
- the starting pointq
- the ending pointMethod Detail |
---|
public Direction turn(double angle)
angle
- the angle in degreespublic double getX()
public double getY()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |