|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--PointCP
This class contains instances of coordinates in either polar or cartesian format. It also provides the utilities to convert them into the other type. It is not an optimal design, it is used only to illustrate some design issues.
Field Summary | |
private char |
typeCoord
Contains C(artesian) or P(olar) to identify the type of coordinates that are being dealt with. |
private double |
xOrRho
Contains the current value of X or RHO depending on the type of coordinates. |
private double |
yOrTheta
Contains the current value of Y or THETA value depending on the type of coordinates. |
Constructor Summary | |
PointCP(char type,
double xOrRho,
double yOrTheta)
Constructs a coordinate object, with a type identifier. |
Method Summary | |
void |
convertStorageToCartesian()
Converts Polar coordinates to Cartesian coordinates. |
void |
convertStorageToPolar()
Converts Cartesian coordinates to Polar coordinates. |
double |
getDistance(PointCP pointB)
Calculates the distance in between two points using the Pythagorean theorem (C ^ 2 = A ^ 2 + B ^ 2). |
double |
getRho()
|
double |
getTheta()
|
double |
getX()
|
double |
getY()
|
PointCP |
rotatePoint(double rotation)
Rotates the specified point by the specified number of degrees. |
java.lang.String |
toString()
Returns information about the coordinates. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private char typeCoord
private double xOrRho
private double yOrTheta
Constructor Detail |
public PointCP(char type, double xOrRho, double yOrTheta)
Method Detail |
public double getX()
public double getY()
public double getRho()
public double getTheta()
public void convertStorageToPolar()
public void convertStorageToCartesian()
public double getDistance(PointCP pointB)
pointA
- The first point.pointB
- The second point.public PointCP rotatePoint(double rotation)
point
- The point to rotaterotation
- The number of degrees to rotate the point.public java.lang.String toString()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |