org.haphazard.util
Class Point3D

java.lang.Object
  extended byjava.awt.geom.Point2D
      extended byjava.awt.geom.Point2D.Double
          extended byorg.haphazard.util.Point3D
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Vector3D

public class Point3D
extends java.awt.geom.Point2D.Double
implements java.lang.Cloneable

A point in 3D space


Nested Class Summary
 
Nested classes inherited from class java.awt.geom.Point2D
java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Float
 
Field Summary
 double z
          The Z coordinate
 
Fields inherited from class java.awt.geom.Point2D.Double
x, y
 
Constructor Summary
Point3D()
          Creates a new Point3D with the coordinates {0,0,0}
Point3D(double x, double y, double z)
          Creates a new instance of Point3D
 
Method Summary
 void add(Point3D point)
          Adds a point to the point
 void add(Vector3D vector)
          Adds a vector to the point
 java.lang.Object clone()
          Clones this object
 double distance(Point3D point)
          Calculates the distance to another point
 boolean equals(Point3D point)
          Checks if this point is approximately equal to another point
 boolean equals(Point3D point, double error)
          Checks if this point is approximately equal to another point
 double getZ()
          Gets the z-coordinate
 void setLocation(double x, double y, double z)
          Sets the coordinates of this Point
 java.lang.String toString()
          Transforms this object into a String on the form {x,y,z}
 
Methods inherited from class java.awt.geom.Point2D.Double
getX, getY, setLocation
 
Methods inherited from class java.awt.geom.Point2D
distance, distance, distance, distanceSq, distanceSq, distanceSq, equals, hashCode, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

z

public double z
The Z coordinate

Constructor Detail

Point3D

public Point3D()
Creates a new Point3D with the coordinates {0,0,0}


Point3D

public Point3D(double x,
               double y,
               double z)
Creates a new instance of Point3D

Parameters:
x - The x-coordinate
y - The y-coordinate
z - The z-coordinate
Method Detail

getZ

public double getZ()
Gets the z-coordinate

Returns:
The z-coordinate

setLocation

public void setLocation(double x,
                        double y,
                        double z)
Sets the coordinates of this Point

Parameters:
x - The x-coordinate
y - The y-coordinate
z - The z-coordinate

distance

public double distance(Point3D point)
Calculates the distance to another point

Parameters:
point - The point to calculate the distance to
Returns:
The distance to the other point

add

public void add(Vector3D vector)
Adds a vector to the point

Parameters:
vector - The vector to add

add

public void add(Point3D point)
Adds a point to the point

Parameters:
point - The point to add

toString

public java.lang.String toString()
Transforms this object into a String on the form {x,y,z}

Returns:
The coordinates on the form {x,y,z}

equals

public boolean equals(Point3D point)
Checks if this point is approximately equal to another point

Parameters:
point - The point to check against
Returns:
true if error is sufficiently small

equals

public boolean equals(Point3D point,
                      double error)
Checks if this point is approximately equal to another point

Parameters:
point - The point to check against
error - The error margin
Returns:
true if error is sufficiently small

clone

public java.lang.Object clone()
Clones this object

Returns:
A clone of this object