Class Point

java.lang.Object
  |
  +--Point

public class Point
extends java.lang.Object

A representation of a point in N-dimensional space. In the current implementation N == 3.


Constructor Summary
Point(int x, int y, int z)
          Create a point in 3 dimensional space given three integers Requires: MAX_DIM == 3
Point(java.lang.String s)
          Create a new point given a string with MAX_DIM integers on it
 
Method Summary
 double distanceFrom(Point p)
          Calculate the distance of this point from point p Requires: p must not be null.
 double get(int i)
          Return the value in the ith dimension of this point Requires: 0 <= i < MAX_DIM
 boolean sameDimension(Point p, int k)
          Returns true if this point has the same value in dimension k as point p.
 java.lang.String toString()
          Construct the string representation of a Point: a list of the values in for each dimension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Point

public Point(java.lang.String s)
Create a new point given a string with MAX_DIM integers on it

Parameters:
s - A string containing MAX_DIM integers

Point

public Point(int x,
             int y,
             int z)
Create a point in 3 dimensional space given three integers Requires: MAX_DIM == 3

Parameters:
x -
y -
z -
Method Detail

get

public double get(int i)
Return the value in the ith dimension of this point Requires: 0 <= i < MAX_DIM

Parameters:
i - the dimension
Returns:
the value of dimension i

distanceFrom

public double distanceFrom(Point p)
Calculate the distance of this point from point p Requires: p must not be null.

Parameters:
p - The point to get the distance from
Returns:
The distance from this point to point p

sameDimension

public boolean sameDimension(Point p,
                             int k)
Returns true if this point has the same value in dimension k as point p. Requires: p must not be null, and it must have at least k dimensions Requires: 0 <= k < MAX_DIM

Parameters:
p - The point to compare.
k - The dimension of interest.
Returns:
true if the points are equal in dimension k.

toString

public java.lang.String toString()
Construct the string representation of a Point: a list of the values in for each dimension.

Overrides:
toString in class java.lang.Object
Returns:
The string represenation