hmi.math
Class Mat4f

java.lang.Object
  extended by hmi.math.Mat4f

public final class Mat4f
extends Object

A collection of static methods for 4 X 4 matrices, represented by float arrays of length 16. Matrices are stored in row-major order, i.e., the first four elements represent the first row, the next four represent the second row etcetera. Note that this deviates from the OpenGL order.

Author:
Job Zwiers

Field Summary
private static int BUFSIZE
           
static int COL_SIZE
           
static float DEGTORADF
           
static float[] ID
          The 4X4 identity matrix.
static int M00
           
static int M01
           
static int M02
           
static int M03
           
static int M10
           
static int M11
           
static int M12
           
static int M13
           
static int M20
           
static int M21
           
static int M22
           
static int M23
           
static int M30
           
static int M31
           
static int M32
           
static int M33
           
static int MAT4F_SIZE
           
static int ROW_SIZE
          Length of Mat4f arrays is 16
 
Constructor Summary
private Mat4f()
           
 
Method Summary
static void clearRotationScale(float[] m)
          Sets the rotation/scaling part of a 4X4 (or 3X4) matrix m, i.e. the upper left 3X3 part, to the 3X3 identity matrix The remaining parts are not modified.
static void convertTo4x4(float[] m)
          Converts a 3 X 3 matrix m into a 4 X 4 matrix, by adding a right colum and a bottom row, consisting of zero enties.
static double decomposeToTRSMat3f(float[] matrix, float[] translation, float[] rotation, float[] scaleMatrix)
          Decomposes a 4 x 4 (or 3 X 4) matrix into a translation vector (a Vec3f array), a rotation quaternion (a Vec4f array), and a 3 X 3 scaling matrix (a Mat3f array), using a polar decompose operation for the upper left 3 x 3 matrix.
static Mat3f.ScalingType decomposeToTRSMat3f(float[] matrix, float[] translation, float[] rotation, float[] scaleMatrix, float epsilon)
          Deprecated.  
static double det(float[] m)
          Determines the determinant of m.
static float dInf(float[] a, float[] b)
           
static boolean epsilonEquals(float[] a, float[] b, float epsilon)
          Tests for equality of matrix components within epsilon.
static boolean equals(float[] a, float[] b)
          Tests for (strict) equality of matrix components.
static String explainMat4f(float[] mat4f, int fieldwidth, int precision, float epsilon)
          converts a Mat4f matrix to a String, for printing on a console, that decomposes the matrix into rotation, translation, and scale.
static float[] from3x3(float[] m3x3)
          Creates a new 4X4 matrix from a 3 X 3 matrix, by adding a right colum and a bottom row, consisting of zero enties.
static void getColumn(float[] m, int j, float[] col)
          Copies a matrix column with index j from a 4X4 matrix m.
static float getElement(float[] m, int i, int j)
          Gets the float value of matrix element m(i,j), form a row-major order 4X4 matrix m.
static float[] getIdentity()
          Allocates a new 4X4 matrix, initialized to the identity matrix.
static float[] getLookAtMatrix(float[] eyePos, float[] centerPos, float[] upVec)
          Allocates a new LookAt matrix, in OpenGL style: from eyePos, look at center, where upVec is used to infer the direction of the Y-axis (needs not be orthogonal to viewing direction) The viewing direction is considered to be the negative Z-axis,
static float[] getMat4f()
          Returns a new float[16] array with zero components
static void getRow(float[] m, int i, float[] row)
          Copies a matrix row with index i from a 4X4 matrix m.
static float[] getScalingMatrix(float[] s)
          Allocates a new 4X4 scaling matrix, with scaling factors specified in a length 3 float array.
static float[] getSkewMatrix(float[] matrix, float angle, float[] rvec, float[] tvec)
          Allocates a new skew matrix, specified in Renderman style, by means of a tranlation vector tvec, a rotation vector rvec, and a rotation angle.
static float[] getSkewMatrix(float angle, float[] rvec, float[] tvec)
          See getSkewMatrix, with null matrix argument
static void getTranslation(float[] t, float[] m)
          Retrieves the translation vector column for a 4X4 or 3X4 matrix m, i.e. the last 3X1 column, to a translation Vec3f vector t.
static float[] getTranslationMatrix(float[] t)
          Allocates a new 4X4 translation matrix, with translation vector specified in a length 3 float array.
static float invertAffine(float[] dest, float[] m)
          Calculates the inverse of 4X4 matrix m, assuming that it consists of a 3X3 rotation/scaling part, a translation part in the last column, and a fourth row of the form (0, 0, 0, 1) This reprents an affine transform within 3D; it does not allow general 4X4 matrices, in particular projection matrices are not allowed here.
static void invertRigid(float[] m)
           
static void invertRigid(float[] dest, float[] m)
          Efficient method for calculating the inverse of a rigid transform.
static boolean isAffine(float[] matrix)
          Checks the bottom row of a 4X4 matrix.
static boolean isIdentity(float[] m)
          Checks whether some matrix is actually the identity matrix.
static boolean isProjective(float[] matrix)
          Deprecated.  
static boolean isRigid(float[] m, float epsilon)
          Checks for orthogonality of the 3X3 upper-left submatrix, and checks that the last row is (0, 0, 0, 1).
static boolean isZero(float[] m)
          Checks whether some matrix is actually the zero matrix.
static void mul(float[] dest, float[] m)
          Multiplies Mat4f matrix dest with Mat4f matrix A and stores the result back in dest.
static void mul(float[] dest, float[] a, float[] b)
          Multiplies Mat4f matrix a with Mat4f matrix b and stores the result in Mat4f matrix dest.
static void mul3x4(float[] dest, float[] a)
          Equivalent to mul(dest, dest, a).
static void mul3x4(float[] dest, float[] a, float[] b)
          Multiplies two Mat4f matrices, assuming that the fourth row is of the form (0, 0, 0, 1).
static void nonUniformScale(float[] m, float[] scale)
          Scales the upper left 3X3 part by means of non-uniform scaling factors, specified in a Vec3f array.
static float norm1(float[] m)
          Return the norm_1 of matrix m: the sum of the absolute values of all matrix elements.
static float norm2(float[] m)
          Return the norm-2 of matrix m: the square root of the sum of the squares of all elements.
static float normInf(float[] m)
          Return the max norm of matrix m: the max absolute value of the matrix elements.
static void scale(float[] m, float s)
          Scales the upper left 3X3 part by means of common factor s.
static void set(float[] dst, float[] src)
          Copies a 4X4 matrix src into matrix dst
static void set(float[] dst, float src00, float src01, float src02, float src03, float src10, float src11, float src12, float src13, float src20, float src21, float src22, float src23, float src30, float src31, float src32, float src33)
          Sets the 4x4 matrix in dst
static void set(float[] dst, int dstIndex, float[] src, int srcIndex)
          Copies a 4X4 matrix src into matrix dst
static void setElement(float[] m, int i, int j, float value)
          Sets the element m(i,j) from a (row-major) 4X4 matrix m to a specified float value.
static void setFromTR(float[] m, float[] t, float[] q)
          Sets all matrix component, from a translation Vec3f t and a rotation Quat4f q.
static void setFromTRCS(float[] m, float[] t, float[] q, float[] c, float uscale)
          Sets all matrix component, from a rotation Quat4f q, a rotation center Vec3f c, and a uniform scale.
static void setFromTRCSVec3f(float[] m, float[] t, float[] q, float[] c, float[] s)
          Sets all matrix component, from a rotation Quat4f q, a rotation center Vec3f c, scaling factors in the form of a Vec3f, and a Vec3f translation.
static void setFromTRS(float[] m, float[] t, float[] q, float uscale)
          Sets all matrix component, from a translation Vec3f t, a rotation Quat4f q, and a uniform scaling float factor uscale.
static void setFromTRSMat3f(float[] m, float[] t, float[] q, float[] smatrix)
          Sets all matrix component, from a rotation Quat4f q, scaling matrix in the form of a Mat3f, and a Vec3f translation.
static void setFromTRSVec3f(float[] m, float[] t, float[] q, float[] s)
          Sets all matrix component, from a translation Vec3f t, rotation Quat4f q, and (non uniform) scaling factors in the form of a Vec3f.
static void setIdentity(float[] m)
          Resets the 4X4 matrix to the identity matrix.
static void setRotation(float[] m, float[] q)
          Sets the rotation part of a 4X4 (or 3X4) matrix m, i.e. the upper left 3X3 part, from a Quat4f quaternion q.
static void setRotation(float[] m, int mIndex, float[] q, int qIndex)
          Sets the rotation part of a 4X4 (or 3X4) matrix m, i.e. the upper left 3X3 part, from a Quat4f quaternion q.
static void setRotationFromAxisAngle(float[] m, float[] axis, float angle)
          Sets the rotation part of a 4X4 or 3X4 matrix m, i.e. the upper left 3X3 part, from an axis aray, of length 3, and an float angle.
static void setRotationFromAxisAngle4f(float[] m, float[] axisangle)
          Sets the rotation part of a 4X4 or 3X4 matrix m, i.e. the upper left 3X3 part, from a axis-and-angle array, of length 4.
static void setRotationFromAxisAngleDegrees(float[] m, float[] axis, float degrees)
          Sets the rotation part of a 4X4 or 3X4 matrix m, i.e. the upper left 3X3 part, from an rotation axis and an angle, specified in degrees, not radians.
static void setRotationScaleVec3f(float[] m, float[] q, float[] s)
          Sets the rotation part of a 4X4 (or 3X4) matrix m, i.e. the upper left 3X3 part, from a Quat4f quaternion q and a Vec3f scaling array in the form of a Vec3f array.
static void setTranslation(float[] m, float[] t)
          Sets the translation vector column for a 4X4 (or 3X4) matrix m, i.e. the last 3X1 column, from a translation Vec3f vector t.
static void setZero(float[] m)
          Resets the 4X4 matrix to zero.
static String toString(float[] m)
          Produces a String representation of a 4 X 4 matrix, suitable for printing, debugging etcetera
static String toString(float[] m, int tab)
          Produces a String representation of Mat4f matrix m, taking into account tab spaces at the beginning of every newline.
static String toString(float[] m, int tab, int fieldwidth, int precision)
          Produces a String representation of Mat4f matrix m, taking into account tab spaces at the beginning of every newline.
static String toString(float[] m, int tab, String fmt)
          Produces a String representation of Mat4f matrix m, taking into account tab spaces at the beginning of every newline.
static void transformAffineMatrix(float[] m, float[] destMat)
          calculates a coordinate transform of matrix destMat in place.
static void transformAffineMatrix(float[] m, float[] destMat, float[] srcMat)
          calculates a coordinate transform of matrix srcMat and stores the result in destMat.
static void transformAffineMatrix(float[] m, float[] minv, float[] destMat, float[] srcMat)
          calculates a coordinate transform of matrix srcMat and stores the result in destMat.
static void transformPoint(float[] m, float[] dest)
          Equivalent to transformPoint(m, dest, dest)
static void transformPoint(float[] m, float[] dest, float[] src)
          Transforms a Vec3 (Nb!)
static void transformPoint(float[] m, float[] dest, int destIndex)
          Transforms a Vec3 (NB!)
static void transformVec3f(float[] m, float[] dest)
          Deprecated.  
static void transformVec3f(float[] m, float[] dest, float[] src)
          Deprecated.  
static void transformVec3f(float[] m, float[] dest, int dstIndex)
          Deprecated.  
static void transformVec4f(float[] m, float[] dest)
          Transforms a Vec4 vector dest in place
static void transformVec4f(float[] m, float[] dest, float[] src)
          Transforms a Vec4 vector src, and puts the result in vector dest.
static void transformVec4f(float[] m, int mIndex, float[] dest, int destIndex, float[] src, int srcIndex)
          Transforms a Vec4 vector src, and puts the result in vector dest.
static void transformVector(float[] m, float[] dest)
          Equivalent to transformVector(m, dest, dest).
static void transformVector(float[] m, float[] dest, float[] src)
          Transforms a Vec3f array that represents a translation vector (as opposed to a geometric point).
static void transformVector(float[] m, float[] dest, int destIndex)
          Transforms a Vec3 (NB!)
static void transpose(float[] m)
          Transposes matrix m.
static void transpose(float[] dest, float[] m)
          Sets matrix dest to the transpose of matrix m.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROW_SIZE

public static final int ROW_SIZE
Length of Mat4f arrays is 16

See Also:
Constant Field Values

COL_SIZE

public static final int COL_SIZE
See Also:
Constant Field Values

MAT4F_SIZE

public static final int MAT4F_SIZE
See Also:
Constant Field Values

M00

public static final int M00
See Also:
Constant Field Values

M01

public static final int M01
See Also:
Constant Field Values

M02

public static final int M02
See Also:
Constant Field Values

M03

public static final int M03
See Also:
Constant Field Values

M10

public static final int M10
See Also:
Constant Field Values

M11

public static final int M11
See Also:
Constant Field Values

M12

public static final int M12
See Also:
Constant Field Values

M13

public static final int M13
See Also:
Constant Field Values

M20

public static final int M20
See Also:
Constant Field Values

M21

public static final int M21
See Also:
Constant Field Values

M22

public static final int M22
See Also:
Constant Field Values

M23

public static final int M23
See Also:
Constant Field Values

M30

public static final int M30
See Also:
Constant Field Values

M31

public static final int M31
See Also:
Constant Field Values

M32

public static final int M32
See Also:
Constant Field Values

M33

public static final int M33
See Also:
Constant Field Values

DEGTORADF

public static final float DEGTORADF
See Also:
Constant Field Values

ID

public static final float[] ID
The 4X4 identity matrix.


BUFSIZE

private static final int BUFSIZE
See Also:
Constant Field Values
Constructor Detail

Mat4f

private Mat4f()
Method Detail

getMat4f

public static float[] getMat4f()
Returns a new float[16] array with zero components


scale

public static void scale(float[] m,
                         float s)
Scales the upper left 3X3 part by means of common factor s. Note that this will not cancel scaling factors set earlier, rather, the effect of scale operations is cumulative.


nonUniformScale

public static void nonUniformScale(float[] m,
                                   float[] scale)
Scales the upper left 3X3 part by means of non-uniform scaling factors, specified in a Vec3f array. Scaling is performed along the major axes. Note that this will not cancel scaling factors set earlier, rather, the effect of scaling operations is cumulative.


getScalingMatrix

public static float[] getScalingMatrix(float[] s)
Allocates a new 4X4 scaling matrix, with scaling factors specified in a length 3 float array.


getTranslationMatrix

public static float[] getTranslationMatrix(float[] t)
Allocates a new 4X4 translation matrix, with translation vector specified in a length 3 float array.


getSkewMatrix

public static float[] getSkewMatrix(float angle,
                                    float[] rvec,
                                    float[] tvec)
See getSkewMatrix, with null matrix argument


getSkewMatrix

public static float[] getSkewMatrix(float[] matrix,
                                    float angle,
                                    float[] rvec,
                                    float[] tvec)
Allocates a new skew matrix, specified in Renderman style, by means of a tranlation vector tvec, a rotation vector rvec, and a rotation angle. According to the Renderman specs, shearing is performed in the direction of tvec, where tvec and rvec define the shearing plane. The effect is such that the skewed rvec vector has the specified angle with rvec itself. (Note that the skewed rvec will not have the same length as rvec; despite this, the specs talk abount "rotating" rvec over an angle as specified.) The Collada skew transform for Nodes refers also to the renderman specs, although their example suggests they don't understand it: Rather, they claim that rvec would be the axis of rotation. The matrix argument should be a Mat4f float array, or it can be null, in which case a float array will be allocated. It is filled with the resulting skewing matrix, and returned


getLookAtMatrix

public static float[] getLookAtMatrix(float[] eyePos,
                                      float[] centerPos,
                                      float[] upVec)
Allocates a new LookAt matrix, in OpenGL style: from eyePos, look at center, where upVec is used to infer the direction of the Y-axis (needs not be orthogonal to viewing direction) The viewing direction is considered to be the negative Z-axis,


from3x3

public static float[] from3x3(float[] m3x3)
Creates a new 4X4 matrix from a 3 X 3 matrix, by adding a right colum and a bottom row, consisting of zero enties. The bottom-right element is set to 1.0,


convertTo4x4

public static void convertTo4x4(float[] m)
Converts a 3 X 3 matrix m into a 4 X 4 matrix, by adding a right colum and a bottom row, consisting of zero enties. The bottom-right element is set to 1.0. This is done "in place", therefore m should be a float array of length 16(!)


set

public static void set(float[] dst,
                       int dstIndex,
                       float[] src,
                       int srcIndex)
Copies a 4X4 matrix src into matrix dst


set

public static void set(float[] dst,
                       float[] src)
Copies a 4X4 matrix src into matrix dst


set

public static void set(float[] dst,
                       float src00,
                       float src01,
                       float src02,
                       float src03,
                       float src10,
                       float src11,
                       float src12,
                       float src13,
                       float src20,
                       float src21,
                       float src22,
                       float src23,
                       float src30,
                       float src31,
                       float src32,
                       float src33)
Sets the 4x4 matrix in dst


setFromTRCS

public static void setFromTRCS(float[] m,
                               float[] t,
                               float[] q,
                               float[] c,
                               float uscale)
Sets all matrix component, from a rotation Quat4f q, a rotation center Vec3f c, and a uniform scale.


setFromTRCSVec3f

public static void setFromTRCSVec3f(float[] m,
                                    float[] t,
                                    float[] q,
                                    float[] c,
                                    float[] s)
Sets all matrix component, from a rotation Quat4f q, a rotation center Vec3f c, scaling factors in the form of a Vec3f, and a Vec3f translation. Scaling is performed along the main axes.


setFromTRSMat3f

public static void setFromTRSMat3f(float[] m,
                                   float[] t,
                                   float[] q,
                                   float[] smatrix)
Sets all matrix component, from a rotation Quat4f q, scaling matrix in the form of a Mat3f, and a Vec3f translation.


setFromTRSVec3f

public static void setFromTRSVec3f(float[] m,
                                   float[] t,
                                   float[] q,
                                   float[] s)
Sets all matrix component, from a translation Vec3f t, rotation Quat4f q, and (non uniform) scaling factors in the form of a Vec3f. Scaling is performed along the main axes.


setFromTRS

public static void setFromTRS(float[] m,
                              float[] t,
                              float[] q,
                              float uscale)
Sets all matrix component, from a translation Vec3f t, a rotation Quat4f q, and a uniform scaling float factor uscale.


setFromTR

public static void setFromTR(float[] m,
                             float[] t,
                             float[] q)
Sets all matrix component, from a translation Vec3f t and a rotation Quat4f q.


setRotationScaleVec3f

public static void setRotationScaleVec3f(float[] m,
                                         float[] q,
                                         float[] s)
Sets the rotation part of a 4X4 (or 3X4) matrix m, i.e. the upper left 3X3 part, from a Quat4f quaternion q and a Vec3f scaling array in the form of a Vec3f array. The remaining parts are not modified.


setRotation

public static void setRotation(float[] m,
                               int mIndex,
                               float[] q,
                               int qIndex)
Sets the rotation part of a 4X4 (or 3X4) matrix m, i.e. the upper left 3X3 part, from a Quat4f quaternion q. The remaining parts are not modified.


setRotation

public static void setRotation(float[] m,
                               float[] q)
Sets the rotation part of a 4X4 (or 3X4) matrix m, i.e. the upper left 3X3 part, from a Quat4f quaternion q. The remaining parts are not modified.


clearRotationScale

public static void clearRotationScale(float[] m)
Sets the rotation/scaling part of a 4X4 (or 3X4) matrix m, i.e. the upper left 3X3 part, to the 3X3 identity matrix The remaining parts are not modified.


setRotationFromAxisAngleDegrees

public static void setRotationFromAxisAngleDegrees(float[] m,
                                                   float[] axis,
                                                   float degrees)
Sets the rotation part of a 4X4 or 3X4 matrix m, i.e. the upper left 3X3 part, from an rotation axis and an angle, specified in degrees, not radians. The axis need not have length 1 for this operation.


setRotationFromAxisAngle4f

public static void setRotationFromAxisAngle4f(float[] m,
                                              float[] axisangle)
Sets the rotation part of a 4X4 or 3X4 matrix m, i.e. the upper left 3X3 part, from a axis-and-angle array, of length 4. The angle is specified in radians, the axis should have length 1. The remaining parts are not modified.


setRotationFromAxisAngle

public static void setRotationFromAxisAngle(float[] m,
                                            float[] axis,
                                            float angle)
Sets the rotation part of a 4X4 or 3X4 matrix m, i.e. the upper left 3X3 part, from an axis aray, of length 3, and an float angle. The angle is specified in radians, the axis should have length 1. The remaining parts are not modified.


setTranslation

public static void setTranslation(float[] m,
                                  float[] t)
Sets the translation vector column for a 4X4 (or 3X4) matrix m, i.e. the last 3X1 column, from a translation Vec3f vector t. The remaining parts are not modified.


getTranslation

public static void getTranslation(float[] t,
                                  float[] m)
Retrieves the translation vector column for a 4X4 or 3X4 matrix m, i.e. the last 3X1 column, to a translation Vec3f vector t.


setZero

public static void setZero(float[] m)
Resets the 4X4 matrix to zero.


setIdentity

public static void setIdentity(float[] m)
Resets the 4X4 matrix to the identity matrix.


getIdentity

public static float[] getIdentity()
Allocates a new 4X4 matrix, initialized to the identity matrix.


isIdentity

public static boolean isIdentity(float[] m)
Checks whether some matrix is actually the identity matrix. This checks for exact identity.


isZero

public static boolean isZero(float[] m)
Checks whether some matrix is actually the zero matrix. This checks for exact equality.


setElement

public static void setElement(float[] m,
                              int i,
                              int j,
                              float value)
Sets the element m(i,j) from a (row-major) 4X4 matrix m to a specified float value.


getElement

public static float getElement(float[] m,
                               int i,
                               int j)
Gets the float value of matrix element m(i,j), form a row-major order 4X4 matrix m.


getRow

public static void getRow(float[] m,
                          int i,
                          float[] row)
Copies a matrix row with index i from a 4X4 matrix m. The result is copied to a Vec4 array row.


getColumn

public static void getColumn(float[] m,
                             int j,
                             float[] col)
Copies a matrix column with index j from a 4X4 matrix m. The result is copied to a Vec4 array col.


mul

public static void mul(float[] dest,
                       float[] m)
Multiplies Mat4f matrix dest with Mat4f matrix A and stores the result back in dest. dest = dest * A


mul

public static void mul(float[] dest,
                       float[] a,
                       float[] b)
Multiplies Mat4f matrix a with Mat4f matrix b and stores the result in Mat4f matrix dest. The dest array is allowed to be aliased with a and/or b: dest = a * b


mul3x4

public static void mul3x4(float[] dest,
                          float[] a,
                          float[] b)
Multiplies two Mat4f matrices, assuming that the fourth row is of the form (0, 0, 0, 1). Whether the fourth row is actually present or not is not important; The Mat4f coding stores these in the last four elements of a float[16] array. This method does not read nor write these elements. (So it will also NOT set dest[M33] to 1) The dest array is allowed to be aliased with a and/or b: dest = a * b


mul3x4

public static void mul3x4(float[] dest,
                          float[] a)
Equivalent to mul(dest, dest, a). That, multiplies the 3x4 dest matrix on the right with the 3x4 matrix a, treating the fourth row of dest and a as being (0, 0, 0, 1)


transformVec4f

public static void transformVec4f(float[] m,
                                  int mIndex,
                                  float[] dest,
                                  int destIndex,
                                  float[] src,
                                  int srcIndex)
Transforms a Vec4 vector src, and puts the result in vector dest. The latter is allowed to be aliased to src. The matrix, as well as the two vectors start at offsets, specified by mIndex, destIndex, and srcIndex.


transformVec4f

public static void transformVec4f(float[] m,
                                  float[] dest,
                                  float[] src)
Transforms a Vec4 vector src, and puts the result in vector dest. The latter is allowed to be aliased to src.


transformVec4f

public static void transformVec4f(float[] m,
                                  float[] dest)
Transforms a Vec4 vector dest in place


transformVec3f

@Deprecated
public static void transformVec3f(float[] m,
                                             float[] dest)
Deprecated. 

Equivalent to transformPoint(m, dest, dest).


transformVec3f

@Deprecated
public static void transformVec3f(float[] m,
                                             float[] dest,
                                             int dstIndex)
Deprecated. 

Equivalent to transformPoint(m, dest, dest).


transformVec3f

@Deprecated
public static void transformVec3f(float[] m,
                                             float[] dest,
                                             float[] src)
Deprecated. 

Equivalent to transformPoint(m, dest, src);


transformPoint

public static void transformPoint(float[] m,
                                  float[] dest,
                                  float[] src)
Transforms a Vec3 (Nb!) array src, and puts the result in Vec3f array dest. The latter is allowed to be aliased to src. In effect the matrix is treated like an 3X3 matrix M33 plus an extra 3X1 colum vector t. (The last matrix row is ignored altogether) The result: dest = M33 * src + t Note that this is an affine transform appropriate for Vec3f elements that represent geometric points in 3D space; it is not appropriate for Vec3f elements that represent translation vectors.


transformPoint

public static void transformPoint(float[] m,
                                  float[] dest)
Equivalent to transformPoint(m, dest, dest)


transformPoint

public static void transformPoint(float[] m,
                                  float[] dest,
                                  int destIndex)
Transforms a Vec3 (NB!) array of points dest starting at the specified destIndex offset, In effect the matrix is treated like an 3X3 matrix M33 plus an extra 3X1 colum vector t. (The last matrix row is ignored altogether) The result: dest = M33 * dest + t


transformVector

public static void transformVector(float[] m,
                                   float[] dest,
                                   float[] src)
Transforms a Vec3f array that represents a translation vector (as opposed to a geometric point). So the upper left 3X3 matrix is applied to the src vector, the translation part of m is ignored, and the result is stored in the dest vector. (Norte: This differs from the transformVec3f operations: the latter do add the translation from the 4X4 matrix.) src and dest can be aliased.


transformVector

public static void transformVector(float[] m,
                                   float[] dest)
Equivalent to transformVector(m, dest, dest).


transformVector

public static void transformVector(float[] m,
                                   float[] dest,
                                   int destIndex)
Transforms a Vec3 (NB!) array of translation vectors, dest starting at the specified destIndex offset, In effect the matrix is treated like an 3X3 matrix M33 plus an extra 3X1 colum vector t. (The last matrix row is ignored altogether) The result: dest = M33 * dest + t


transformAffineMatrix

public static void transformAffineMatrix(float[] m,
                                         float[] destMat)
calculates a coordinate transform of matrix destMat in place. The coordinate transform must be provided by a 4X4 affine matrix. (So m should have a last row of the form (0, 0, 0, 1))


transformAffineMatrix

public static void transformAffineMatrix(float[] m,
                                         float[] minv,
                                         float[] destMat,
                                         float[] srcMat)
calculates a coordinate transform of matrix srcMat and stores the result in destMat. The coordinate transform must be provided by a 4X4 affine matrix, together with its inverse minv. (So m and minv should have a last row of the form (0, 0, 0, 1))


transformAffineMatrix

public static void transformAffineMatrix(float[] m,
                                         float[] destMat,
                                         float[] srcMat)
calculates a coordinate transform of matrix srcMat and stores the result in destMat. The coordinate transform must be provided by a 4X4 affine matrix (So m should have a last row of the form (0, 0, 0, 1))


transpose

public static void transpose(float[] dest,
                             float[] m)
Sets matrix dest to the transpose of matrix m. dest and m can be the same matrix.


transpose

public static void transpose(float[] m)
Transposes matrix m.


invertRigid

public static void invertRigid(float[] dest,
                               float[] m)
Efficient method for calculating the inverse of a rigid transform. This assumes that m has the form T(t) o R, where T(t) translates over vector t, and where R is a pure rotation, without scaling. In this case, the inverse is T(R'(-t)) o R', where R' is the transpose of R.


invertRigid

public static void invertRigid(float[] m)

invertAffine

public static float invertAffine(float[] dest,
                                 float[] m)
Calculates the inverse of 4X4 matrix m, assuming that it consists of a 3X3 rotation/scaling part, a translation part in the last column, and a fourth row of the form (0, 0, 0, 1) This reprents an affine transform within 3D; it does not allow general 4X4 matrices, in particular projection matrices are not allowed here.


equals

public static boolean equals(float[] a,
                             float[] b)
Tests for (strict) equality of matrix components.


epsilonEquals

public static boolean epsilonEquals(float[] a,
                                    float[] b,
                                    float epsilon)
Tests for equality of matrix components within epsilon.


dInf

public static float dInf(float[] a,
                         float[] b)

norm1

public static float norm1(float[] m)
Return the norm_1 of matrix m: the sum of the absolute values of all matrix elements.


norm2

public static float norm2(float[] m)
Return the norm-2 of matrix m: the square root of the sum of the squares of all elements. (The standard euclidean norm)


normInf

public static float normInf(float[] m)
Return the max norm of matrix m: the max absolute value of the matrix elements.


det

public static double det(float[] m)
Determines the determinant of m.


isAffine

public static boolean isAffine(float[] matrix)
Checks the bottom row of a 4X4 matrix. Returns true if it is equal to 0, 0, 0, 1, which is the case for affine matrices, but not for projection matrices.


isRigid

public static boolean isRigid(float[] m,
                              float epsilon)
Checks for orthogonality of the 3X3 upper-left submatrix, and checks that the last row is (0, 0, 0, 1). The epsilon factor determines how precise this requirement is checked: absolute values of inproducts between different columns are required to be smaller than epsilon, inproduct of colums with themselves should be equal to 1.0 within epsilon. A gigid matrix cobines an orthogonal 3X3 transform with a translation.


toString

public static String toString(float[] m)
Produces a String representation of a 4 X 4 matrix, suitable for printing, debugging etcetera


toString

public static String toString(float[] m,
                              int tab,
                              int fieldwidth,
                              int precision)
Produces a String representation of Mat4f matrix m, taking into account tab spaces at the beginning of every newline. Matrix elements within eps from 1.0 or -1.0 are represented by 1.0 or -1.0, elements with absolute value < eps will be presented as 0.0 values.


toString

public static String toString(float[] m,
                              int tab,
                              String fmt)
Produces a String representation of Mat4f matrix m, taking into account tab spaces at the beginning of every newline. Matrix elements within eps from 1.0 or -1.0 are represented by 1.0 or -1.0, elements with absolute value < eps will be presented as 0.0 values.


toString

public static String toString(float[] m,
                              int tab)
Produces a String representation of Mat4f matrix m, taking into account tab spaces at the beginning of every newline. Matrix elements within eps from 1.0 or -1.0 are represented by 1.0 or -1.0, elements with absolute value < eps will be presented as 0.0 values.


decomposeToTRSMat3f

public static double decomposeToTRSMat3f(float[] matrix,
                                         float[] translation,
                                         float[] rotation,
                                         float[] scaleMatrix)
Decomposes a 4 x 4 (or 3 X 4) matrix into a translation vector (a Vec3f array), a rotation quaternion (a Vec4f array), and a 3 X 3 scaling matrix (a Mat3f array), using a polar decompose operation for the upper left 3 x 3 matrix. The bottom row of matrix is ignored. The type of scaling is returned. If this would be ALIGNED, then a Vec3f scaling vector can be obtained by calling Mat3f.getDiagonal(scaleMatrix), if it would be UNIFORM, then the scale factor is scaleMatrix[Mat3f.M00]. If it is IDENTITY, then the uniform scale factor is 1.0. If it is SKEW, then the scaleMatrix is not a simple diagonal matrix, but involves scaling along rotated axes.


explainMat4f

public static String explainMat4f(float[] mat4f,
                                  int fieldwidth,
                                  int precision,
                                  float epsilon)
converts a Mat4f matrix to a String, for printing on a console, that decomposes the matrix into rotation, translation, and scale. rotation is presented by means of axis angle and degrees. scaling is omitted when it is uniform with factor 1. else it is represented by scaling factor(s) or, when it is skew scaling, by means of a scaling matrix


decomposeToTRSMat3f

@Deprecated
public static Mat3f.ScalingType decomposeToTRSMat3f(float[] matrix,
                                                               float[] translation,
                                                               float[] rotation,
                                                               float[] scaleMatrix,
                                                               float epsilon)
Deprecated. 

Decomposes a 4 x 4 (or 3 X 4) matrix into a translation vector (a Vec3f array), a rotation quaternion (a Vec4f array), and a 3 X 3 scaling matrix (a Mat3f array), using a polar decompose operation for the upper left 3 x 3 matrix. The bottom row of matrix is ignored. The type of scaling is returned. If this would be ALIGNED, then a Vec3f scaling vector can be obtained by calling Mat3f.getDiagonal(scaleMatrix), if it would be UNIFORM, then the scale factor is scaleMatrix[Mat3f.M00]. If it is IDENTITY, then the uniform scale factor is 1.0. If it is SKEW, then the scaleMatrix is not a simple diagonal matrix, but involves scaling along rotated axes. The epsilon factor determines the threshold for smoothing the scaling matrix and rotation quaternion


isProjective

@Deprecated
public static boolean isProjective(float[] matrix)
Deprecated. 

Checks the bottom row of a 4X4 matrix. Returns true if it is not equal to 0, 0, 0, 1, as is the case for projection matrices. Deprecated: use isAffine(m) (= ! isProjective(m))