Class Matrix4
java.lang.Object
graphic.Matrix4
Column-major 4x4 matrix, used for 3D computations (homogeneous coordinates).
- Author:
- Andrea Zoppi
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a matrix to this one.voidAdds a matrix to itself.clone()static Matrix4createDiagonal(float allValues) static Matrix4createDiagonal(float d00, float d11, float d22, float d33) static Matrix4static Matrix4createRotationX(float rad) static Matrix4createRotationXYZ(float rx, float ry, float rz) static Matrix4createRotationY(float rad) static Matrix4createRotationZ(float rad) static Matrix4createRotationZXY(float rx, float ry, float rz) static Matrix4createScale(float xyzScale) static Matrix4createScale(float sx, float sy, float sz) static Matrix4createTranslation(float dx, float dy, float dz) static Matrix4createTranslationOnly(float dx, float dy, float dz) floatdet()Computes the determinant of the matrix.div(float scalar) voiddivSelf(float scalar) floatget(int r, int c) Gets a matrix value.getColumn(int c) Gets a single column vector.getRow(int r) Gets a single row vector.inv()Computes an inverted copy of the matrix.voidinvSelf()Self-inverts the matrix.mult(float scalar) Multiplied copy of the matrix by a scalar value.Multiplies the matrix by another matrix.Multiplies the matrix by a vector.voidmultSelf(float scalar) Multiplies itself by a scalar value.voidMultiplied itself by another matrix.voidset(float allValues) Sets all matrix values to the given value.voidset(float[] a) Sets all values from a given matrix in column-major vector array form.voidset(int r, int c, float value) Sets a matrix value.voidCopies all values from an existing matrix.voidSets a single column vector.voidSets the matrix to an identity matrix.voidSets a single row vector.Subtracts a mtrix to this one.voidSubtracts a matrix to itself.float[]toArray()toString()tr()Transposed version of the matrix.trans(float dx, float dy, float dz) voidtransSelf(float dx, float dy, float dz) voidvoidtrSelf()Self-transposes the matrix.
-
Field Details
-
m
protected float[] m -
IDENTITY
-
X_INDEX
public static final int X_INDEX- See Also:
-
Y_INDEX
public static final int Y_INDEX- See Also:
-
Z_INDEX
public static final int Z_INDEX- See Also:
-
-
Constructor Details
-
Matrix4
public Matrix4() -
Matrix4
public Matrix4(float scalar) Diagonal constructor.- Parameters:
scalar- Scalar value to put on diagonal.
-
Matrix4
-
Matrix4
public Matrix4(float[] a) Array constructor.- Parameters:
a- Array to be converted into a matrix.
-
Matrix4
-
-
Method Details
-
get
public float get(int r, int c) Gets a matrix value.- Parameters:
r- Row number.c- Column number.- Returns:
- Value at (row, column).
-
set
public void set(int r, int c, float value) Sets a matrix value.- Parameters:
r- Row number.c- Column number.value- Value at (row, column).
-
set
public void set(float allValues) Sets all matrix values to the given value.- Parameters:
allValues- Value to put in all cells.
-
set
Copies all values from an existing matrix.- Parameters:
m- Matrix to be copied.
-
set
public void set(float[] a) Sets all values from a given matrix in column-major vector array form.- Parameters:
a- Array to be converted into a matrix.
-
getRow
Gets a single row vector.- Parameters:
r- Row number.- Returns:
- The copied row vector.
-
getColumn
Gets a single column vector.- Parameters:
c- Column number.- Returns:
- The copied column vector.
-
setRow
Sets a single row vector.- Parameters:
r- Row number.v- Vector to be copied onto the row.
-
setColumn
Sets a single column vector.- Parameters:
c- Column number.v- Vector to be copied onto the column.
-
setIdentity
public void setIdentity()Sets the matrix to an identity matrix. -
tr
-
trSelf
public void trSelf()Self-transposes the matrix. -
det
public float det()Computes the determinant of the matrix.- Returns:
- The matrix determinant.
-
inv
Computes an inverted copy of the matrix.- Returns:
- The inverted copy of the matrix.
-
invSelf
public void invSelf()Self-inverts the matrix. -
add
-
addSelf
-
sub
-
subSelf
Subtracts a matrix to itself.- Parameters:
m- Matrix to be subtracted.
-
mult
Multiplied copy of the matrix by a scalar value.- Parameters:
scalar- Scalar value to be multiplied.- Returns:
- The multiplied matrix.
-
mult
-
mult
-
multSelf
public void multSelf(float scalar) Multiplies itself by a scalar value.- Parameters:
scalar- Scalar value to multiply by.
-
multSelf
Multiplied itself by another matrix.- Parameters:
m- Matrix to be multiplied by.
-
div
-
divSelf
public void divSelf(float scalar) -
trans
-
trans
-
transSelf
public void transSelf(float dx, float dy, float dz) -
transSelf
-
toArray
public float[] toArray() -
clone
-
toString
-
createIdentity
-
createTranslation
-
createTranslationOnly
-
createRotationXYZ
-
createRotationZXY
-
createRotationX
-
createRotationY
-
createRotationZ
-
createDiagonal
-
createDiagonal
-
createScale
-
createScale
-