Class com.oroinc.math.geometry.GeometricVector
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.oroinc.math.geometry.GeometricVector

java.lang.Object
   |
   +----com.oroinc.math.geometry.Tuple
           |
           +----com.oroinc.math.geometry.GeometricVector

public final class GeometricVector
extends Tuple
A class used to represent a geometric vector. It is named GeometricVector instead of Vector to avoid having to use explicit class names when also using java.util.Vector.

Copyright © 1996, 1997 Original Reusable Objects, Inc. All rights reserved.

Author:
Daniel F. Savarese

Constructor Index

 o GeometricVector()
Default constructor.
 o GeometricVector(float, float)
Creates a two dimensional Vector.
 o GeometricVector(float, float, float)
Creates a three dimensional Vector.
 o GeometricVector(int)
Creates a GeometricVector of a given dimension and initizlies all of its coordinates to 0.
 o GeometricVector(Tuple)
The GeometricVector copy constructor.

Method Index

 o assign(GeometricVector)
This is the assignment operator for GeometricVectors.
 o clone()
Returns a deep copy of the GeometricVector.
 o cross(Tuple, Tuple)
Calculate the cross product of two vectors and return the result.
 o dot(Tuple, Tuple)
Calculate the dot product of two vectors and return the result.
 o magnitude()
Returns the magnitude of the vector.
 o normalize()
Normalizes the vector to a unit vector.
 o normalized()
Creates a new vector in the same direction as the calling vector, but normalized to unit length.
 o setDimension(int)
Sets the dimension of the GeometricVector.

Constructors

 o GeometricVector
  public GeometricVector(Tuple tuple)
The GeometricVector copy constructor. Creates a new GeometricVector instance that is a deep copy of the argument. The programmer should exercise care in choosing what Tuple subclasses to pass as an argument.

Parameters:
tuple - The Tuple used to initialize the new GeometricVector.
 o GeometricVector
  public GeometricVector(int dimension)
Creates a GeometricVector of a given dimension and initizlies all of its coordinates to 0. Only dimensions 1 to 3 are supported and no check is made to ensure a valid argument was passed. It is the programmer's responsibility to use valid arguments.

Parameters:
dimension - The dimension of the new GeometricVector.
 o GeometricVector
  public GeometricVector(float x,
                         float y)
Creates a two dimensional Vector.

Parameters:
x - The x component.
y - The y component.
 o GeometricVector
  public GeometricVector(float x,
                         float y,
                         float z)
Creates a three dimensional Vector.

Parameters:
x - The x component.
y - The y component.
z - The z component.
 o GeometricVector
  public GeometricVector()
Default constructor. Creates a GeometricVector of dimension 0 under the assumption that a subsequent call to setDimension(int) will be made.

Methods

 o cross
  public final static GeometricVector cross(Tuple v1,
                                            Tuple v2)
Calculate the cross product of two vectors and return the result. Assumes both vectors are 3 dimensional.

Parameters:
v1 - The first operand of the cross product.
v2 - The second operand of the cross product.
Returns:
The cross product of the two arguments.
 o dot
  public final static float dot(Tuple v1,
                                Tuple v2)
Calculate the dot product of two vectors and return the result.

Parameters:
v1 - The first operand of the dot product.
v2 - The second operand of the dot product.
Returns:
The dot product of the two arguments.
 o assign
  public void assign(GeometricVector vector)
This is the assignment operator for GeometricVectors. Assigns the value of the argument to the calling GeometricVector.

Parameters:
GeometricVector - The value to assign to the GeometricVector.
 o clone
  public Object clone()
Returns a deep copy of the GeometricVector. Essentially just returns
new GeometricVector(this);

Returns:
A deep copy of the GeometricVector.
Overrides:
clone in class Tuple
 o setDimension
  public void setDimension(int dimension)
Sets the dimension of the GeometricVector. Only dimensions 1 to 3 are supported and no check is made to ensure a valid argument was passed. It is the programmer's responsibility to use valid arguments.

Parameters:
dimension - The new dimension of the GeometricVector.
Overrides:
setDimension in class Tuple
 o magnitude
  public float magnitude()
Returns the magnitude of the vector. In ther words, the square root of its dot product.

Returns:
The magnitude of the vector.
 o normalize
  public void normalize()
Normalizes the vector to a unit vector. In other words, it multiplies the vector by the inverse of its magnitude.
 o normalized
  public GeometricVector normalized()
Creates a new vector in the same direction as the calling vector, but normalized to unit length.

Returns:
A normalized vector in the same direction as the caller.

All Packages  Class Hierarchy  This Package  Previous  Next  Index