Terrenus HRPT v2.2

terrenus.orbit
Class VectorOp

java.lang.Object
  extended by terrenus.orbit.VectorOp

public class VectorOp
extends java.lang.Object

The VectorOp class performs various vector and matrix operations.


Field Summary
static int X
          The index of the x coordinate.
static int Y
          The index of the y coordinate.
static int Z
          The index of the z coordinate.
 
Constructor Summary
VectorOp()
           
 
Method Summary
static double[] add(double[] vectorA, double[] vectorB, double[] output)
          Computes the sum two vectors, a + b.
static double[] cross(double[] vectorA, double[] vectorB, double[] output)
          Computes the cross product of two vectors, a x b.
static double dot(double[] vectorA, double[] vectorB)
          Computes the dot product of two vectors, a (dot) b.
static double magnitude(double[] vector)
          Computes the vector 2-norm magnitude.
static double[][] multiply(double[][] matrixA, double[][] matrixB, double[][] output)
          Computes the product of two matrices, AB.
static double[] multiply(double[][] matrix, double[] vector, double[] output)
          Applies a matrix transform to a vector.
static double[] multiply(double[] vector, double factor, double[] output)
          Multiplies a vector by a scalar.
static double[] normalize(double[] vector, double[] output)
          Normalizes a vector to unit magnitude.
static double[][] rotationMatrix(int axis, double theta, double[][] output)
          Computes a rotation matrix.
static double[] subtract(double[] vectorA, double[] vectorB, double[] output)
          Computes the difference of two vectors, a - b.
static java.lang.String toString(double[] vector)
          Converts a vector to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X

public static final int X
The index of the x coordinate.

See Also:
Constant Field Values

Y

public static final int Y
The index of the y coordinate.

See Also:
Constant Field Values

Z

public static final int Z
The index of the z coordinate.

See Also:
Constant Field Values
Constructor Detail

VectorOp

public VectorOp()
Method Detail

multiply

public static double[] multiply(double[] vector,
                                double factor,
                                double[] output)
Multiplies a vector by a scalar.

Parameters:
vector - the vector to multiply.
factor - the scalar multiple.
output - the output vector to fill. If null, an output vector is created.
Returns:
the output vector.

magnitude

public static double magnitude(double[] vector)
Computes the vector 2-norm magnitude.

Parameters:
vector - the vector to compute magnitude.
Returns:
the vector 2-norm magnitude.

normalize

public static double[] normalize(double[] vector,
                                 double[] output)
Normalizes a vector to unit magnitude.

Parameters:
vector - the vector to normalize.
output - the output vector to fill. If null, an output vector is created.
Returns:
the output vector.

cross

public static double[] cross(double[] vectorA,
                             double[] vectorB,
                             double[] output)
Computes the cross product of two vectors, a x b.

Parameters:
vectorA - the first vector in the product.
vectorB - the second vector in the product.
output - the output vector to fill. If null, an output vector is created.
Returns:
the output product vector.

add

public static double[] add(double[] vectorA,
                           double[] vectorB,
                           double[] output)
Computes the sum two vectors, a + b.

Parameters:
vectorA - the first vector in the sum.
vectorB - the second vector in the sum.
output - the output vector to fill. If null, an output vector is created.
Returns:
the output sum vector.

subtract

public static double[] subtract(double[] vectorA,
                                double[] vectorB,
                                double[] output)
Computes the difference of two vectors, a - b.

Parameters:
vectorA - the first vector in the difference.
vectorB - the second vector in the difference.
output - the output vector to fill. If null, an output vector is created.
Returns:
the output difference vector.

multiply

public static double[] multiply(double[][] matrix,
                                double[] vector,
                                double[] output)
Applies a matrix transform to a vector.

Parameters:
matrix - the matrix to apply.
vector - the vector to transform.
output - the output vector to fill. If null, an output vector is created.
Returns:
the output transformed vector.

dot

public static double dot(double[] vectorA,
                         double[] vectorB)
Computes the dot product of two vectors, a (dot) b.

Parameters:
vectorA - the first vector in the product.
vectorB - the second vector in the product.
Returns:
the output dot product.

rotationMatrix

public static double[][] rotationMatrix(int axis,
                                        double theta,
                                        double[][] output)
Computes a rotation matrix.

Parameters:
axis - the axis about which the matrix should rotate: X, Y, or Z.
theta - the angle to rotate in radians. A positive angle will rotate coordinates in a counter-clockwise direction (right hand rule, thumb pointing along the positive axis).
output - the output matrix to fill. If null, an output matrix is created.
Returns:
the output rotation matrix.

multiply

public static double[][] multiply(double[][] matrixA,
                                  double[][] matrixB,
                                  double[][] output)
Computes the product of two matrices, AB.

Parameters:
matrixA - the first matrix in the product.
matrixB - the second matrix in the product.
output - the output matrix to fill. If null, an output matrix is created.
Returns:
the output product matrix.

toString

public static java.lang.String toString(double[] vector)
Converts a vector to a string.


Terrenus HRPT v2.2