public class Matrix
extends java.lang.Object
implements java.io.Serializable
| Constructor and Description |
|---|
Matrix()
Creates a new matrix and sets it to the identity matrix.
|
Matrix(Matrix m)
Creates a matrix from a given one.
|
| Modifier and Type | Method and Description |
|---|---|
Matrix |
cloneMatrix()
Creates a copy of this matrix.
|
boolean |
equals(java.lang.Object obj) |
float[] |
fillDump(float[] dump)
Dumps a matrix row-wise into a given float[16]-array and returns it.
|
float |
get(int row,
int col)
Returns the value at a position in the matrix.
|
float[] |
getDump()
Dumps a matrix row-wise into a float[16]-array.
|
SimpleVector |
getTranslation()
Returns the translation this matrix would represent when viewed as a
translation matrix.
|
SimpleVector |
getTranslation(SimpleVector toFill)
Returns the translation this matrix would represent when viewed as a
translation matrix.
|
SimpleVector |
getXAxis()
Returns the x-axis this matrix would represent when viewed as a rotation
matrix.
|
SimpleVector |
getXAxis(SimpleVector toFill)
Returns the x-axis this matrix would represent when viewed as a rotation
matrix.
|
SimpleVector |
getYAxis()
Returns the y-axis this matrix would represent when viewed as a rotation
matrix.
|
SimpleVector |
getYAxis(SimpleVector toFill)
Returns the y-axis this matrix would represent when viewed as a rotation
matrix.
|
SimpleVector |
getZAxis()
Returns the z-axis this matrix would represent when viewed as a rotation
matrix.
|
SimpleVector |
getZAxis(SimpleVector toFill)
Returns the z-axis this matrix would represent when viewed as a rotation
matrix.
|
int |
hashCode() |
void |
interpolate(Matrix source,
Matrix dest,
float weight)
Fills the matrix with data interpolated between the source and the
destination matrix.
|
Matrix |
invert()
Calculates the inverse of this matrix.
|
Matrix |
invert(Matrix dst)
Calculates the inverse of this matrix and fills the result into the given
matrix (which will be returned in addition).
|
Matrix |
invert3x3()
Calculates the inverse of this matrix as if this matrix would be a 3x3
one (instead of the 4x4 it actually is).
|
Matrix |
invert3x3(Matrix toFill)
Calculates the inverse of this matrix as if this matrix would be a 3x3
one (instead of the 4x4 it actually is).
|
boolean |
isIdentity()
Returns true, if this matrix is the identity matrix.
|
void |
matMul(Matrix maty)
Multiplies this matrix with another one.
|
void |
orthonormalize()
Orthonormalizes a matrix using the Gramm-Schmidt orthonormalization
algorithm.
|
void |
rotateAxis(SimpleVector axis,
float angle)
Rotates the matrix around an arbitrary axis.
|
void |
rotateX(float w)
Rotates the matrix around the X-axis (counter clockwise for positive w).
|
void |
rotateY(float w)
Rotates the matrix around the Y-axis (clockwise for positive w).
|
void |
rotateZ(float w)
Rotates the matrix around the Z-axis (counter clockwise for positive w).
|
void |
scalarMul(float scalar)
Multiplies this matrix with a scalar (the left upper 3x3 part only).
|
void |
set(int row,
int col,
float value)
Injects a value directly into the matrix at a position.
|
void |
setColumn(int col,
float v1,
float v2,
float v3,
float v4)
Inject values directly into a matrix' column.
|
void |
setDump(float[] dump)
Reimports a dumped matrix (or every data from a float[16]-array) into a
Matrix.
|
void |
setIdentity()
(Re-)sets this matrix to the identity matrix.
|
void |
setOrientation(SimpleVector dir,
SimpleVector up)
Sets the orientation of a rotation matrix by giving a direction and an
up-vector.
|
void |
setRow(int row,
float v1,
float v2,
float v3,
float v4)
Inject values directly into a matrix' row.
|
void |
setTo(Matrix source)
Sets this matrix' values to the ones of the source matrix.
|
java.lang.String |
toString() |
void |
transformToGL()
Transforms a matrix from jPCT's coordinate system into OpenGL's (and vice
versa)
|
void |
translate(float x,
float y,
float z)
Applies a translation to this matrix.
|
void |
translate(SimpleVector trans)
Applies a translation to this matrix.
|
Matrix |
transpose()
Calculates the transposed matrix of this matrix.
|
public Matrix()
public Matrix(Matrix m)
m - the source matrixpublic final boolean isIdentity()
public final void setIdentity()
public final void setOrientation(SimpleVector dir, SimpleVector up)
dir - the directionup - the up-vectorpublic final void scalarMul(float scalar)
scalar - the scalar to multiply withpublic final void matMul(Matrix maty)
maty - the matrix to multiply withpublic final void rotateX(float w)
w - the rotation angle in radianspublic final void rotateY(float w)
w - the rotation angle in radianspublic final void rotateZ(float w)
w - the rotation angle in radianspublic final void rotateAxis(SimpleVector axis, float angle)
axis - a direction-vector pointing into the axis directionangle - the angle of the rotation in radianspublic final void interpolate(Matrix source, Matrix dest, float weight)
source - the source matrixdest - the destination matrixweight - the weight of the destination matrix (0-1)public final SimpleVector getTranslation()
public final SimpleVector getTranslation(SimpleVector toFill)
toFill - the SimpleVector to fill with the result. This will also be
returned.public final SimpleVector getXAxis()
public final SimpleVector getYAxis()
public final SimpleVector getZAxis()
public final SimpleVector getXAxis(SimpleVector toFill)
toFill - the vector to fillpublic final SimpleVector getYAxis(SimpleVector toFill)
toFill - the vector to fillpublic final SimpleVector getZAxis(SimpleVector toFill)
toFill - the vector to fillpublic final float get(int row,
int col)
row - the rowcol - the columnpublic final void translate(SimpleVector trans)
trans - the translationpublic final void translate(float x,
float y,
float z)
x - the x component of the translationy - the y component of the translationz - the z component of the translationpublic final Matrix cloneMatrix()
public final Matrix invert()
public final Matrix invert(Matrix dst)
dst - the matrix to fill with the result.public final Matrix invert3x3()
invert()public final Matrix invert3x3(Matrix toFill)
toFill - the matrix to fill. Can't be the same instance as the matrix
to invert.invert()public final void orthonormalize()
public final float[] getDump()
public final float[] fillDump(float[] dump)
public final void setDump(float[] dump)
dump - the "dump"public final void setTo(Matrix source)
source - the source matrixpublic final void set(int row,
int col,
float value)
row - the rowcol - the columnvalue - the value to setpublic final void setRow(int row,
float v1,
float v2,
float v3,
float v4)
row - thw rowv1 - the first valuev2 - the second valuev3 - the third valuev4 - the fourth valuepublic final void setColumn(int col,
float v1,
float v2,
float v3,
float v4)
col - thw columnv1 - the first valuev2 - the second valuev3 - the third valuev4 - the fourth valuepublic java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic final Matrix transpose()
public void transformToGL()