Implementation assumes linear matrix layout in column-major order matching OpenGL's implementation, illustration:
Row-Major Column-Major (OpenGL):
| 0 1 2 3 | | 0 4 8 12 |
| | | |
| 4 5 6 7 | | 1 5 9 13 |
M = | | M = | |
| 8 9 10 11 | | 2 6 10 14 |
| | | |
| 12 13 14 15 | | 3 7 11 15 |
C R C R
m[0*4+3] = tx; m[0+4*3] = tx;
m[1*4+3] = ty; m[1+4*3] = ty;
m[2*4+3] = tz; m[2+4*3] = tz;
Implementation utilizes unrolling of small vertices and matrices wherever possible while trying to access memory in a linear fashion for performance reasons, see:
| Modifier and Type | Field and Description |
|---|---|
| public static final boolean | |
| private static final boolean | |
| public static final float | |
| public static final float | EPSILON
Epsilon for floating point , as once computed via |
| public static final float | HALF_PI
The value PI/2, i.e. 90 degrees in radians. |
| public static final float | INV_DEVIANCE
Inversion Epsilon, used with equals method to determine if two inverted matrices are close enough to be considered equal. |
| private static float | |
| private static volatile boolean | |
| public static final float | PI
The value PI, i.e. 180 degrees in radians. |
| public static final float | QUARTER_PI
The value PI/4, i.e. 45 degrees in radians. |
| public static final float | SQUARED_PI
The value PI^2. |
| public static final float | TWO_PI
The value 2PI, i.e. 360 degrees in radians. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static float | |
| public static float | |
| public static float | |
| public static float | |
| public static float | |
| private static void | |
| public static int | |
| public static int | compare(final float a, final float b, final float epsilon)
Return true if both values are equal, i.e. their absolute delta < |
| public static float[] | Returns: given result vector v_out for chaininginput column-major matrix m_in, final int offset to input matrix m_in_off, final int named column to copy column, final float[] the column-vector storage, at least 3 components long v_out, final int offset to storage v_out_off)Copy the named column of the given column-major matrix to v_out. |
| public static float[] | Returns: given result vector v_out for chaininginput column-major matrix m_in, final int offset to input matrix m_in_off, final int named row to copy row, final float[] the row-vector storage, at least 3 components long v_out, final int offset to storage v_out_off)Copy the named row of the given column-major matrix to v_out. |
| public static float | |
| public static float | |
| public static float | getOrthoWinZ(final float orthoZ, final float zNear, final float zFar)
Returns orthogonal distance (1f/zNear-1f/orthoDist)/(1f/zNear-1f/zFar); |
| public static float | Returns: smallest resolvable Z separation at this range.number of bits of Z precision, i.e. z-buffer depth zBits, final float distance from the eye to the object z, final float distance from eye to near clip plane zNear)Returns resolution of Z buffer of given parameter, see Love Your Z-Buffer. |
| public static int | Returns: z buffer valuenumber of bits of Z precision, i.e. z-buffer depth zBits, final float distance from the eye to the object z, final float distance from eye to near clip plane zNear, final float distance from eye to far clip plane zFar)Returns Z buffer value of given parameter, see Love Your Z-Buffer. |
| public static float[] | Returns: given result matrix mres for chaining if successful, otherwisenull. See above.4x4 matrix in column-major order, the source msrc, final int offset in given array msrc, i.e. start of the 4x4 matrix msrc_offset, final float[] 4x4 matrix in column-major order, the result - may be mres, final int msrc (in-place)offset in given array mres, i.e. start of the 4x4 matrix - may be mres_offset)msrc_offset (in-place)Invert the given matrix. |
| public static float[] | Returns: given result matrix mres for chaining if successful, otherwisenull. See above.4x4 matrix in column-major order, the source msrc, final float[] 4x4 matrix in column-major order, the result - may be mres)msrc (in-place)Invert the given matrix. |
| public static boolean | |
| public static boolean | isEqual(final float a, final float b, final float epsilon)
Return true if both values are equal, i.e. their absolute delta < |
| public static boolean | isZero(final float a, final float epsilon)
Return true if value is zero, i.e. it's absolute value < |
| public static float[] | Returns: given matrix for chaining4x4 matrix in column-major order (also result) m, final int offset in given array m, i.e. start of the 4x4 matrix m_offset, final boolean if true, given matrix will be initialized w/ identity matrix,
otherwise only the frustum fields are set. initM, final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)Make given matrix the frustum matrix based on given parameters. |
| public static float[] | Returns: given matrix for chaining4x4 matrix in column-major order (also result) m, final int offset in given array m, i.e. start of the 4x4 matrix m_offset)Make matrix an identity matrix |
| public static float[] | Returns: given matrix for chaining4x4 matrix in column-major order (also result) m)Make matrix an identity matrix |
| public static float[] | Returns: given matrixm for chaining4x4 matrix in column-major order, result only m, final int offset in given array m, i.e. start of the 4x4 matrix m_offset, final float[] 3 component eye vector eye, final int eye_offset, final float[] 3 component center vector center, final int center_offset, final float[] 3 component up vector up, final int up_offset, final float[] temp float[16] storage mat4Tmp)Make given matrix the look-at matrix based on given parameters. |
| public static float[] | Returns: given matrix for chaining4x4 matrix in column-major order (also result) m, final int offset in given array m, i.e. start of the 4x4 matrix m_offset, final boolean if true, given matrix will be initialized w/ identity matrix,
otherwise only the orthogonal fields are set. initM, final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)Make given matrix the orthogonal matrix based on given parameters. |
| public static float[] | Returns: given matrix for chaining4x4 matrix in column-major order (also result) m, final int offset in given array m, i.e. start of the 4x4 matrix m_off, final boolean if true, given matrix will be initialized w/ identity matrix,
otherwise only the frustum fields are set. initM, final float angle in radians fovy_rad, final float aspect ratio width / height aspect, final float zNear, final float zFar)Make given matrix the perspective |
| public static float[] | Returns: given matrix for chaining4x4 matrix in column-major order (also result) m, final int offset in given array m, i.e. start of the 4x4 matrix m_offset, final boolean if true, given matrix will be initialized w/ identity matrix,
otherwise only the frustum fields are set. initM, final FovHVHalves FovHVHalves field of view in both directions, may not be centered, either in radians or tangentMake given matrix the perspective |
| public static float[] | Returns: given matrixm for chaining or null if either delta value is <= zero.4x4 matrix in column-major order, result only m, final int offset in given array m, i.e. start of the 4x4 matrix m_offset, final float the center x-component of a picking region in window coordinates x, final float the center y-component of a picking region in window coordinates y, final float the width of the picking region in window coordinates. deltaX, final float the height of the picking region in window coordinates. deltaY, final int[] 4 component viewport vector viewport, final int viewport_offset, final float[] temp float[16] storage mat4Tmp)Make given matrix the pick matrix based on given parameters. |
| public static float[] | Returns: given matrix for chaining4x4 matrix in column-major order (also result) m, final int offset in given array m, i.e. start of the 4x4 matrix m_offset, final float angrad, float x, float y, float z, final float[] tmpVec3f)Make a rotation matrix from the given axis and angle in radians. |
| public static float[] | Returns: given matrix for chainingImplementation does not use Quaternion and hence is exposed to Gimbal-Lock 4x4 matrix in column-major order (also result) m, final int offset in given array m, i.e. start of the 4x4 matrix m_offset, final float the Euler pitch angle in radians. (rotation about the X axis) bankX, final float the Euler yaw angle in radians. (rotation about the Y axis) headingY, final float the Euler roll angle in radians. (rotation about the Z axis) attitudeZ)Make a concatenated rotation matrix in column-major order from the given Euler rotation angles in radians. |
| public static float[] | Returns: given matrix for chaining4x4 matrix in column-major order (also result) m, final int offset in given array m, i.e. start of the 4x4 matrix m_offset, final boolean if true, given matrix will be initialized w/ identity matrix,
otherwise only the diagonal and last-row is set.
The latter can be utilized to share a once initM, final float sx, final float sy, final float sz)identity set matrix
for scaling
and translation,
while leaving the other fields untouched for performance reasons.Make a scale matrix in column-major order from the given axis factors
Scale matrix (Any Order):
x 0 0 0
0 y 0 0
0 0 z 0
0 0 0 1
|
| public static float[] | Returns: given matrix for chaining4x4 matrix in column-major order (also result) m, final boolean if true, given matrix will be initialized w/ identity matrix,
otherwise only the diagonal and last-row is set.
The latter can be utilized to share a once initM, final float sx, final float sy, final float sz)identity set matrix
for scaling
and translation,
while leaving the other fields untouched for performance reasons.Make a scale matrix in column-major order from the given axis factors
Scale matrix (Any Order):
x 0 0 0
0 y 0 0
0 0 z 0
0 0 0 1
|
| public static float[] | Returns: given matrix for chaining4x4 matrix in column-major order (also result) m, final int offset in given array m, i.e. start of the 4x4 matrix m_offset, final boolean if true, given matrix will be initialized w/ identity matrix,
otherwise only the diagonal and last-row is set.
The latter can be utilized to share a once initM, final float tx, final float ty, final float tz)identity set matrix
for scaling
and translation,
while leaving the other fields untouched for performance reasons.Make a translation matrix in column-major order from the given axis deltas
Translation matrix (Column Order):
1 0 0 0
0 1 0 0
0 0 1 0
x y z 1
|
| public static float[] | Returns: given matrix for chaining4x4 matrix in column-major order (also result) m, final boolean if true, given matrix will be initialized w/ identity matrix,
otherwise only the diagonal and last-row is set.
The latter can be utilized to share a once initM, final float tx, final float ty, final float tz)identity set matrix
for scaling
and translation,
while leaving the other fields untouched for performance reasons.Make a translation matrix in column-major order from the given axis deltas
Translation matrix (Column Order):
1 0 0 0
0 1 0 0
0 0 1 0
x y z 1
|
| public static boolean | Returns: true if successful, otherwise false (z is 1)4x4 modelview matrix modelMatrix, final int modelMatrix_offset, final float[] 4x4 projection matrix projMatrix, final int projMatrix_offset, final int[] 4 component viewport vector viewport, final int viewport_offset, final float[] 3 component window coordinate, the result win_pos, final int win_pos_offset, final float[] 4 component vector for temp storage vec4Tmp1, final float[] 4 component vector for temp storage vec4Tmp2)Map object coordinates to window coordinates. |
| public static boolean | Returns: true if successful, otherwise false (z is 1)[projection] x [modelview] matrix, i.e. P x Mv mat4PMv, final int[] 4 component viewport vector viewport, final int viewport_offset, final float[] 3 component window coordinate, the result win_pos, final int win_pos_offset, final float[] 4 component vector for temp storage vec4Tmp1, final float[] 4 component vector for temp storage vec4Tmp2)Map object coordinates to window coordinates. |
| public static boolean | Returns: true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)4x4 modelview matrix modelMatrix, final int modelMatrix_offset, final float[] 4x4 projection matrix projMatrix, final int projMatrix_offset, final int[] 4 component viewport vector viewport, final int viewport_offset, final float[] 3 component object coordinate, the result obj_pos, final int obj_pos_offset, final float[] 16 component matrix for temp storage mat4Tmp1, final float[] 16 component matrix for temp storage mat4Tmp2)Map window coordinates to object coordinates. |
| public static boolean | Returns: true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)inverse [projection] x [modelview] matrix, i.e. Inv(P x Mv) mat4PMvI, final int[] 4 component viewport vector viewport, final int viewport_offset, final float[] 3 component object coordinate, the result obj_pos, final int obj_pos_offset, final float[] 4 component vector for temp storage vec4Tmp1, final float[] 4 component vector for temp storage vec4Tmp2)Map window coordinates to object coordinates. |
| public static boolean | Returns: true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)inverse [projection] x [modelview] matrix, i.e. Inv(P x Mv) mat4PMvI, final int[] 4 component viewport vector viewport, final int viewport_offset, final float[] 3 component object coordinate, the result for winz1 obj1_pos, final int obj1_pos_offset, final float[] 3 component object coordinate, the result for winz2 obj2_pos, final int obj2_pos_offset, final float[] 4 component vector for temp storage vec4Tmp1, final float[] 4 component vector for temp storage vec4Tmp2)Map two window coordinates to two object coordinates, distinguished by their z component. |
| public static boolean | Returns: true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)4x4 modelview matrix modelMatrix, final int modelMatrix_offset, final float[] 4x4 projection matrix projMatrix, final int projMatrix_offset, final int[] 4 component viewport vector viewport, final int viewport_offset, final float near, final float far, final float[] 4 component object coordinate, the result obj_pos, final int obj_pos_offset, final float[] 16 component matrix for temp storage mat4Tmp1, final float[] 16 component matrix for temp storage mat4Tmp2)Map window coordinates to object coordinates. |
| public static boolean | Returns: true if successful, otherwise false (failed to invert matrix, or becomes z is infinity)4x4 modelview matrix modelMatrix, final int modelMatrix_offset, final float[] 4x4 projection matrix projMatrix, final int projMatrix_offset, final int[] 4 component viewport vector viewport, final int viewport_offset, final Ray storage for the resulting ray, final float[] Ray16 component matrix for temp storage mat4Tmp1, final float[] 16 component matrix for temp storage mat4Tmp2, final float[] 4 component vector for temp storage vec4Tmp2)Map two window coordinates w/ shared X/Y and distinctive Z
to a |
| public static float | Returns: the matrix determinant4x4 matrix in column-major order, the source m, final int offset in given array m, i.e. start of the 4x4 matrix m_offset)Returns the determinant of the given matrix |
| public static float | Returns: the matrix determinant4x4 matrix in column-major order, the source m)Returns the determinant of the given matrix |
| public static StringBuilder | Returns: matrix row string representationoptional passed StringBuilder instance to be used sb, final String the format string of one floating point, i.e. "%10.5f", see f, final FloatBuffer java.mxn matrix (rows x columns) a, final int offset to aOffset, final int rows, final int columns, final boolean a's current positionif true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) rowMajorOrder, final int row number to print row)
Deprecated
use on of the float[] variants
|
| public static StringBuilder | Returns: matrix row string representationoptional passed StringBuilder instance to be used sb, final String the format string of one floating point, i.e. "%10.5f", see f, final float[] java.mxn matrix (rows x columns) a, final int offset to aOffset, final int rows, final int columns, final boolean a's current positionif true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) rowMajorOrder, final int row number to print row)
|
| public static StringBuilder | Returns: matrix string representationoptional passed StringBuilder instance to be used sb, final String optional prefix for each row rowPrefix, final String the format string of one floating point, i.e. "%10.5f", see f, final FloatBuffer java.mxn matrix (rows x columns) a, final int offset to aOffset, final int rows, final int columns, final boolean a's current positionif true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) rowMajorOrder)
Deprecated
use on of the float[] variants
|
| public static StringBuilder | Returns: matrix string representationoptional passed StringBuilder instance to be used sb, final String optional prefix for each row rowPrefix, final String the format string of one floating point, i.e. "%10.5f", see f, final float[] java.mxn matrix (rows x columns) a, final int offset to aOffset, final int rows, final int columns, final boolean a's current positionif true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) rowMajorOrder)
|
| public static StringBuilder | Returns: side by side representationoptional passed StringBuilder instance to be used sb, final String optional prefix for each row rowPrefix, final String the format string of one floating point, i.e. "%10.5f", see f, final FloatBuffer java.4x4 matrix in column major order (OpenGL) a, final int offset to aOffset, final FloatBuffer a's current position4x4 matrix in column major order (OpenGL) b, final int offset to bOffset, final int rows, final int columns, final boolean a's current positionif true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) rowMajorOrder)
Deprecated
use on of the float[] variants
|
| public static StringBuilder | Returns: side by side representationoptional passed StringBuilder instance to be used sb, final String optional prefix for each row rowPrefix, final String the format string of one floating point, i.e. "%10.5f", see f, final float[] java.4x4 matrix in column major order (OpenGL) a, final int offset to aOffset, final float[] a's current position4x4 matrix in column major order (OpenGL) b, final int offset to bOffset, final int rows, final int columns, final boolean a's current positionif true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) rowMajorOrder)
|
| public static float[] | Returns: given result matrix d for chaining4x4 matrix in column-major order a, final int a_off, final float[] 4x4 matrix in column-major order b, final int b_off, final float[] result a*b in column-major order d, final int d_off)Multiply matrix: [d] = [a] x [b] |
| public static float[] | Returns: given result matrix d for chaining4x4 matrix in column-major order a, final float[] 4x4 matrix in column-major order b, final float[] result a*b in column-major order d)Multiply matrix: [d] = [a] x [b] |
| public static float[] | Returns: given result matrix a for chaining4x4 matrix in column-major order (also result) a, final int a_off, final float[] 4x4 matrix in column-major order b, final int b_off)Multiply matrix: [a] = [a] x [b] |
| public static float[] | Returns: given result matrix a for chaining4x4 matrix in column-major order (also result) a, final float[] 4x4 matrix in column-major order b)Multiply matrix: [a] = [a] x [b] |
| public static void | multMatrix(final FloatBuffer
4x4 matrix in column-major order a, final FloatBuffer 4x4 matrix in column-major order b, final float[] result a*b in column-major order d)
Deprecated
use on of the float[] variants
Multiply matrix: [d] = [a] x [b]
|
| public static void | multMatrix(final FloatBuffer
4x4 matrix in column-major order (also result) a, final FloatBuffer 4x4 matrix in column-major order b)
Deprecated
use on of the float[] variants
Multiply matrix: [a] = [a] x [b]
|
| public static float[] | Returns: given result vector v_out for chaining4x4 matrix in column-major order m_in, final int m_in_off, final float[] 4-component column-vector v_in, final int v_in_off, final float[] m_in * v_in v_out, final int v_out_off)
|
| public static float[] | Returns: given result vector v_out for chaining4x4 matrix in column-major order m_in, final float[] 4-component column-vector v_in, final float[] m_in * v_in v_out)
|
| public static void | multMatrixVec(final FloatBuffer
4x4 matrix in column-major order m_in, final float[] 4-component column-vector v_in, final float[] m_in * v_in v_out)
Deprecated
use on of the float[] variants
|
| public static float | |
| public static float | |
| public static float | |
| public static float | |
| public static float[] | Returns: given result matrix mres for chaining4x4 matrix in column-major order, the source msrc, final int offset in given array msrc, i.e. start of the 4x4 matrix msrc_offset, final float[] 4x4 matrix in column-major order, the result mres, final int offset in given array mres, i.e. start of the 4x4 matrix mres_offset)Transpose the given matrix. |
| public static float[] | Returns: given result matrix mres for chaining4x4 matrix in column-major order, the source msrc, final float[] 4x4 matrix in column-major order, the result mres)Transpose the given matrix. |