raja
Class Vector3D

java.lang.Object
  |
  +--raja.Vector3D
All Implemented Interfaces:
Serializable, Writable

public class Vector3D
extends Object
implements Serializable, Writable

The Vector3D class defines a high precision vector in the 3 dimensional space, given by its 3D coordinates. This class provides most of the classical operations on vectors (norm, dot product, cross product, projection...).

See Also:
Point3D, Serialized Form

Field Summary
 double x
          The x coordinate.
 double y
          The y coordinate.
 double z
          The z coordinate.
 
Constructor Summary
Vector3D(double x, double y, double z)
          Creates a Vector3D object initialized with the specified 3D coordinates.
Vector3D(Point3D source, Point3D dest)
          Initializes a newly created Vector3D object so that it represents the vector connecting the two specified 3D points.
Vector3D(Vector3D v)
          Initializes a newly created Vector3D object so that it represents the same 3 dimensional vector as the argument.
 
Method Summary
static Object build(ObjectReader reader)
          Creates a Vector3D object from the specified ObjectReader.
static Vector3D crossProduct(Vector3D v1, Vector3D v2)
          Computes the cross product of the two specified Vector3D.
static double dotProduct(Vector3D v1, Vector3D v2)
          Computes the dot product of the two specified Vector3D.
 double norm()
          Computes the norm of this Vector3D.
static Vector3D normalization(Vector3D v)
          Computes a normed version of the specified Vector3D.
 double normSq()
          Computes the square of the norm of this Vector3D.
static Vector3D opposite(Vector3D v)
          Computes the opposite of the specified Vector3D.
static Vector3D product(Vector3D v, double f)
          Computes the product of the specified Vector3D with the specified double factor.
static Vector3D projection(Vector3D v, Vector3D n)
          Computes the projection of the specified Vector3D on the hyperplane given by the specified normal.
static Vector3D sum(Vector3D v1, Vector3D v2)
          Computes the sum of the two specified Vector3D.
 String toString()
          Returns a textual String representation of this Vector3D object.
 void write(ObjectWriter writer)
          Writes the contents of this Vector3D object to the specified ObjectWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
The x coordinate.

y

public double y
The y coordinate.

z

public double z
The z coordinate.
Constructor Detail

Vector3D

public Vector3D(double x,
                double y,
                double z)
Creates a Vector3D object initialized with the specified 3D coordinates.
Parameters:
x, y, z - the coordinates to which to set the newly constructed Vector3D.

Vector3D

public Vector3D(Vector3D v)
Initializes a newly created Vector3D object so that it represents the same 3 dimensional vector as the argument. In other words, the newly created Vector3D is a copy of the specified Vector3D.
Parameters:
p - a Vector3D object.

Vector3D

public Vector3D(Point3D source,
                Point3D dest)
Initializes a newly created Vector3D object so that it represents the vector connecting the two specified 3D points.
Parameters:
source - the source Point3D.
dest - the destination Point3D.
Method Detail

build

public static Object build(ObjectReader reader)
                    throws IOException
Creates a Vector3D object from the specified ObjectReader.
Parameters:
reader - the ObjectReader to read the fields from.

norm

public double norm()
Computes the norm of this Vector3D.
Returns:
the norm of this Vector3D.

normSq

public double normSq()
Computes the square of the norm of this Vector3D.
Returns:
the square of the norm of this Vector3D.

normalization

public static Vector3D normalization(Vector3D v)
Computes a normed version of the specified Vector3D. The norm of the Vector3D argument is assumed to be non zero.
Parameters:
v - a Vector3D object, whose norm is non zero.
Returns:
a normed version of the specified Vector3D.

dotProduct

public static double dotProduct(Vector3D v1,
                                Vector3D v2)
Computes the dot product of the two specified Vector3D.
Parameters:
v1, v2 - the two Vector3D to dot product.
Returns:
the dot product of the two specified Vector3D.

product

public static Vector3D product(Vector3D v,
                               double f)
Computes the product of the specified Vector3D with the specified double factor.
Parameters:
v - the Vector3D product with.
f - the double factor.
Returns:
an instance of Vector3D that is the product of the specified Vector3D with the specified double factor.

crossProduct

public static Vector3D crossProduct(Vector3D v1,
                                    Vector3D v2)
Computes the cross product of the two specified Vector3D.
Parameters:
v1, v2 - the two Vector3D to cross product.
Returns:
an instance of Vector3D that is the cross product of the two specified Vector3D.

sum

public static Vector3D sum(Vector3D v1,
                           Vector3D v2)
Computes the sum of the two specified Vector3D.
Parameters:
v1, v2 - the two Vector3D to sum.
Returns:
an instance of Vector3D that is the sum of the two specified Vector3D.

opposite

public static Vector3D opposite(Vector3D v)
Computes the opposite of the specified Vector3D.
Parameters:
v - the Vector3D to compute the opposite of.
Returns:
an instance of Vector3D that is the opposite of the specified Vector3D.

projection

public static Vector3D projection(Vector3D v,
                                  Vector3D n)
Computes the projection of the specified Vector3D on the hyperplane given by the specified normal.
Parameters:
v - the Vector3D project.
n - the normal of the hyperplane to project the specified Vector3D on.
Returns:
an instance of Vector3D that is the projection of the specified Vector3D on the hyperplane given by the specified normal.

toString

public String toString()
Returns a textual String representation of this Vector3D object.
Overrides:
toString in class Object

write

public void write(ObjectWriter writer)
           throws IOException
Writes the contents of this Vector3D object to the specified ObjectWriter.
Specified by:
write in interface Writable
Parameters:
writer - the ObjectWriter to write the fields to.