public class Matrix extends Object implements Serializable
This class is not supposed to be a replacement for a full-fledged mathematical package. It provides a convenient wrapper for double arrays that offers some basic functionality for multiplying and inverting matrices and such, but if you want to do more involved stuff, you probably want to use a dedicated math library.
Rn
,
P3
,
Pn
,
Serialized FormModifier and Type | Field and Description |
---|---|
static double |
TOLERANCE |
Constructor and Description |
---|
Matrix() |
Matrix(double[] m)
plain wrapper for the array m; does NOT make a copy of m!
|
Matrix(DoubleArray data)
this constructor copies the content of the given DoubleArray.
|
Matrix(double x00,
double x01,
double x02,
double x03,
double x10,
double x11,
double x12,
double x13,
double x20,
double x21,
double x22,
double x23,
double x30,
double x31,
double x32,
double x33)
TODO
|
Matrix(Matrix T)
copy constructor
|
Matrix(Transformation data)
this constructor copies the content of the given Transformation.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Matrix T)
Let M be the current Matrix.
|
void |
assignFrom(double[] initValue)
copies initValue
|
void |
assignFrom(DoubleArray data)
copies initValue
|
void |
assignFrom(double x00,
double x01,
double x02,
double x03,
double x10,
double x11,
double x12,
double x13,
double x20,
double x21,
double x22,
double x23,
double x30,
double x31,
double x32,
double x33)
TODO: assign single values!
|
void |
assignFrom(Matrix initValue)
copies initValue
|
void |
assignFrom(Transformation trafo)
copies initValue
|
void |
assignIdentity() |
void |
assignTo(double[] array) |
void |
assignTo(Matrix m) |
void |
assignTo(SceneGraphComponent comp)
Set the matrix of the transformation of comp to be this instance.
|
void |
assignTo(Transformation trafo) |
static Matrix |
conjugate(Matrix A,
Matrix B) |
void |
conjugateBy(Matrix T)
Let M be the current Matrix.
|
boolean |
containsNanOrInfinite() |
boolean |
equals(Matrix T) |
double[] |
getArray() |
double[] |
getColumn(int i) |
double |
getDeterminant() |
double |
getEntry(int row,
int column) |
Matrix |
getInverse() |
double[] |
getRow(int i) |
double |
getTrace() |
Matrix |
getTranspose() |
void |
invert() |
void |
multiplyOnLeft(double[] T)
Let M be the current matrix.
|
void |
multiplyOnLeft(Matrix T)
Let M be the current matrix.
|
void |
multiplyOnRight(double[] T)
Let M be the current matrix.
|
void |
multiplyOnRight(Matrix T)
Let M be the current matrix.
|
double[] |
multiplyVector(double[] v)
Form the matrix-vector product M.v (v is column vector on the right).
|
static Matrix |
power(Matrix m,
int n) |
void |
setColumn(int i,
double[] v)
assigns the values of the ith column with the values from v.
|
void |
setEntry(int row,
int column,
double value) |
void |
setRow(int i,
double[] v) |
void |
subtract(Matrix T)
Let M be the current Matrix.
|
static Matrix |
sum(Matrix A,
Matrix B) |
void |
times(double f)
Let M be the current Matrix.
|
static Matrix |
times(Matrix A,
Matrix B) |
String |
toString() |
void |
transformVector(double[] v)
Form the matrix-vector product M.v (v is column vector on the right) and assign it to v.
|
void |
transpose() |
double[] |
writeToArray(double[] aMatrix)
Copy the current matrix into aMatrix and return it.
|
public static final double TOLERANCE
public Matrix()
public Matrix(Matrix T)
T
- public Matrix(double[] m)
m
- the double array to be wrapped by this Matrixpublic Matrix(double x00, double x01, double x02, double x03, double x10, double x11, double x12, double x13, double x20, double x21, double x22, double x23, double x30, double x31, double x32, double x33)
public Matrix(DoubleArray data)
the
- DoubleArray to copy and wrappublic Matrix(Transformation data)
the
- Transformation to copy and wrappublic static Matrix conjugate(Matrix A, Matrix B)
A
- B
- public void assignFrom(double[] initValue)
initValue
- public void assignFrom(Matrix initValue)
initValue
- public void assignFrom(DoubleArray data)
initValue
- public void assignFrom(Transformation trafo)
initValue
- public void assignFrom(double x00, double x01, double x02, double x03, double x10, double x11, double x12, double x13, double x20, double x21, double x22, double x23, double x30, double x31, double x32, double x33)
public void assignTo(double[] array)
public void assignTo(Matrix m)
public void assignTo(Transformation trafo)
public void assignTo(SceneGraphComponent comp)
comp
- public void assignIdentity()
public double getDeterminant()
public double getTrace()
public double getEntry(int row, int column)
public void setEntry(int row, int column, double value)
public double[] getRow(int i)
public void setRow(int i, double[] v)
public double[] getColumn(int i)
public void setColumn(int i, double[] v)
i
- v
- public double[] getArray()
public double[] writeToArray(double[] aMatrix)
aMatrix
- public void multiplyOnRight(double[] T)
aMatrix
- public void multiplyOnRight(Matrix T)
aMatrix
- public void multiplyOnLeft(double[] T)
aMatrix
- public void multiplyOnLeft(Matrix T)
aMatrix
- public void conjugateBy(Matrix T)
T
- public void add(Matrix T)
T
- the matrix to addpublic void subtract(Matrix T)
T
- the matrix to subtractpublic void times(double f)
f
- the scalar to multiply M withpublic Matrix getInverse()
public void invert()
public Matrix getTranspose()
public void transpose()
public double[] multiplyVector(double[] v)
v
- the vector vpublic void transformVector(double[] v)
vector
- the vector to transformpublic boolean equals(Matrix T)
public boolean containsNanOrInfinite()