cynosurex.math
Class Vector

java.lang.Object
  extended by cynosurex.math.Vector
All Implemented Interfaces:
cynosurex.internal.AuthorCommon, cynosurex.internal.CommonInterface, cynosurex.internal.CompanyCommon

public class Vector
extends java.lang.Object
implements cynosurex.internal.CommonInterface


Field Summary
protected  double[] vector
          Internal storage of the vector.
 
Fields inherited from interface cynosurex.internal.CommonInterface
copyright, copyrightYears, notice, program, version
 
Fields inherited from interface cynosurex.internal.AuthorCommon
author, copyrightSymbol, noticeMsg, rights
 
Fields inherited from interface cynosurex.internal.CompanyCommon
company, email, website
 
Constructor Summary
Vector(double[] vector)
          Constructor to create a n-dimensional vector from an array.
Vector(double x, double y)
          Constructor to create a 2-dimensional vector.
Vector(double x, double y, double z)
          Constructor to create a 3-dimensional vector.
 
Method Summary
static Vector addition(Vector u, Vector v)
          Static method to add two vector together.
static Vector crossProduct(Vector u, Vector v)
          Static method to calculate the cross product of two vectors of length 3.
static double dotProduct(Vector u, Vector v)
          Static method to calculate the dot product of two vectors.
 int getDimension()
          This method returns the dimension of the vector.
 Vector getInverse()
          This method creates a new inverse vector based on the current vector.
 double getMagnitude()
          This method returns the magnitude (length) of the vector.
 Vector getUnitVector()
          This method creates a new unit vector based on the current vector.
 double getValueAt(int pos)
          This method returns the value within the vector.
 void inverse()
          This method inverses the current vector.
 void normalize()
          This method normalizes the vector into an unit vector.
static Vector scalarMultiplication(double value, Vector v)
          Static method to apply scalar multiplication to a vector.
 java.lang.String toString()
          This method overrides the super class method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vector

protected double[] vector
Internal storage of the vector.

Constructor Detail

Vector

public Vector(double[] vector)
Constructor to create a n-dimensional vector from an array.

Parameters:
vector - the array of the vector

Vector

public Vector(double x,
              double y)
Constructor to create a 2-dimensional vector.

Parameters:
x - value for x
y - value for y

Vector

public Vector(double x,
              double y,
              double z)
Constructor to create a 3-dimensional vector.

Parameters:
x - value for x
y - value for y
z - value for z
Method Detail

addition

public static Vector addition(Vector u,
                              Vector v)
Static method to add two vector together.

Parameters:
u - vector 1
v - vector 2

crossProduct

public static Vector crossProduct(Vector u,
                                  Vector v)
Static method to calculate the cross product of two vectors of length 3.

Parameters:
u - vector 1
v - vector 2

dotProduct

public static double dotProduct(Vector u,
                                Vector v)
Static method to calculate the dot product of two vectors.

Parameters:
u - vector 1
v - vector 2

scalarMultiplication

public static Vector scalarMultiplication(double value,
                                          Vector v)
Static method to apply scalar multiplication to a vector.

Parameters:
value - the value to multiply
v - the vector

getValueAt

public double getValueAt(int pos)
This method returns the value within the vector.

Parameters:
pos - the position of the value

getMagnitude

public double getMagnitude()
This method returns the magnitude (length) of the vector.


getDimension

public int getDimension()
This method returns the dimension of the vector.


getInverse

public Vector getInverse()
This method creates a new inverse vector based on the current vector.


inverse

public void inverse()
This method inverses the current vector.


getUnitVector

public Vector getUnitVector()
This method creates a new unit vector based on the current vector.


normalize

public void normalize()
This method normalizes the vector into an unit vector.


toString

public java.lang.String toString()
This method overrides the super class method.

Overrides:
toString in class java.lang.Object