gov.sandia.cognition.math.matrix.mtj
Class Vector3

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.math.AbstractRing<VectorType>
          extended by gov.sandia.cognition.math.matrix.AbstractVectorSpace<Vector,VectorEntry>
              extended by gov.sandia.cognition.math.matrix.AbstractVector
                  extended by gov.sandia.cognition.math.matrix.mtj.AbstractMTJVector
                      extended by gov.sandia.cognition.math.matrix.mtj.DenseVector
                          extended by gov.sandia.cognition.math.matrix.mtj.Vector3
All Implemented Interfaces:
Vector, Vector3D, Vectorizable, VectorSpace<Vector,VectorEntry>, Ring<Vector>, CloneableSerializable, Triple<Double,Double,Double>, Serializable, Cloneable, Iterable<VectorEntry>

@CodeReview(reviewer="Justin Basilico",
            date="2006-07-26",
            changesNeeded=false,
            comments="Looks good.")
public class Vector3
extends DenseVector
implements Vector3D

Implements a three-dimensional DenseVector.

Since:
1.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface gov.sandia.cognition.math.matrix.VectorSpace
VectorSpace.Entry
 
Field Summary
 
Fields inherited from class gov.sandia.cognition.math.matrix.AbstractVector
DEFAULT_DELIMITER
 
Constructor Summary
Vector3()
          Creates a new instance of Vector3 that is all zeros.
Vector3(double x, double y, double z)
          Creates a new instance of Vector3 with the given values.
Vector3(Vector other)
          Creates a new instance of Vector3 with values copied from the given vector.
Vector3(Vector3D other)
          Creates a new instance of Vector3 with values copied from the given vector.
 
Method Summary
 Vector3 clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
static Vector3 createRandom(Random random)
          Creates a new random Vector3 from the given Random object.
 int getDimensionality()
          Returns the number of elements in the Vector
 Double getFirst()
          Gets the first object.
 Double getSecond()
          Gets the second object.
 Double getThird()
          Gets the third object.
 double getX()
          Gets the value of the first dimension (x).
 double getY()
          Gets the value of the second dimension (y).
 double getZ()
          Gets the value of the third dimension (z).
 void setX(double x)
          Sets the value of the first dimension (x).
 void setXYZ(double x, double y, double z)
          Sets the value of all three dimensions of this vector.
 void setY(double y)
          Sets the value of the second dimension (y).
 void setZ(double z)
          Sets the value of the third dimension (z).
 String toString()
          The String representation of the Vector3, which is "<x, y, z>".
 
Methods inherited from class gov.sandia.cognition.math.matrix.mtj.DenseVector
equals, euclideanDistanceSquared, getArray, isSparse, outerProduct, setInternalVector, stack, subVector
 
Methods inherited from class gov.sandia.cognition.math.matrix.mtj.AbstractMTJVector
dotProduct, dotProduct, dotTimesEquals, getElement, getInternalVector, iterator, minusEquals, minusEquals, norm2, norm2Squared, outerProduct, plusEquals, plusEquals, scaledMinusEquals, scaledPlusEquals, scaledPlusEquals, scaleEquals, setElement, setInternalVector, times, times, zero
 
Methods inherited from class gov.sandia.cognition.math.matrix.AbstractVector
assertDimensionalityEquals, assertEqualDimensionality, assertSameDimensionality, checkSameDimensionality, convertFromVector, convertToVector, dotDivide, dotDivideEquals, equals, hashCode, toArray, toString, toString, transform, transformEquals, transformNonZeros, transformNonZerosEquals
 
Methods inherited from class gov.sandia.cognition.math.matrix.AbstractVectorSpace
angle, cosine, euclideanDistance, isUnitVector, isUnitVector, isZero, norm, norm1, normInfinity, sum, unitVector, unitVectorEquals
 
Methods inherited from class gov.sandia.cognition.math.AbstractRing
dotTimes, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.math.matrix.Vector
assertDimensionalityEquals, assertSameDimensionality, checkSameDimensionality, dotDivide, dotDivideEquals, getElement, isSparse, outerProduct, setElement, stack, subVector, times, toArray, toString, toString, transform, transformEquals, transformNonZeros, transformNonZerosEquals
 
Methods inherited from interface gov.sandia.cognition.math.matrix.VectorSpace
angle, cosine, dotProduct, euclideanDistance, euclideanDistanceSquared, isUnitVector, isUnitVector, norm, norm1, norm2, norm2Squared, normInfinity, sum, unitVector, unitVectorEquals
 
Methods inherited from interface gov.sandia.cognition.math.Ring
dotTimes, dotTimesEquals, equals, equals, isZero, isZero, minus, minusEquals, negative, negativeEquals, plus, plusEquals, scale, scaledMinus, scaledMinusEquals, scaledPlus, scaledPlusEquals, scaleEquals, zero
 
Methods inherited from interface java.lang.Iterable
iterator
 
Methods inherited from interface gov.sandia.cognition.math.matrix.Vectorizable
convertFromVector, convertToVector
 

Constructor Detail

Vector3

public Vector3()
Creates a new instance of Vector3 that is all zeros.


Vector3

public Vector3(double x,
               double y,
               double z)
Creates a new instance of Vector3 with the given values.

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

Vector3

public Vector3(Vector other)
Creates a new instance of Vector3 with values copied from the given vector.

Parameters:
other - The other vector to copy.

Vector3

public Vector3(Vector3D other)
Creates a new instance of Vector3 with values copied from the given vector.

Parameters:
other - The other vector to copy.
Method Detail

clone

public Vector3 clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface Vector
Specified by:
clone in interface Vectorizable
Specified by:
clone in interface Ring<Vector>
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractMTJVector
Returns:
A clone of this object.

getDimensionality

public int getDimensionality()
Description copied from interface: Vector
Returns the number of elements in the Vector

Specified by:
getDimensionality in interface Vector
Overrides:
getDimensionality in class AbstractMTJVector
Returns:
number of elements in the Vector

getX

public double getX()
Description copied from interface: Vector3D
Gets the value of the first dimension (x).

Specified by:
getX in interface Vector3D
Returns:
The value of the first dimension (x).

setX

public void setX(double x)
Description copied from interface: Vector3D
Sets the value of the first dimension (x).

Specified by:
setX in interface Vector3D
Parameters:
x - The value for the first dimension (x).

getY

public double getY()
Description copied from interface: Vector3D
Gets the value of the second dimension (y).

Specified by:
getY in interface Vector3D
Returns:
The value of the second dimension (y).

setY

public void setY(double y)
Description copied from interface: Vector3D
Sets the value of the second dimension (y).

Specified by:
setY in interface Vector3D
Parameters:
y - The value of the second dimension (y).

getZ

public double getZ()
Description copied from interface: Vector3D
Gets the value of the third dimension (z).

Specified by:
getZ in interface Vector3D
Returns:
The value of the third dimension (z).

setZ

public void setZ(double z)
Description copied from interface: Vector3D
Sets the value of the third dimension (z).

Specified by:
setZ in interface Vector3D
Parameters:
z - The value of the third dimension (z).

setXYZ

public void setXYZ(double x,
                   double y,
                   double z)
Description copied from interface: Vector3D
Sets the value of all three dimensions of this vector.

Specified by:
setXYZ in interface Vector3D
Parameters:
x - The value of the first dimension (x).
y - The value of the second dimension (y).
z - The value of the third dimension (z).

toString

public String toString()
The String representation of the Vector3, which is "<x, y, z>".

Specified by:
toString in interface Vector
Overrides:
toString in class AbstractVector
Returns:
The string "<x, y, z>".

createRandom

public static Vector3 createRandom(Random random)
Creates a new random Vector3 from the given Random object. Each value in the new Vector3 is a random number between 0.0 and 1.0.

Parameters:
random - The random number generator to use.
Returns:
A new random Vector3.

getFirst

public Double getFirst()
Description copied from interface: Triple
Gets the first object.

Specified by:
getFirst in interface Triple<Double,Double,Double>
Returns:
The first object.

getSecond

public Double getSecond()
Description copied from interface: Triple
Gets the second object.

Specified by:
getSecond in interface Triple<Double,Double,Double>
Returns:
The second object.

getThird

public Double getThird()
Description copied from interface: Triple
Gets the third object.

Specified by:
getThird in interface Triple<Double,Double,Double>
Returns:
The third object.