Class Vector

java.lang.Object
  extended by Vector

public class Vector
extends java.lang.Object

Represents a three-dimensional vector.


Method Summary
 Vector add(Vector other)
          Returns the result of adding this vector to another.
static Vector create(double x, double y, double z)
          Creates a vector with the given x-, y-, and z-coordinates.
 Vector cross(Vector other)
          Returns the result of a cross product between this vector and another.
 double dot(Vector other)
          Returns the result of a dot product between this vector and another.
 double getLength()
          Returns the length, or magnitude, of this vector.
 double getX()
          Returns the change in x represented by this vector.
 double getY()
          Returns the change in y represented by this vector.
 double getZ()
          Returns the change in z represented by this vector.
 Vector normalize()
          Returns a vector that is the normalization of this vector.
 Vector projectOnto(Vector other)
          Returns the result of projecting this vector onto the direction of another.
 Vector scale(double scalar)
          Returns a vector that is in the same direction as this vector, but whose magnitude has been scaled by the given scalar.
 Vector subtract(Vector other)
          Returns the result of subtracting another vector from this one.
 java.lang.String toString()
          Returns a traditional representation of this vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getX

public double getX()
Returns the change in x represented by this vector.


getY

public double getY()
Returns the change in y represented by this vector.


getZ

public double getZ()
Returns the change in z represented by this vector.


getLength

public double getLength()
Returns the length, or magnitude, of this vector.


normalize

public Vector normalize()
Returns a vector that is the normalization of this vector. That is, the returned vector is in the same direction but has a length of 1.


dot

public double dot(Vector other)
Returns the result of a dot product between this vector and another.


cross

public Vector cross(Vector other)
Returns the result of a cross product between this vector and another.


add

public Vector add(Vector other)
Returns the result of adding this vector to another.


subtract

public Vector subtract(Vector other)
Returns the result of subtracting another vector from this one.


projectOnto

public Vector projectOnto(Vector other)
Returns the result of projecting this vector onto the direction of another. The returned vector will be in the same direction of the parameter vector.


scale

public Vector scale(double scalar)
Returns a vector that is in the same direction as this vector, but whose magnitude has been scaled by the given scalar.


toString

public java.lang.String toString()
Returns a traditional representation of this vector.

Overrides:
toString in class java.lang.Object

create

public static Vector create(double x,
                            double y,
                            double z)
Creates a vector with the given x-, y-, and z-coordinates.