hmi.math
Class Mat3f

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

public final class Mat3f
extends Object

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

Author:
Job Zwiers, Herwin van Welbergen

Nested Class Summary
static class Mat3f.ScalingType
          Restored for compatibility with Herwin's demos, do not remove
 
Field Summary
static int COL_SIZE
           
static double DEGREEPERRAD
           
static int M00
           
static int M01
           
static int M02
           
static int M10
           
static int M11
           
static int M12
           
static int M20
           
static int M21
           
static int M22
           
static int MAT3F_SIZE
           
private static float MINIMAL_SKEW_ANGLE
           
private static float NORMALIZE_THRESHOLD
           
private static float POLARDECOMPOSESMOOTHFACTOR
           
static int ROW_SIZE
           
static float TOL
           
 
Constructor Summary
private Mat3f()
           
 
Method Summary
static void add(float[] dest, float[] a)
          dest += a
static void add(float[] dest, float[] a, float[] b)
          dest = a+b
static void add(float[] dest, int destIndex, float[] a, int aIndex)
          dest += b
static void add(float[] dest, int destIndex, float[] a, int aIndex, float[] b, int bIndex)
          dest = a+b
static float adjugate(float[] dest, float[] m)
          Sets the dest matrix to the adjugate (i.e "classical adjoint") matrix of m) It is always defined, even when m is not invertible.
static float adjugateTranspose(float[] dest, float[] m)
          Sets the dest matrix to the transpose of the adjugate (i.e "classical adjoint" matrix of m) It is always defined, even when m is not invertible.
protected static float adjugateTransposeMat4f(float[] dest, float[] m)
          Sets the dest matrix to the transpose of the adjugate of the rotation/scaling 3x3 part of the 4x4 matrix m.
static void convertTo3x3(float[] m)
          Converts a 4 X 4 matrix, stored in a length 16(!)
static double det(float[] m)
          Determines the determinant of m.
static boolean epsilonEquals(float[] a, float[] b, float epsilon)
          Tests for equality of matrix components within epsilon.
static boolean epsilonEquals(float[] a, int aIndex, float[] b, int bIndex, float epsilon)
          Tests for equality of matrix components within epsilon.
static boolean equals(float[] a, float[] b)
          Tests for equality of matrix components.
static float[] from4x4(float[] m4x4)
          Allocates a new 3 X 3 matrix, containing a copy of the upper-left 3 X 3 matrix from an 4 X 4 matrix.
static void getColumn(float[] m, int j, float[] col)
          Copies a matrix column with index j from a 3X3 matrix m.
static void getDiagonal(float[] matrix3f, float[] vec3f)
          Returns the diagonal in a Vec3f array
static float getElement(float[] m, int i, int j)
          Gets the float value of matrix element m(i,j), form a row-major order 3X3 matrix m.
static float[] getIdentity()
          Allocates a new 3X3 matrix, initialized to the identity matrix.
static float[] getMat3f()
          Returns a new float[9] array with zero components
static void getRow(float[] m, int i, float[] row)
          Copies a matrix row with index i from a 3X3 matrix m.
static float[] getScalingMatrix(float[] s)
          Allocates a new 3X3 scaling matrix, with scaling factors specified in a length 3 float array.
static Mat3f.ScalingType getScalingType(float[] m)
          Determines the scaling type of a matrix The type is SKEW if there are any non-zero off-diagonal elements.
static Mat3f.ScalingType getScalingTypeVec3f(float[] scaleVec)
          Deprecated. Restored for compatibility with Herwin's demos
static float[] getSkewMatrix(float[] matrix, float angle, float[] rvec, float[] tvec)
          Allocates a new skew/shear matrix, specified in Renderman style, by means of a translation vector tvec, a rotation vector rvec, and a rotation angle.
static float[] getSkewMatrix(float angle, float[] rvec, float[] tvec)
          Like getSkewMatrix with null matrix argument
static float invert(float[] dest, float[] m)
          Inverts matrix m and returns the determinant of m.
static float invertTranspose(float[] dest, float[] m)
          Sets dest to the transpose of the inverted m matrix, and returns the determinant of m.
static float invertTransposeMat4f(float[] dest3x3, float[] m4x4)
          Sets dest to the 3x3 matrix that is the inverse-transpose of the rotation/scaling part of the 4x4 matrix m
static boolean isDiagonal(float[] m, float epsilon)
          Determines whether some 3 X 3 matrix is in diagonal form.
static boolean isIdentity(float[] m)
          Checks whether some matrix is actually the identity matrix.
static boolean isOrthogonal(float[] m, float epsilon)
          Checks for orthogonality of m.
static boolean isSymmetric(float[] m, float epsilon)
          Determines whether some 3 X 3 matrix is symmetric.
static boolean isZero(float[] m)
          Checks whether some matrix is actually the zero matrix.
static void mul(float[] dest, float[] m)
          Multiplies dest with m and stores the result in dest: dest = dest * m
static void mul(float[] dest, float[] a, float[] b)
          Multiplies a with b and stores the result in dest.
static void mul(float[] dest, int destIndex, float[] m, int mIndex)
          Multiplies dest with m and stores the result in dest: dest = dest * m
static void mul(float[] dest, int dIndex, float[] a, int aIndex, float[] b, int bIndex)
          Multiplies a with b and stores the result in dest.
static void mulTransposeRight(float[] dest, float[] a, float[] b)
          Multiplies a with b^T and stores the result in dest.
static void mulTransposeRight(float[] dest, int dstIndex, float[] a, int aIndex, float[] b, int bIndex)
          Multiplies a with b^T and stores the result in dest.
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 double polarDecompose(float[] m, float[] q, float[] s)
          Performs a polar decomposition of matrix M into factor Q and S: M = Q S Q is orthogonal, S is symmetric.
static Mat3f.ScalingType polarDecompose(float[] m, float[] q, float[] s, float epsilon)
          Deprecated. Restored for compatibility with Herwin's demos, do not remove
static void scale(float[] m, double s)
          Scales the matrix m by means of factor s.
static void scale(float[] m, float s)
          Scales the matrix m by means of factor s.
static void scale(float[] dst, float[] src, float s)
          Scales the matrix src by means of factor s, stores result in dst.
static void scale(float[] m, int iIndex, double s)
          Scales the matrix m by means of factor s.
static void scale(float[] m, int iIndex, float s)
          Scales the matrix m by means of factor s.
static void scale(float[] dst, int dstIndex, float[] src, int srcIndex, float s)
          Scales the matrix src by means of factor s, stores result in dst.
static void set(float[] dst, float[] src)
          Copies a 3X3 matrix src into matrix dst
static void set(float[] dst, float src00, float src01, float src02, float src10, float src11, float src12, float src20, float src21, float src22)
          Sets the matrix from 9 float values;
static void set(float[] dst, int dstIndex, float[] src, int srcIndex)
          Copies a 3X3 matrix src into matrix dst
static void set(float[] dst, int dIndex, float src00, float src01, float src02, float src10, float src11, float src12, float src20, float src21, float src22)
          Sets the matrix from 9 float values;
static void setDiagonal(float[] matrix3f, float[] vec3f)
          Sets the diagonal elements in a 3 X 3 matrix from a Vec3f array.
static void setElement(float[] m, int i, int j, float value)
          Sets the element m(i,j) from a (row-major) 3X3 matrix m to a specified float value.
static void setFromAxisAngleScale(float[] m, float[] aa, float scale)
          Sets a 3X3 matrix from a axis angle aa and scale factor.
static void setFromAxisAngleScale(float[] m, float[] axis, float angle, float scale)
          Sets a 3X3 matrix from an axis (float[3]), angle and scale factor.
static void setFromQuatScale(float[] m, float[] q, float s)
          Sets a 3X3 matrix from a unit quaternion and scale factor.
static void setFromQuatScale(float[] m, int mIndex, float[] q, int qIndex, float s)
          Sets a 3X3 matrix from a unit quaternion and scale factor.
static void setIdentity(float[] m)
          Resets the 3X3 matrix to the identity matrix.
static void setIdentity(float[] m, int index)
          Resets the 3X3 matrix to the identity matrix.
static void setRow(float[] m, int i, float[] row)
          Sets row i in the 3X3 matrix m.
static void setXRot(float[] m, float angle)
          Sets m to the rotation matrix of a rotation of angle around the x-axis.
static void setXRotDegrees(float[] m, float angle)
          Sets m to the rotation matrix of a rotation of angle degrees around the x-axis.
static void setYRot(float[] m, float angle)
          Sets m to the rotation matrix of a rotation of angle around the y-axis.
static void setYRotDegrees(float[] m, float angle)
          Sets m to the rotation matrix of a rotation of angle degrees around the y-axis.
static void setZero(float[] m)
          Resets the 3X3 matrix to zero
static void setZRot(float[] m, float angle)
          Sets m to the rotation matrix of a rotation of angle around the z-axis.
static void setZRotDegrees(float[] m, float angle)
          Sets m to the rotation matrix of a rotation of angle degrees around the z-axis.
static void skew(float[] m, float[] v)
          Sets the skew matrix 0 -vz vy vz 0 -vx -vy vx 0 from a vector
static void skew(float[] m, float vx, float vy, float vz)
          Sets the skew matrix 0 -vz vy vz 0 -vx -vy vx 0 from a vector
static void skew(float[] m, int mIndex, float[] v, int vIndex)
          Sets the skew matrix 0 -vz vy vz 0 -vx -vy vx 0 from a vector
static void smooth(float[] m, float eps)
          Matrix elements close to 0.0, 1.0, or -1.0 are rounded towards those values, provided the difference is less than eps
static void sub(float[] dest, float[] a)
          dest -= a
static void sub(float[] dest, float[] a, float[] b)
          dest = a-b
static void sub(float[] dest, int destIndex, float[] a, int aIndex)
          dest -= b
static void sub(float[] dest, int destIndex, float[] a, int aIndex, float[] b, int bIndex)
          dest = a-b
static String toString(float[] m)
           
static String toString(float[] m, int mIndex)
           
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 String toStringTabbed(float[] m, int tab)
          Produces a String representation of Mat3f matrix m, taking into account tab spaces at the beginning of every newline.
static String toStringTabbed(float[] m, int mIndex, int tab)
          Produces a String representation of Mat3f matrix m, taking into account tab spaces at the beginning of every newline.
static void transform(float[] m, float[] dst)
          Transforms a Vec3 vector dst, and puts the result back in vector dst.
static void transform(float[] m, float[] dest, float[] src)
          Transforms a Vec3 vector src, and puts the result in vector dest.
static void transform(float[] m, float[] dest, int destIndex, float srcx, float srcy, float srcz)
          Transforms a 3 float src, and puts the result in vector dest.
static void transform(float[] m, int mIndex, float[] dst, int dstIndex)
          Transforms a Vec3 vector dst, and puts the result back in vector dst.
static void transform(float[] m, int mIndex, float[] dest, int destIndex, float[] src, int srcIndex)
          Transforms a Vec3 vector src, and puts the result in vector dest.
static void transform(float[] m, int mIndex, float[] dest, int destIndex, float srcx, float srcy, float srcz)
          Transforms a 3 float src, and puts the result in vector dest.
static void transformTranspose(float[] m, float[] dst, float[] src)
          Transforms a Vec3 with the transpose of matrix m
static void transformTranspose(float[] m, int mIndex, float[] dst, int dstIndex, float[] src, int srcIndex)
          Transforms a Vec3 with the matrix transpose
static void transformVec3f(float[] m, float[] dest)
          Transforms a Vec3 vector dest in place
static void transformVec3f(float[] m, float[] dst, int destIndex)
          Transforms a Vec3 vector dest in place
static void transformVec3f(float[] m, int mIndex, float[] dest, int dIndex)
          Transforms a Vec3 vector dest in place
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
See Also:
Constant Field Values

COL_SIZE

public static final int COL_SIZE
See Also:
Constant Field Values

MAT3F_SIZE

public static final int MAT3F_SIZE
See Also:
Constant Field Values

DEGREEPERRAD

public static final double DEGREEPERRAD
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

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

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

NORMALIZE_THRESHOLD

private static final float NORMALIZE_THRESHOLD
See Also:
Constant Field Values

TOL

public static final float TOL
See Also:
Constant Field Values

POLARDECOMPOSESMOOTHFACTOR

private static final float POLARDECOMPOSESMOOTHFACTOR
See Also:
Constant Field Values

MINIMAL_SKEW_ANGLE

private static final float MINIMAL_SKEW_ANGLE
See Also:
Constant Field Values
Constructor Detail

Mat3f

private Mat3f()
Method Detail

getMat3f

public static float[] getMat3f()
Returns a new float[9] array with zero components


getScalingTypeVec3f

@Deprecated
public static Mat3f.ScalingType getScalingTypeVec3f(float[] scaleVec)
Deprecated. Restored for compatibility with Herwin's demos

Returns the scaling type for a vector of scale factors. This is one of ScalingType.IDENTITY, ScalingType.UNIFORM, or ScalingType.ALIGNED.


getScalingMatrix

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


scale

public static void scale(float[] m,
                         float s)
Scales the matrix m by means of factor s.


scale

public static void scale(float[] dst,
                         float[] src,
                         float s)
Scales the matrix src by means of factor s, stores result in dst.


scale

public static void scale(float[] dst,
                         int dstIndex,
                         float[] src,
                         int srcIndex,
                         float s)
Scales the matrix src by means of factor s, stores result in dst.


scale

public static void scale(float[] m,
                         int iIndex,
                         float s)
Scales the matrix m by means of factor s.


scale

public static void scale(float[] m,
                         int iIndex,
                         double s)
Scales the matrix m by means of factor s.


scale

public static void scale(float[] m,
                         double s)
Scales the matrix m by means of factor s.


set

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


set

public static void set(float[] dst,
                       float src00,
                       float src01,
                       float src02,
                       float src10,
                       float src11,
                       float src12,
                       float src20,
                       float src21,
                       float src22)
Sets the matrix from 9 float values;


set

public static void set(float[] dst,
                       int dIndex,
                       float src00,
                       float src01,
                       float src02,
                       float src10,
                       float src11,
                       float src12,
                       float src20,
                       float src21,
                       float src22)
Sets the matrix from 9 float values;


set

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


setXRot

public static void setXRot(float[] m,
                           float angle)
Sets m to the rotation matrix of a rotation of angle around the x-axis.


setXRotDegrees

public static void setXRotDegrees(float[] m,
                                  float angle)
Sets m to the rotation matrix of a rotation of angle degrees around the x-axis.


setYRot

public static void setYRot(float[] m,
                           float angle)
Sets m to the rotation matrix of a rotation of angle around the y-axis.


setYRotDegrees

public static void setYRotDegrees(float[] m,
                                  float angle)
Sets m to the rotation matrix of a rotation of angle degrees around the y-axis.


setZRot

public static void setZRot(float[] m,
                           float angle)
Sets m to the rotation matrix of a rotation of angle around the z-axis.


setZRotDegrees

public static void setZRotDegrees(float[] m,
                                  float angle)
Sets m to the rotation matrix of a rotation of angle degrees around the z-axis.


setFromQuatScale

public static void setFromQuatScale(float[] m,
                                    float[] q,
                                    float s)
Sets a 3X3 matrix from a unit quaternion and scale factor.


setFromQuatScale

public static void setFromQuatScale(float[] m,
                                    int mIndex,
                                    float[] q,
                                    int qIndex,
                                    float s)
Sets a 3X3 matrix from a unit quaternion and scale factor.


setFromAxisAngleScale

public static void setFromAxisAngleScale(float[] m,
                                         float[] axis,
                                         float angle,
                                         float scale)
Sets a 3X3 matrix from an axis (float[3]), angle and scale factor. The axis need not have length 1.


setFromAxisAngleScale

public static void setFromAxisAngleScale(float[] m,
                                         float[] aa,
                                         float scale)
Sets a 3X3 matrix from a axis angle aa and scale factor. The first three components of aa define the axis, the fouth one is the angle.


setZero

public static void setZero(float[] m)
Resets the 3X3 matrix to zero


setIdentity

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


setIdentity

public static void setIdentity(float[] m,
                               int index)
Resets the 3X3 matrix to the identity matrix.


getIdentity

public static float[] getIdentity()
Allocates a new 3X3 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) 3X3 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 3X3 matrix m.


getRow

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


setRow

public static void setRow(float[] m,
                          int i,
                          float[] row)
Sets row i in the 3X3 matrix m.


getColumn

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


mul

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


mulTransposeRight

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


mulTransposeRight

public static void mulTransposeRight(float[] dest,
                                     int dstIndex,
                                     float[] a,
                                     int aIndex,
                                     float[] b,
                                     int bIndex)
Multiplies a with b^T and stores the result in dest. The dest array is allowed to be aliased with a and/or b: dest = a * b^T


mul

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


mul

public static void mul(float[] dest,
                       float[] m)
Multiplies dest with m and stores the result in dest: dest = dest * m


mul

public static void mul(float[] dest,
                       int destIndex,
                       float[] m,
                       int mIndex)
Multiplies dest with m and stores the result in dest: dest = dest * m


transform

public static void transform(float[] m,
                             int mIndex,
                             float[] dest,
                             int destIndex,
                             float srcx,
                             float srcy,
                             float srcz)
Transforms a 3 float src, and puts the result in vector dest. The dst vector and matrix start at a offset, specified by destIndex and mIndex


transform

public static void transform(float[] m,
                             float[] dest,
                             int destIndex,
                             float srcx,
                             float srcy,
                             float srcz)
Transforms a 3 float src, and puts the result in vector dest. The dst vector starts at a offset, specified by destIndex


transform

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


transform

public static void transform(float[] m,
                             int mIndex,
                             float[] dst,
                             int dstIndex)
Transforms a Vec3 vector dst, and puts the result back in vector dst. The matrix, as well as the vector start at offsets, specified by mIndex, dstIndex,


transform

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


transform

public static void transform(float[] m,
                             float[] dst)
Transforms a Vec3 vector dst, and puts the result back in vector dst.


equals

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


epsilonEquals

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


epsilonEquals

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


transformTranspose

public static void transformTranspose(float[] m,
                                      float[] dst,
                                      float[] src)
Transforms a Vec3 with the transpose of matrix m


transformTranspose

public static void transformTranspose(float[] m,
                                      int mIndex,
                                      float[] dst,
                                      int dstIndex,
                                      float[] src,
                                      int srcIndex)
Transforms a Vec3 with the matrix transpose


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.


add

public static void add(float[] dest,
                       float[] a)
dest += a


sub

public static void sub(float[] dest,
                       float[] a)
dest -= a


add

public static void add(float[] dest,
                       int destIndex,
                       float[] a,
                       int aIndex)
dest += b


sub

public static void sub(float[] dest,
                       int destIndex,
                       float[] a,
                       int aIndex)
dest -= b


add

public static void add(float[] dest,
                       float[] a,
                       float[] b)
dest = a+b


sub

public static void sub(float[] dest,
                       float[] a,
                       float[] b)
dest = a-b


sub

public static void sub(float[] dest,
                       int destIndex,
                       float[] a,
                       int aIndex,
                       float[] b,
                       int bIndex)
dest = a-b


add

public static void add(float[] dest,
                       int destIndex,
                       float[] a,
                       int aIndex,
                       float[] b,
                       int bIndex)
dest = a+b


det

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


adjugateTranspose

public static float adjugateTranspose(float[] dest,
                                      float[] m)
Sets the dest matrix to the transpose of the adjugate (i.e "classical adjoint" matrix of m) It is always defined, even when m is not invertible. If m is invertible, i.e. det(m) != 0, then adjugate_transpose(m) = (transpose invert(m)) * det(m) Returns the determinant of m.


adjugateTransposeMat4f

protected static float adjugateTransposeMat4f(float[] dest,
                                              float[] m)
Sets the dest matrix to the transpose of the adjugate of the rotation/scaling 3x3 part of the 4x4 matrix m. Returns the determinant of the 3X3 matrix part


adjugate

public static float adjugate(float[] dest,
                             float[] m)
Sets the dest matrix to the adjugate (i.e "classical adjoint") matrix of m) It is always defined, even when m is not invertible. If m is invertible, i.e. det(m) != 0, then adjugate(m) = invert(m) * det(m) Return the determinant det(m)


invert

public static float invert(float[] dest,
                           float[] m)
Inverts matrix m and returns the determinant of m. If the latter is equal to zero, the adjugate is returned in dest, and zero is returned. Hint: Use the more efficient transpose method if the matrix is known to be orthogonal


invertTranspose

public static float invertTranspose(float[] dest,
                                    float[] m)
Sets dest to the transpose of the inverted m matrix, and returns the determinant of m. If the latter is equal to zero, the adjugate_transpose is returned in dest, and zero is returned. Hint: Use the more efficient transpose method if the matrix is known to be orthogonal


invertTransposeMat4f

public static float invertTransposeMat4f(float[] dest3x3,
                                         float[] m4x4)
Sets dest to the 3x3 matrix that is the inverse-transpose of the rotation/scaling part of the 4x4 matrix m


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.


from4x4

public static float[] from4x4(float[] m4x4)
Allocates a new 3 X 3 matrix, containing a copy of the upper-left 3 X 3 matrix from an 4 X 4 matrix.


convertTo3x3

public static void convertTo3x3(float[] m)
Converts a 4 X 4 matrix, stored in a length 16(!) float array m into a 3 X 3 matrix, by dropping the rightmost column, and the bottom row. This is done "in place", so m remains a length 16 float array, where the first 9 array elements now contain the Mat3f matrix.


isDiagonal

public static boolean isDiagonal(float[] m,
                                 float epsilon)
Determines whether some 3 X 3 matrix is in diagonal form. By definition, this is the case when all off-diagonal elements have absolute value less than epsilon


getDiagonal

public static void getDiagonal(float[] matrix3f,
                               float[] vec3f)
Returns the diagonal in a Vec3f array


setDiagonal

public static void setDiagonal(float[] matrix3f,
                               float[] vec3f)
Sets the diagonal elements in a 3 X 3 matrix from a Vec3f array. The remaining matrix elements are not modified.


isSymmetric

public static boolean isSymmetric(float[] m,
                                  float epsilon)
Determines whether some 3 X 3 matrix is symmetric. By definition, this is the case when Math.abs (mij - mji) < epsilon, for all i != j


isOrthogonal

public static boolean isOrthogonal(float[] m,
                                   float epsilon)
Checks for orthogonality of m. 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.


polarDecompose

public static double polarDecompose(float[] m,
                                    float[] q,
                                    float[] s)
Performs a polar decomposition of matrix M into factor Q and S: M = Q S Q is orthogonal, S is symmetric. In essence, Q is the rotation part, S is the scaling matrix. Note that the latter can scale along axes that are not aligned with the x-y-z axes, in which case S is also called skewing or shearing. Returns the determinant of Q. Remark: when M has det < 0, Q will be orthogonal with det = -1, so it will include a reflection.


polarDecompose

@Deprecated
public static Mat3f.ScalingType polarDecompose(float[] m,
                                                          float[] q,
                                                          float[] s,
                                                          float epsilon)
Deprecated. Restored for compatibility with Herwin's demos, do not remove

Performs a polar decomposition of matrix M into factor Q and S: M = Q S Q is orthogonal, S is symmetric. In essence, Q is the rotation part, S is the scaling matrix. Note that the latter can scale along axes that are not aligned with the x-y-z axes, in which case S is also called skewing or shearing. Returns the scaling type. The epsilon parameter determines the threshold for smoothing the scaling matrix.


smooth

public static void smooth(float[] m,
                          float eps)
Matrix elements close to 0.0, 1.0, or -1.0 are rounded towards those values, provided the difference is less than eps


getScalingType

public static Mat3f.ScalingType getScalingType(float[] m)
Determines the scaling type of a matrix The type is SKEW if there are any non-zero off-diagonal elements. (This could incorporate a reflection) If non-SKEW, the type is REFLECTION if the determinant is -1


skew

public static void skew(float[] m,
                        float[] v)
Sets the skew matrix 0 -vz vy vz 0 -vx -vy vx 0 from a vector


skew

public static void skew(float[] m,
                        float vx,
                        float vy,
                        float vz)
Sets the skew matrix 0 -vz vy vz 0 -vx -vy vx 0 from a vector


skew

public static void skew(float[] m,
                        int mIndex,
                        float[] v,
                        int vIndex)
Sets the skew matrix 0 -vz vy vz 0 -vx -vy vx 0 from a vector


getSkewMatrix

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


getSkewMatrix

public static float[] getSkewMatrix(float[] matrix,
                                    float angle,
                                    float[] rvec,
                                    float[] tvec)
Allocates a new skew/shear matrix, specified in Renderman style, by means of a translation 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 float array, with length at least 9, or it can be null, in which case a Mat3f float array will be allocated. It is filled with the resulting skewing matrix, and returned


transformVec3f

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


transformVec3f

public static void transformVec3f(float[] m,
                                  float[] dst,
                                  int destIndex)
Transforms a Vec3 vector dest in place


transformVec3f

public static void transformVec3f(float[] m,
                                  int mIndex,
                                  float[] dest,
                                  int dIndex)
Transforms a Vec3 vector dest in place


toString

public static String toString(float[] m)

toString

public static String toString(float[] m,
                              int mIndex)

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.


toStringTabbed

public static String toStringTabbed(float[] m,
                                    int tab)
Produces a String representation of Mat3f 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.

Parameters:
m - the Mat3f
amount - of spaces before every line

toStringTabbed

public static String toStringTabbed(float[] m,
                                    int mIndex,
                                    int tab)
Produces a String representation of Mat3f 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.

Parameters:
m - the Mat3f
amount - of spaces before every line