|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdriver.ted.utilities.T_Vector
public class T_Vector
Title: T_Vector
Description: This class provides the scientific vector functionality.
The precision variable is used for display purposes, the actual value used in calculations is the full
value allowed by a double.
Copyright: (c) 2002 - 2006
Change History:
| Constructor Summary | |
|---|---|
T_Vector()
Default Constructor. |
|
T_Vector(double x,
double y,
double z)
Constructor specifying three doubles with which to initialze a three-dimensional vector. |
|
T_Vector(double x,
double y,
double z,
int precision)
Constructor specifying initial values and a precision for a vector. |
|
T_Vector(int size)
Constructor specifying an integer size. |
|
T_Vector(int size,
int precision)
Constructor specifying an integer size and an integer precision. |
|
| Method Summary | |
|---|---|
T_Vector |
cross(T_Vector v)
Cross Product function for vectors Usage: v3 = v1xv2 is implemented as v3 = v1.cross(v2) |
double |
dot(T_Vector v)
Dot Product function for vectors Usage: x = v1*v2 is implemented as x = v1.dot(v2) |
double |
getElement(int index)
Accessor function to return an element at the specified index. |
int |
getPrecision()
Accessor function to return the precision value for the vector. |
int |
getSize()
Returns the size of the vector. |
double |
magnitude()
Method to return the magnitude of the vector The magnitude is calculated as sqrt(x^2 + y^2 + z^2 + ...) |
static void |
main(java.lang.String[] args)
An executable function to test the Vector Library. |
T_Vector |
plus(T_Vector v)
Addition function for vectors Usage: v3 = v1 + v2 is implemented as v3 = v1.plus(v2) |
void |
setElement(int index,
double value)
Method to set an individual element within the vector. |
java.lang.String |
toString()
Method to display the vector in convienent notation. |
T_Vector |
unit()
Method to return the unit vector. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public T_Vector()
public T_Vector(int size)
size - The size of the vector, otherwise known as the length.
The returned vector will have n elements indexed from 0 to size-1.
public T_Vector(int size,
int precision)
size - The size of the vector, otherwise known as the length.
The returned vector will have size elements indexed from 0 to size-1.precision - The precision of the vector; the number of places to the
right of the decimal point.
public T_Vector(double x,
double y,
double z)
x - The x value of the vector, indexed by 0.y - The y value of the vector, indexed by 1.z - The z value of the vector, indexed by 2.
public T_Vector(double x,
double y,
double z,
int precision)
x - The x value of the vector, indexed by 0.y - The y value of the vector, indexed by 1.z - The z value of the vector, indexed by 2.precision - The number of decimal places required for this vector's elements.| Method Detail |
|---|
public int getSize()
public double getElement(int index)
index - The index in the vector array for the element to be returned
public int getPrecision()
public void setElement(int index,
double value)
throws java.lang.ArrayIndexOutOfBoundsException
index - The index in the vector for which the value will be changedvalue - The value to set at element index
java.lang.ArrayIndexOutOfBoundsException - The index must be between 0 and getSize() - 1public java.lang.String toString()
toString in class java.lang.Object
public T_Vector plus(T_Vector v)
throws java.lang.ArrayIndexOutOfBoundsException
v3[0] = v1[0] + v2[0]
v3[1] = v1[1] + v2[1] etc.
v - The vector to add
java.lang.ArrayIndexOutOfBoundsException - If the vectors are not the same size
public T_Vector cross(T_Vector v)
throws java.lang.ArrayIndexOutOfBoundsException
v3[0] = v1[1]*v2[2] - v2[1]*v1[2]
v3[1] = v1[0]*v2[2] - v2[0]*v1[2]
v3[2] = v1[0]*v2[1] - v2[0]*v1[1]
v - The vector to cross into
java.lang.ArrayIndexOutOfBoundsException - If the vectors are not the same size
public double dot(T_Vector v)
throws java.lang.ArrayIndexOutOfBoundsException
x = v1[0]*v2[0] + v1[1]*v2[1] + ...
v - The vector to dot into
java.lang.ArrayIndexOutOfBoundsException - If the vectors are not the same size,
or if the vector size is not equal to 3.public T_Vector unit()
public double magnitude()
public static void main(java.lang.String[] args)
args - Argument string to the test program.
(Not needed for this test program)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||