org.ode4j.math
Class DMatrix3

java.lang.Object
  extended by org.ode4j.math.DMatrix3
All Implemented Interfaces:
DMatrix3C

public final class DMatrix3
extends java.lang.Object
implements DMatrix3C

3x3 matrix class. Internally this uses a 4x3 matrix for compatibility.

Author:
Tilmann Zaeschke

Nested Class Summary
 class DMatrix3.DVector3ColView
           
 class DMatrix3.DVector3RowTView
           
 
Field Summary
static int LEN
           
static int MAX_I
           
static int MAX_J
           
static DMatrix3C ZERO
           
 
Constructor Summary
DMatrix3()
           
DMatrix3(DMatrix3C matrix3)
           
DMatrix3(double d, double e, double f, double g, double h, double i, double j, double k, double l)
          Create new Matrix of the form:
DMatrix3(double d, double e, double f, double g, double h, double i, double j, double k, double l, double m, double n, double o)
          Deprecated.  
 
Method Summary
 DMatrix3 add(DMatrix3C m)
           
 void add(int i, int j, double d)
           
 DMatrix3 clone()
          Returns a clone of this Matrix.
 DVector3 columnAsNewVector(int c)
          Return a new dVector containing the specified column.
 int dimI()
           
 int dimJ()
           
 void dMultiply0(DMatrix3C B, DMatrix3C C)
          Matrix multiplication.
 double dotCol(int col, DVector3C v3)
          Calculates the dot product of the the specified column of this matrix with the given vector.
 double dotColCol(int col, DMatrix3C m2, int col2)
          Calculates the dot product of the the specified column col of this matrix with the specified column col2 of the second matrix m2.
 double dotRow(int row, double[] c, int cOfs)
          Calculates the dot product of the the specified row of this matrix with the given array at the given offset.
 double dotRow(int row, DVector3C v3)
          Calculates the dot product of the the specified row of this matrix with the given vector.
 double dotRowCol(int row, DMatrix3C m2, int col2)
          Calculates the dot product of the the specified row row of this matrix with the specified column col2 of the second matrix m2.
 double dotRowRow(int row, DMatrix3C m2, int row2)
          Calculates the dot product of the the specified row row of this matrix with the specified row row2 of the second matrix m2.
 void eqIdentity()
           
 void eqMul(DMatrix3C B, DMatrix3C C)
           
 DMatrix3 eqTranspose()
          Transpose this matrix.
 boolean equals(java.lang.Object o)
          Compares two objects for equality.
 void eqZero()
           
 double get(int i)
           
 double get(int i, int j)
           
 double get00()
           
 double get01()
           
 double get02()
           
 double get10()
           
 double get11()
           
 double get12()
           
 double get20()
           
 double get21()
           
 double get22()
           
 boolean isEqual(DMatrix3C m)
          Compares two matrices for equality.
 DMatrix3 reTranspose()
          Create a new transposed version of this matrix.
 void scale(double scale)
           
 DMatrix3 set(DMatrix3C m)
           
 void set(double i, double j, double k, double l, double m, double n, double o, double p, double q)
           
 void set(int i, int j, double a)
           
 void set00(double d)
           
 void set01(double d)
           
 void set02(double d)
           
 void set10(double d)
           
 void set11(double d)
           
 void set12(double d)
           
 void set12(double[] da, int da_ofs)
          Initialises this matrix from a 3*4 double [] with 12 fields, ignoring the 4th, 8th and 12th field.
 void set20(double d)
           
 void set21(double d)
           
 void set22(double d)
           
 void setCol(int i, DVector3 v3)
           
 DMatrix3 setIdentity()
           
 void setOfs(int ofs, DVector3 v3)
           
 void setZero()
           
 void sub(int i, int j, double d)
           
 float[] toFloatArray()
           
 float[] toFloatArray12()
           
 java.lang.String toString()
           
 DMatrix3.DVector3ColView viewCol(int column)
          View a particular column as dVector3.
 DMatrix3.DVector3RowTView viewRowT(int row)
           
static DMatrix3 wrap(double[] a)
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_I

public static final int MAX_I
See Also:
Constant Field Values

MAX_J

public static final int MAX_J
See Also:
Constant Field Values

LEN

public static final int LEN
See Also:
Constant Field Values

ZERO

public static final DMatrix3C ZERO
Constructor Detail

DMatrix3

public DMatrix3(double d,
                double e,
                double f,
                double g,
                double h,
                double i,
                double j,
                double k,
                double l,
                double m,
                double n,
                double o)
Deprecated. 


DMatrix3

public DMatrix3(double d,
                double e,
                double f,
                double g,
                double h,
                double i,
                double j,
                double k,
                double l)
Create new Matrix of the form:
 d, e, f
 g, h, i
 j, k, l
 

Parameters:
d - 0,0
e - 0,1
f - 0,2
g - 1,0
h - 1,1
i - 1,2
j - 2,0
k - 2,1
l - 2,2

DMatrix3

public DMatrix3(DMatrix3C matrix3)

DMatrix3

public DMatrix3()
Method Detail

wrap

public static DMatrix3 wrap(double[] a)

set

public DMatrix3 set(DMatrix3C m)

clone

public DMatrix3 clone()
Returns a clone of this Matrix.

Specified by:
clone in interface DMatrix3C
Overrides:
clone in class java.lang.Object

toString

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

setOfs

public void setOfs(int ofs,
                   DVector3 v3)

setCol

public void setCol(int i,
                   DVector3 v3)

set

public void set(double i,
                double j,
                double k,
                double l,
                double m,
                double n,
                double o,
                double p,
                double q)

set12

public void set12(double[] da,
                  int da_ofs)
Initialises this matrix from a 3*4 double [] with 12 fields, ignoring the 4th, 8th and 12th field. This is useful when using padded arrays.


get

public double get(int i)

columnAsNewVector

public DVector3 columnAsNewVector(int c)
Return a new dVector containing the specified column. For padding=4 this uses the elements c, 4+c, 8+c;

Specified by:
columnAsNewVector in interface DMatrix3C
Parameters:
c - Column (0, 1, 2)
Returns:
A new dVector.

add

public DMatrix3 add(DMatrix3C m)

scale

public void scale(double scale)

dMultiply0

public void dMultiply0(DMatrix3C B,
                       DMatrix3C C)
Matrix multiplication. all matrices are stored in standard row format. the digit refers to the argument that is transposed: 0: A = B * C (sizes: A:p*r B:p*q C:q*r) 1: A = B' * C (sizes: A:p*r B:q*p C:q*r) 2: A = B * C' (sizes: A:p*r B:p*q C:r*q) case 1,2 are equivalent to saying that the operation is A=B*C but B or C are stored in standard column format.


eqMul

public void eqMul(DMatrix3C B,
                  DMatrix3C C)

viewCol

public DMatrix3.DVector3ColView viewCol(int column)
View a particular column as dVector3. For example:
// dir[0] = R[0*4+2];
// dir[1] = R[1*4+2];
// dir[2] = R[2*4+2];
dir.set(R.getColumnView(2));

Specified by:
viewCol in interface DMatrix3C
Parameters:
column - The column to return [0, 1, 2].

viewRowT

public DMatrix3.DVector3RowTView viewRowT(int row)

get00

public final double get00()
Specified by:
get00 in interface DMatrix3C

get01

public final double get01()
Specified by:
get01 in interface DMatrix3C

get02

public final double get02()
Specified by:
get02 in interface DMatrix3C

get10

public final double get10()
Specified by:
get10 in interface DMatrix3C

get11

public final double get11()
Specified by:
get11 in interface DMatrix3C

get12

public final double get12()
Specified by:
get12 in interface DMatrix3C

get20

public final double get20()
Specified by:
get20 in interface DMatrix3C

get21

public final double get21()
Specified by:
get21 in interface DMatrix3C

get22

public final double get22()
Specified by:
get22 in interface DMatrix3C

set00

public final void set00(double d)

set01

public final void set01(double d)

set02

public final void set02(double d)

set10

public final void set10(double d)

set11

public final void set11(double d)

set12

public final void set12(double d)

set20

public final void set20(double d)

set21

public final void set21(double d)

set22

public final void set22(double d)

dimI

public final int dimI()

dimJ

public final int dimJ()

isEqual

public final boolean isEqual(DMatrix3C m)
Compares two matrices for equality. This is marginally faster than equals(Object o).


equals

public final boolean equals(java.lang.Object o)
Compares two objects for equality. This is marginally slower than isEquals(DMatrix3C m).

Overrides:
equals in class java.lang.Object

eqIdentity

public final void eqIdentity()

setIdentity

public final DMatrix3 setIdentity()

eqZero

public final void eqZero()

setZero

public final void setZero()

toFloatArray12

public final float[] toFloatArray12()
Specified by:
toFloatArray12 in interface DMatrix3C

toFloatArray

public final float[] toFloatArray()
Specified by:
toFloatArray in interface DMatrix3C

eqTranspose

public final DMatrix3 eqTranspose()
Transpose this matrix.

Returns:
This matrix.

reTranspose

public final DMatrix3 reTranspose()
Create a new transposed version of this matrix.

Returns:
The transposed copy of this matrix.

dotCol

public final double dotCol(int col,
                           DVector3C v3)
Calculates the dot product of the the specified column of this matrix with the given vector.

Specified by:
dotCol in interface DMatrix3C
Parameters:
col -
v3 -

dotRow

public final double dotRow(int row,
                           DVector3C v3)
Calculates the dot product of the the specified row of this matrix with the given vector.

Specified by:
dotRow in interface DMatrix3C
Parameters:
row -
v3 -

dotColCol

public final double dotColCol(int col,
                              DMatrix3C m2,
                              int col2)
Calculates the dot product of the the specified column col of this matrix with the specified column col2 of the second matrix m2.

Specified by:
dotColCol in interface DMatrix3C
Parameters:
col -
m2 -
col2 -

dotRowCol

public double dotRowCol(int row,
                        DMatrix3C m2,
                        int col2)
Calculates the dot product of the the specified row row of this matrix with the specified column col2 of the second matrix m2.

Specified by:
dotRowCol in interface DMatrix3C
Parameters:
row -
m2 -
col2 -

dotRow

public final double dotRow(int row,
                           double[] c,
                           int cOfs)
Calculates the dot product of the the specified row of this matrix with the given array at the given offset.

Specified by:
dotRow in interface DMatrix3C
Parameters:
row - The row.
c - The array.
cOfs - The offset in c.

dotRowRow

public double dotRowRow(int row,
                        DMatrix3C m2,
                        int row2)
Calculates the dot product of the the specified row row of this matrix with the specified row row2 of the second matrix m2.

Specified by:
dotRowRow in interface DMatrix3C
Parameters:
row -
m2 -
row2 -

get

public double get(int i,
                  int j)
Specified by:
get in interface DMatrix3C
Parameters:
i - row
j - column
Returns:
Value at (i,j).

set

public void set(int i,
                int j,
                double a)
Parameters:
i - row
j - column
a - value at (i,j)

add

public void add(int i,
                int j,
                double d)

sub

public void sub(int i,
                int j,
                double d)