Package toxi.geom
Class Matrix4x4
java.lang.Object
toxi.geom.Matrix4x4
Implements a simple row-major 4x4 matrix class, all matrix operations are
applied to new instances. Use
transpose()
to convert from
column-major formats...-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreates a copy of the given vector, transformed by this matrix.applyToSelf
(Vec3D v) copy()
getRotatedAroundAxis
(ReadonlyVec3D axis, double theta) getRotatedX
(double theta) getRotatedY
(double theta) getRotatedZ
(double theta) identity()
invert()
Matrix Inversion using Cramer's Method Computes Adjoint matrix divided by determinant Code modified from http://www.intel.com/design/pentiumiii/sml/24504301.pdflookAt
(ReadonlyVec3D eye, ReadonlyVec3D target, ReadonlyVec3D up) multiply
(double factor) Matrix-Matrix Right-multiplication.multiplySelf
(double factor) In-place matrix-scalar multiplication.multiplySelf
(Matrix4x4 mat) rotateAroundAxis
(ReadonlyVec3D axis, double theta) Applies rotation about arbitrary axis to matrixrotateX
(double theta) Applies rotation about X to this matrix.rotateY
(double theta) Applies rotation about Y to this matrix.rotateZ
(double theta) scale
(double scale) scale
(double scaleX, double scaleY, double scaleZ) scale
(ReadonlyVec3D scale) scaleSelf
(double scale) scaleSelf
(double scaleX, double scaleY, double scaleZ) scaleSelf
(ReadonlyVec3D scale) set
(double a, double b, double c, double d, double e, double f, double g, double h, double i, double j, double k, double l, double m, double n, double o, double p) setFrustum
(double left, double right, double top, double bottom, double near, double far) setOrtho
(double left, double right, double top, double bottom, double near, double far) setPerspective
(double fov, double aspect, double near, double far) setPosition
(double x, double y, double z) setScale
(double scaleX, double scaleY, double scaleZ) double[]
toArray
(double[] result) Copies all matrix elements into an linear array.float[]
toFloatArray
(float[] result) toString()
float[]
toTransposedFloatArray
(float[] result) translate
(double dx, double dy, double dz) translate
(ReadonlyVec3D trans) translateSelf
(double dx, double dy, double dz) translateSelf
(ReadonlyVec3D trans) Converts the matrix (in-place) between column-major to row-major order (and vice versa).
-
Field Details
-
matrix
public double[][] matrix
-
-
Constructor Details
-
Matrix4x4
public Matrix4x4() -
Matrix4x4
public Matrix4x4(double v11, double v12, double v13, double v14, double v21, double v22, double v23, double v24, double v31, double v32, double v33, double v34, double v41, double v42, double v43, double v44) -
Matrix4x4
public Matrix4x4(double[] array) Initialising constructor from a 1d array. Assumes row-major ordering (column index increases faster).- Parameters:
array
-
-
Matrix4x4
-
-
Method Details
-
add
-
addSelf
-
applyTo
Creates a copy of the given vector, transformed by this matrix.- Parameters:
v
-- Returns:
- transformed vector
-
applyToSelf
-
copy
-
getInverted
-
getRotatedAroundAxis
-
getRotatedX
-
getRotatedY
-
getRotatedZ
-
getTransposed
-
identity
-
invert
Matrix Inversion using Cramer's Method Computes Adjoint matrix divided by determinant Code modified from http://www.intel.com/design/pentiumiii/sml/24504301.pdf- Returns:
- itself
-
lookAt
-
multiply
-
multiply
Matrix-Matrix Right-multiplication.- Parameters:
mat
-- Returns:
- product as new matrix
-
multiplySelf
In-place matrix-scalar multiplication.- Parameters:
factor
-- Returns:
- product applied to this matrix.
-
multiplySelf
-
rotateAroundAxis
Applies rotation about arbitrary axis to matrix- Parameters:
axis
-theta
-- Returns:
- rotation applied to this matrix
-
rotateX
Applies rotation about X to this matrix.- Parameters:
theta
- rotation angle in radians- Returns:
- itself
-
rotateY
Applies rotation about Y to this matrix.- Parameters:
theta
- rotation angle in radians- Returns:
- itself
-
rotateZ
-
scale
-
scale
-
scale
-
scaleSelf
-
scaleSelf
-
scaleSelf
-
set
public Matrix4x4 set(double a, double b, double c, double d, double e, double f, double g, double h, double i, double j, double k, double l, double m, double n, double o, double p) -
set
-
setFrustum
public Matrix4x4 setFrustum(double left, double right, double top, double bottom, double near, double far) -
setOrtho
public Matrix4x4 setOrtho(double left, double right, double top, double bottom, double near, double far) -
setPerspective
-
setPosition
-
setScale
-
sub
-
subSelf
-
toArray
public double[] toArray(double[] result) Copies all matrix elements into an linear array.- Parameters:
result
- array (or null to create a new one)- Returns:
- matrix as 16 element array
-
toFloatArray
public float[] toFloatArray(float[] result) -
toString
-
toTransposedFloatArray
public float[] toTransposedFloatArray(float[] result) -
translate
-
translate
-
translateSelf
-
translateSelf
-
transpose
Converts the matrix (in-place) between column-major to row-major order (and vice versa).- Returns:
- itself
-