JNISpice
version 2.0.0

spice.basic
Class Matrix33

java.lang.Object
  extended by spice.basic.Matrix33

public class Matrix33
extends java.lang.Object

Class Matrix33 represents 3 by 3 double precision matrices.

Version 1.0.0 22-DEC-2009 (NJB)


Constructor Summary
Matrix33()
          No-arguments constructor: create a zero-filled 3x3 matrix.
Matrix33(double[] array)
          Construct a Matrix33 from an array of type double[].
Matrix33(double[][] array3x3)
          Construct a Matrix33 from an array of type double[][].
Matrix33(int axisIndex, double angle)
          Construct a rotation matrix that transforms vectors from the standard basis to a basis rotated about a specified coordinate axis by a specified angle.
Matrix33(Matrix33 matrix)
          Construct a Matrix33 from another Matrix33.
Matrix33(Vector3 axis, double angle)
          Construct a rotation matrix that rotates vectors about a specified axis vector by a specified angle.
Matrix33(Vector3 primaryVector, int primaryIndex, Vector3 secondaryVector, int secondaryIndex)
          Construct a rotation matrix representing a reference frame defined by primary and secondary vectors.
Matrix33(Vector3 row0, Vector3 row1, Vector3 row2)
          Construct a Matrix33 from a set of three row vectors.
 
Method Summary
 Matrix33 add(Matrix33 m2)
          Add this instance to another Matrix33 instance.
 double det()
          Return the determinant of this instance.
 double dist(Matrix33 m2)
          Return the vector (L2) distance between this instance and another Matrix33 instance.
static Matrix33 fill(double value)
          Fill all elements of a matrix with a given constant.
 double getElt(int i, int j)
          Return the element of this instance at index [i][j].
static Matrix33 identity()
          Return the identity matrix.
 Matrix33 invert()
          Invert this instance.
 boolean isRotation(double normTol, double determinantTol)
          Indicate whether this instance is a rotation matrix.
 Matrix33 mtxm(Matrix33 m2)
          Multiply a Matrix33 instance on the left by the transpose of this instance.
 Vector3 mtxv(Vector3 vin)
          Multiply a vector on the left by the transpose of this instance.
 Matrix33 mxm(Matrix33 m2)
          Multiply another Matrix33 instance on the left by this instance.
 Matrix33 mxmt(Matrix33 m2)
          Multiply the transpose of a Matrix33 instance on the left by this instance.
 Vector3 mxv(Vector3 vin)
          Multiply a Vector3 on the left by this instance.
 double norm()
          Compute the vector (L2) norm of this instance.
 Matrix33 scale(double s)
          Multiply this instance by a scalar.
 Matrix33 sub(Matrix33 m2)
          Subtract another Matrix33 instance from this instance.
 double[][] toArray()
          Return a 3x3 array containing the contents of this Matrix33 instance.
 double[] toArray1D()
          Return a 1-dimensional array containing the contents of this Matrix33 instance.
 java.lang.String toString()
          Convert this instance to a String.
 Matrix33 xpose()
          Transpose this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix33

public Matrix33()
No-arguments constructor: create a zero-filled 3x3 matrix.


Matrix33

public Matrix33(Matrix33 matrix)
Construct a Matrix33 from another Matrix33. This method creates a deep copy.


Matrix33

public Matrix33(double[][] array3x3)
         throws SpiceException
Construct a Matrix33 from an array of type double[][].

Throws:
SpiceException

Matrix33

public Matrix33(double[] array)
         throws SpiceException
Construct a Matrix33 from an array of type double[].

The array is considered to consist of rows 0-2 of the matrix, in that order.

Throws:
SpiceException

Matrix33

public Matrix33(Vector3 row0,
                Vector3 row1,
                Vector3 row2)
Construct a Matrix33 from a set of three row vectors. Each row is represented by a Vector3.


Matrix33

public Matrix33(Vector3 primaryVector,
                int primaryIndex,
                Vector3 secondaryVector,
                int secondaryIndex)
         throws SpiceException
Construct a rotation matrix representing a reference frame defined by primary and secondary vectors. A specified axis of the frame is aligned with the primary vector; another specified axis is aligned with the component of the secondary vector that is orthogonal to the primary vector.

This constructor is analogous to the twovec_c function of CSPICE.

The association of axes and axis numbers is as follows:

      axis     index
      ----     -----
       X         1
       Y         2
       Z         3
   

The matrix created by this constructor transforms vectors from the standard basis to that defined by the input vectors.

Example

The numerical results shown for this example may differ across platforms. The results depend on the compiler and supporting libraries, and the machine specific arithmetic implementation.

Create a matrix that transforms vectors from the standard basis to one whose X-axis is aligned with the vector (1,1,1) and whose Z-axis is aligned with the component of (0,0,1) that is orthogonal to its X-axis.

      import spice.basic.*;

      class Twovec
      {
         //
         // Load the JNISpice shared library.
         //
         static { System.loadLibrary( "JNISpice" ); }


         public static void main ( String[] args )
         {
            try
            {
               Vector3  primary   = new Vector3( 1, 1, 1 );
               Vector3  secondary = new Vector3( 0, 0, 1 );

               Matrix33 r         = new Matrix33( primary, 1, secondary, 3 );

               System.out.println ( r );

            }
            catch ( SpiceException exc ) {
               exc.printStackTrace();
            }
         }
      }
   

When run on a PC/Linux/java 1.6.0_14/gcc platform, the output from this program was (lines below were wrapped to fit into the 80 character page width):

        5.7735026918962580e-01,   5.7735026918962580e-01,   5.773502691896258
0e-01,
       -7.0710678118654750e-01,   7.0710678118654750e-01,   0.000000000000000
0e+00,
       -4.0824829046386310e-01,  -4.0824829046386310e-01,   8.164965809277261
0e-01
   

Throws:
SpiceException

Matrix33

public Matrix33(int axisIndex,
                double angle)
         throws SpiceException
Construct a rotation matrix that transforms vectors from the standard basis to a basis rotated about a specified coordinate axis by a specified angle.

This constructor is analogous to the rotate_c function of CSPICE.

The association of axes and axis numbers is as follows:

      axis     index
      ----     -----
       X         1
       Y         2
       Z         3
   

The angle is expressed in radians.

Throws:
SpiceException

Matrix33

public Matrix33(Vector3 axis,
                double angle)
         throws SpiceException
Construct a rotation matrix that rotates vectors about a specified axis vector by a specified angle.

This constructor is analogous to the axisar_c function of CSPICE.

The angle is expressed in radians.

Throws:
SpiceException
Method Detail

add

public Matrix33 add(Matrix33 m2)
Add this instance to another Matrix33 instance.


det

public double det()
           throws SpiceException
Return the determinant of this instance.

Throws:
SpiceException

dist

public double dist(Matrix33 m2)
Return the vector (L2) distance between this instance and another Matrix33 instance.


fill

public static Matrix33 fill(double value)
Fill all elements of a matrix with a given constant.


getElt

public double getElt(int i,
                     int j)
              throws SpiceException
Return the element of this instance at index [i][j].

Throws:
SpiceException

identity

public static Matrix33 identity()
Return the identity matrix.


invert

public Matrix33 invert()
                throws SpiceException
Invert this instance.

Throws:
SpiceException

isRotation

public boolean isRotation(double normTol,
                          double determinantTol)
                   throws SpiceException
Indicate whether this instance is a rotation matrix.

The input tolerance values are used, respectively, as the maximum deviation of the magnitude of the matrix's columns from 1 and of the matrix's determinant from 1.

Throws:
SpiceException

mxm

public Matrix33 mxm(Matrix33 m2)
Multiply another Matrix33 instance on the left by this instance.


mtxm

public Matrix33 mtxm(Matrix33 m2)
Multiply a Matrix33 instance on the left by the transpose of this instance.


mtxv

public Vector3 mtxv(Vector3 vin)
Multiply a vector on the left by the transpose of this instance.


mxmt

public Matrix33 mxmt(Matrix33 m2)
Multiply the transpose of a Matrix33 instance on the left by this instance.


mxv

public Vector3 mxv(Vector3 vin)
Multiply a Vector3 on the left by this instance.


norm

public double norm()
Compute the vector (L2) norm of this instance.


sub

public Matrix33 sub(Matrix33 m2)
Subtract another Matrix33 instance from this instance.


scale

public Matrix33 scale(double s)
Multiply this instance by a scalar.


toArray

public double[][] toArray()
Return a 3x3 array containing the contents of this Matrix33 instance.


toArray1D

public double[] toArray1D()
Return a 1-dimensional array containing the contents of this Matrix33 instance.


toString

public java.lang.String toString()
Convert this instance to a String. This method overrides Object's toString() method.

Overrides:
toString in class java.lang.Object

xpose

public Matrix33 xpose()
Transpose this instance.


JNISpice
version 2.0.0

JNISpice Alpha Test Version 2.0.0 28-JAN-2017 (NJB)