Class Vector

java.lang.Object
  extended by Vector

public class Vector
extends java.lang.Object

Represents a vector in three-dimensional space.


Field Summary
static Vector ZERO
          The zero vector, with zero in all components.
 
Method Summary
 Vector add(Vector other)
          Returns the sum of this vector and the parameter vector.
static Vector create(double x, double y, double z)
          Creates a vector with the given components.
 Vector cross(Vector other)
          Returns the cross-product of this vector and the parameter vector.
 double dot(Vector other)
          Returns the dot-product of this vector and the parameter vector.
 double dotPoint(Point other)
          Returns the dot-product of this vector and the vector from the origin to the parameter point.
 double getLength()
          Returns the length of this vector.
 double getLengthSquared()
          Returns the square of the length of this vector.
 double getX()
          Returns the x-component of this vector.
 double getY()
          Returns the y-component of this vector.
 double getZ()
          Returns the z-component of this vector.
 Vector normalize()
          Returns a vector in the same direction as this one, but whose length is one.
 Vector projectOnto(Vector other)
          Returns the vector resulting from projecting this vector onto the given vector's direction.
 Vector scale(double scalar)
          Returns a copy of this vector scaled by the given vector.
 Vector subtract(Vector other)
          Returns the difference of this vector and the parameter vector.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final Vector ZERO
The zero vector, with zero in all components.

Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getX

public double getX()
Returns the x-component of this vector.


getY

public double getY()
Returns the y-component of this vector.


getZ

public double getZ()
Returns the z-component of this vector.


getLengthSquared

public double getLengthSquared()
Returns the square of the length of this vector.


getLength

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


normalize

public Vector normalize()
Returns a vector in the same direction as this one, but whose length is one.


dot

public double dot(Vector other)
Returns the dot-product of this vector and the parameter vector.


dotPoint

public double dotPoint(Point other)
Returns the dot-product of this vector and the vector from the origin to the parameter point.


cross

public Vector cross(Vector other)
Returns the cross-product of this vector and the parameter vector.


add

public Vector add(Vector other)
Returns the sum of this vector and the parameter vector.


subtract

public Vector subtract(Vector other)
Returns the difference of this vector and the parameter vector.


projectOnto

public Vector projectOnto(Vector other)
Returns the vector resulting from projecting this vector onto the given vector's direction.


scale

public Vector scale(double scalar)
Returns a copy of this vector scaled by the given vector.


create

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