util
Class Vector3D

java.lang.Object
  extended by util.Vector3D
Direct Known Subclasses:
Point3D

public class Vector3D
extends java.lang.Object

This class allows storing 3-D vector components.


Field Summary
 double x
           
 double y
           
 double z
           
 
Constructor Summary
Vector3D()
          Creates a Vector3D object with (0, 0, 0) as the component values.
Vector3D(double x, double y, double z)
          Creates a Vector3D object with (x, y, and z) component values.
Vector3D(Point3D point)
          Creates a Vector3D object from a Point3D argument's component values.
Vector3D(Vector3D vector)
          Creates a Vector3D object from a Vector3D argument's component values.
 
Method Summary
 Vector3D clone()
          Creates a new Vector3D object from the Vector3D's component values.
 Vector3D crossProd(double x, double y, double z)
          Returns the vector from the cross product with the given vector components.
static Vector3D crossProd(double x1, double y1, double z1, double x2, double y2, double z2)
          Returns the vector from the cross product of the two vector component triplets.
 Vector3D crossProd(Vector3D vector)
          Returns the vector from the cross product with the given Vector3D.
static Vector3D crossProd(Vector3D vector1, Vector3D vector2)
          Returns the vector from the cross product of the two vectors.
 Vector3D diff(double x, double y, double z)
          Returns the difference between the two component vectors.
static Vector3D diff(double x1, double y1, double z1, double x2, double y2, double z2)
          Returns the difference between the two component vectors.
 Vector3D diff(Vector3D vector)
          Returns the difference between the two Vector3D vectors.
static Vector3D diff(Vector3D vector1, Vector3D vector2)
          Returns the difference between the two Vector3D vectors.
 double distance(double x, double y, double z)
          Returns the distance from this Point3D to the specified coordinate.
 double distance(Point3D point)
          Returns the distance from this Point3D to the specified Point3D.
 double distanceSQ(double x, double y, double z)
          Returns the distance squared from this Point3D to the specified coordinate.
static double distanceSQ(double x1, double y1, double z1, double x2, double y2, double z2)
          Returns the distance squared between the two coordinate locations.
 double distanceSQ(Point3D point)
          Returns the distance squared from this Point3D to the specified Point3D.
 double dotProd(double x, double y, double z)
          Returns the scalar value of the dot product with the given vector components.
static double dotProd(double x1, double y1, double z1, double x2, double y2, double z2)
          Returns the scalar value of the dot product with the given vector components.
 double dotProd(Vector3D vector)
          Returns the scalar value of the dot product with the given Vector3D.
static double dotProd(Vector3D vector1, Vector3D vector2)
          Returns the vector dot product between the given Vector3D vectors.
 double getX()
          Returns the X component of this Vector3D in double precision.
 double getY()
          Returns the Y component of this Vector3D in double precision.
 double getZ()
          Returns the Z component of this Vector3D in double precision.
 double magnitude()
          Returns the Euclidian magnitude of the Vector3D.
static double magnitude(double x, double y, double z)
          Returns the Euclidean magnitude of these vector components
 boolean normalize()
          Normalizes the vector.
 void Print()
          Prints the representation the value of this Vector3D.
 Vector3D scale(double scale)
          Returns the scaled vector.
 void setComponents(double x, double y, double z)
          Sets the Vector3D component values to the x, y, and Z component values.
 void setLocation(Vector3D vector)
          Sets the Vector3D object to the x, y, and Z component values of another vector.
 Vector3D sum(double x, double y, double z)
          Returns the sum of the two component vectors.
static Vector3D sum(double x1, double y1, double z1, double x2, double y2, double z2)
          Returns the sum of the two component vectors.
 Vector3D sum(Vector3D vector)
          Returns the sum of the two Vector3D vectors.
static Vector3D sum(Vector3D vector1, Vector3D vector2)
          Returns the sum of the two Vector3D vectors.
 java.lang.String toString()
          Returns a String that represents the value of this Vector3D.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x

y

public double y

z

public double z
Constructor Detail

Vector3D

public Vector3D()
Creates a Vector3D object with (0, 0, 0) as the component values.


Vector3D

public Vector3D(double x,
                double y,
                double z)
Creates a Vector3D object with (x, y, and z) component values.

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

Vector3D

public Vector3D(Vector3D vector)
Creates a Vector3D object from a Vector3D argument's component values.

Parameters:
vector - the other vector.

Vector3D

public Vector3D(Point3D point)
Creates a Vector3D object from a Point3D argument's component values.

Parameters:
point - the point.
Method Detail

clone

public Vector3D clone()
Creates a new Vector3D object from the Vector3D's component values.

Overrides:
clone in class java.lang.Object
Returns:
the new Vector3D object reference.

getX

public double getX()
Returns the X component of this Vector3D in double precision.

Returns:
the X component value.

getY

public double getY()
Returns the Y component of this Vector3D in double precision.

Returns:
the Y component value.

getZ

public double getZ()
Returns the Z component of this Vector3D in double precision.

Returns:
the Z component value.

setComponents

public void setComponents(double x,
                          double y,
                          double z)
Sets the Vector3D component values to the x, y, and Z component values.

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

setLocation

public void setLocation(Vector3D vector)
Sets the Vector3D object to the x, y, and Z component values of another vector.

Parameters:
vector - the other vector.

magnitude

public static double magnitude(double x,
                               double y,
                               double z)
Returns the Euclidean magnitude of these vector components

Parameters:
x - the X component
y - the Y component
z - the Z component

magnitude

public double magnitude()
Returns the Euclidian magnitude of the Vector3D.


scale

public Vector3D scale(double scale)
Returns the scaled vector.

Parameters:
scale - the scale multiplier.
Returns:
a scaled vector.

diff

public static Vector3D diff(Vector3D vector1,
                            Vector3D vector2)
Returns the difference between the two Vector3D vectors.

Parameters:
vector1 - the first vector
vector2 - the second vector

diff

public static Vector3D diff(double x1,
                            double y1,
                            double z1,
                            double x2,
                            double y2,
                            double z2)
Returns the difference between the two component vectors.

Parameters:
x1 - the first location's X component
y1 - the first location's Y component
z1 - the first location's Z component
x2 - the second location's X component
y2 - the second location's Y component
z2 - the second location's Z component
Returns:
the difference Vector3D.

diff

public Vector3D diff(Vector3D vector)
Returns the difference between the two Vector3D vectors.

Parameters:
vector - the other vector
Returns:
the difference Vector3D.

diff

public Vector3D diff(double x,
                     double y,
                     double z)
Returns the difference between the two component vectors.

Parameters:
x - the vector's X component
y - the vector's Y component
z - the vector's Z component
Returns:
the difference Vector3D.

sum

public static Vector3D sum(Vector3D vector1,
                           Vector3D vector2)
Returns the sum of the two Vector3D vectors.

Parameters:
vector1 - the first vector
vector2 - the second vector
Returns:
the difference Vector3D.

sum

public static Vector3D sum(double x1,
                           double y1,
                           double z1,
                           double x2,
                           double y2,
                           double z2)
Returns the sum of the two component vectors.

Parameters:
x1 - the first location's X component
y1 - the first location's Y component
z1 - the first location's Z component
x2 - the second location's X component
y2 - the second location's Y component
z2 - the second location's Z component
Returns:
the sum Vector3D.

sum

public Vector3D sum(Vector3D vector)
Returns the sum of the two Vector3D vectors.

Parameters:
vector - the other vector
Returns:
the sum Vector3D.

sum

public Vector3D sum(double x,
                    double y,
                    double z)
Returns the sum of the two component vectors.

Parameters:
x - the vector's X component
y - the vector's Y component
z - the vector's Z component
Returns:
the sum Vector3D.

dotProd

public static double dotProd(Vector3D vector1,
                             Vector3D vector2)
Returns the vector dot product between the given Vector3D vectors.

Parameters:
vector1 - the first vector.
vector2 - the second vector.
Returns:
the dot product scalar.

dotProd

public static double dotProd(double x1,
                             double y1,
                             double z1,
                             double x2,
                             double y2,
                             double z2)
Returns the scalar value of the dot product with the given vector components.

Parameters:
x1 - the first location's X component
y1 - the first location's Y component
z1 - the first location's Z component
x2 - the second location's X component
y2 - the second location's Y component
z2 - the second location's Z component
Returns:
the dot product scalar.

dotProd

public double dotProd(Vector3D vector)
Returns the scalar value of the dot product with the given Vector3D.

Parameters:
vector - the other vector.
Returns:
the dot product scalar.

dotProd

public double dotProd(double x,
                      double y,
                      double z)
Returns the scalar value of the dot product with the given vector components.

Parameters:
x - the X component
y - the Y component
z - the Z component
Returns:
the dot product scalar.

crossProd

public static Vector3D crossProd(Vector3D vector1,
                                 Vector3D vector2)
Returns the vector from the cross product of the two vectors.

Parameters:
vector1 - the first vector.
vector2 - the second vector.
Returns:
the cross product Vector3D.

crossProd

public static Vector3D crossProd(double x1,
                                 double y1,
                                 double z1,
                                 double x2,
                                 double y2,
                                 double z2)
Returns the vector from the cross product of the two vector component triplets.

Parameters:
x1 - the first vector's X component
y1 - the first vector's Y component
z1 - the first vector's Z component
x2 - the second vector's X component
y2 - the second vector's Y component
z2 - the second vector's Z component
Returns:
the cross product Vector3D.

crossProd

public Vector3D crossProd(Vector3D vector)
Returns the vector from the cross product with the given Vector3D.

Parameters:
vector - the other vector.
Returns:
the cross product Vector3D.

crossProd

public Vector3D crossProd(double x,
                          double y,
                          double z)
Returns the vector from the cross product with the given vector components.

Parameters:
x - the X component
y - the Y component
z - the Z component
Returns:
the cross product Vector3D.

normalize

public boolean normalize()
Normalizes the vector.

Returns:
true if a the magnitude was 0 so it couldn't be normalized.

distance

public double distance(double x,
                       double y,
                       double z)
Returns the distance from this Point3D to the specified coordinate.

Parameters:
x - the X coordinate
y - the Y coordinate
z - the Z coordinate

distance

public double distance(Point3D point)
Returns the distance from this Point3D to the specified Point3D.

Parameters:
point - the other point.

distanceSQ

public double distanceSQ(double x,
                         double y,
                         double z)
Returns the distance squared from this Point3D to the specified coordinate.

Parameters:
x - the X coordinate
y - the Y coordinate
z - the Z coordinate

distanceSQ

public double distanceSQ(Point3D point)
Returns the distance squared from this Point3D to the specified Point3D.

Parameters:
point - the other point.

distanceSQ

public static double distanceSQ(double x1,
                                double y1,
                                double z1,
                                double x2,
                                double y2,
                                double z2)
Returns the distance squared between the two coordinate locations.

Parameters:
x1 - the first location's X coordinate
y1 - the first location's Y coordinate
z1 - the first location's Z coordinate
x2 - the second location's X coordinate
y2 - the second location's Y coordinate
z2 - the second location's Z coordinate

toString

public java.lang.String toString()
Returns a String that represents the value of this Vector3D.

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

Print

public void Print()
Prints the representation the value of this Vector3D.