org.proteinshader.math
Class Point3d

java.lang.Object
  extended by org.proteinshader.math.Point3d
All Implemented Interfaces:
Cloneable

public class Point3d
extends Object
implements Cloneable

This class is used to create a point with 3 elements of type double. The Point3f class is nearly identical, except that it happens to use floats rather than doubles.

The x, y, and z attributes have been made public because this class is primarily only a data structure (although there are a few methods for doing basic point operations).


Field Summary
static String DECIMAL_FORMAT
          As a convienence for debugging, the toString() method will return a representation of a point in the general form "(x, y, z)", where the number of decimal places for each value will be determined this decimal format String, which is "0.000".
 double x
          The public x-coordinate of this three element point.
 double y
          The public y-coordinate of this three element point.
 double z
          The public z-coordinate of this three element point.
 
Constructor Summary
Point3d()
          Constructs a Point3d at the origin.
Point3d(double x, double y, double z)
          Constructs a point with the requested xyz-coordinates.
 
Method Summary
 Point3d add(Vec3d vec)
          Returns the point created by adding the vector given as an argument to the point that is the calling object.
 void addToMe(Vec3d vec)
          Tranlates the calling Point3d by adding the vector xyz-coordinates to it.
 Point3d clone()
          Returns a clone of this point.
 Vec3d minus(Point3d point)
          Returns the direction vector obtained by subtracting the point given as an argument from the calling point.
 void setXYZ(double x, double y, double z)
          Sets the xyz-values of the point.
 String toString()
          As a convenience for debugging, the toString() method returns the xyz-coordinates of the point in the form "(x, y, z)".
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DECIMAL_FORMAT

public static final String DECIMAL_FORMAT
As a convienence for debugging, the toString() method will return a representation of a point in the general form "(x, y, z)", where the number of decimal places for each value will be determined this decimal format String, which is "0.000".

See Also:
Constant Field Values

x

public double x
The public x-coordinate of this three element point.


y

public double y
The public y-coordinate of this three element point.


z

public double z
The public z-coordinate of this three element point.

Constructor Detail

Point3d

public Point3d()
Constructs a Point3d at the origin.


Point3d

public Point3d(double x,
               double y,
               double z)
Constructs a point with the requested xyz-coordinates.

Parameters:
x - the x-coordinate.
y - the y-coordinate.
z - the z-coordinate.
Method Detail

add

public Point3d add(Vec3d vec)
Returns the point created by adding the vector given as an argument to the point that is the calling object.

The original point is not modified.

Parameters:
vec - rgw vector to translate the point by.
Returns:
A new point.

addToMe

public void addToMe(Vec3d vec)
Tranlates the calling Point3d by adding the vector xyz-coordinates to it.

Parameters:
vec - the vector to translate the point by.

clone

public Point3d clone()
Returns a clone of this point.

The clone is a deep clone (completely independent of the original).

Overrides:
clone in class Object
Returns:
A clone of the calling Point.

minus

public Vec3d minus(Point3d point)
Returns the direction vector obtained by subtracting the point given as an argument from the calling point. The direction vector can be thought of as an arrow with its tail at the point given as an argument and the arrowhead at the point that is the calling object of this method.

Parameters:
point - The point to subtract from the calling point.
Returns:
A direction vector.

setXYZ

public void setXYZ(double x,
                   double y,
                   double z)
Sets the xyz-values of the point.

Parameters:
x - the x-coordinate.
y - the y-coordinate.
z - the z-coordinate.

toString

public String toString()
As a convenience for debugging, the toString() method returns the xyz-coordinates of the point in the form "(x, y, z)". The number of digits after the decimal place will be determined by the DECIMAL_FORMAT constant for this class.

Overrides:
toString in class Object
Returns:
A String representation of this vector.


Copyright © 2007-2008