Class PointCP

java.lang.Object
  |
  +--PointCP

public class PointCP
extends java.lang.Object

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
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

typeCoord

private char typeCoord
Contains C(artesian) or P(olar) to identify the type of coordinates that are being dealt with.

xOrRho

private double xOrRho
Contains the current value of X or RHO depending on the type of coordinates.

yOrTheta

private double yOrTheta
Contains the current value of Y or THETA value depending on the type of coordinates.
Constructor Detail

PointCP

public PointCP(char type,
               double xOrRho,
               double yOrTheta)
Constructs a coordinate object, with a type identifier.
Method Detail

getX

public double getX()

getY

public double getY()

getRho

public double getRho()

getTheta

public double getTheta()

convertStorageToPolar

public void convertStorageToPolar()
Converts Cartesian coordinates to Polar coordinates.

convertStorageToCartesian

public void convertStorageToCartesian()
Converts Polar coordinates to Cartesian coordinates.

getDistance

public double getDistance(PointCP pointB)
Calculates the distance in between two points using the Pythagorean theorem (C ^ 2 = A ^ 2 + B ^ 2). Not needed until E2.30.
Parameters:
pointA - The first point.
pointB - The second point.
Returns:
The distance between the two points.

rotatePoint

public PointCP rotatePoint(double rotation)
Rotates the specified point by the specified number of degrees. Not required until E2.30
Parameters:
point - The point to rotate
rotation - The number of degrees to rotate the point.
Returns:
The rotated image of the original point.

toString

public java.lang.String toString()
Returns information about the coordinates.
Returns:
A String containing information about the coordinates.
Overrides:
toString in class java.lang.Object