Class Space

java.lang.Object
  |
  +--Space

public class Space
extends java.lang.Object

Space maintains a collection of Points, and a current view point. The points in space can be ordered by their distance from the current view point.


Constructor Summary
Space()
           
 
Method Summary
 void addPoint(Point p)
          Add Point p to this space.
 Point get(int i)
          Get the point at position i in the collection ordered by the current view point.
 void order()
          Sort the points in order of distance from the viewpoint.
 void printPoints(java.io.PrintStream ps)
          Print the list of points.
 java.util.Vector samePlane(int k)
          Print the list of points that are in the same kth plane as point p.
 void setView(int x, int y, int z)
          Create 3d viewpoint.
 void setView(Point p)
          Set the view point to be p.
 java.lang.String toString()
          Create a string represenation of the object where the collection is given in order of a point's distance from the view point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Space

public Space()
Method Detail

setView

public void setView(int x,
                    int y,
                    int z)
Create 3d viewpoint.

Parameters:
x -
y -
z -

setView

public void setView(Point p)
Set the view point to be p.

Parameters:
p - The new view point.

get

public Point get(int i)
Get the point at position i in the collection ordered by the current view point.

Parameters:
i - The position of the point to retrieve.
Returns:
The point found at position i, or null if i is not a valid position.

toString

public java.lang.String toString()
Create a string represenation of the object where the collection is given in order of a point's distance from the view point.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the collection.

samePlane

public java.util.Vector samePlane(int k)
Print the list of points that are in the same kth plane as point p.

Parameters:
k - The index of the plane to report on.

addPoint

public void addPoint(Point p)
Add Point p to this space.

Parameters:
p - The point to add.

order

public void order()
Sort the points in order of distance from the viewpoint. Original source of the code is given below. A bubble sort demonstration algorithm SortAlgorithm.java, Thu Oct 27 10:32:35 1994 *


printPoints

public void printPoints(java.io.PrintStream ps)
                 throws java.io.IOException
Print the list of points.

Parameters:
ps - The PrintStream to print to.
java.io.IOException