org.openmali.vecmath2.util
Class MatrixUtils

java.lang.Object
  extended by org.openmali.vecmath2.util.MatrixUtils

public class MatrixUtils
extends java.lang.Object

Util class for Maths.


Constructor Summary
MatrixUtils()
           
 
Method Summary
static Matrix3f computeRotation(float v1x, float v1y, float v1z, float v2x, float v2y, float v2z, int normalize, Matrix3f result)
          Computes the rotation between the vectors v1 ans v2.
static Matrix3f computeRotation(Tuple3f v1, Tuple3f v2, int normalize, Matrix3f result)
          Computes the rotation between the vectors v1 ans v2.
static Matrix3f eulerToMatrix3f(float eulerX, float eulerY, float eulerZ)
          Converts Euler angles to a Matrix3f.
static void eulerToMatrix3f(float eulerX, float eulerY, float eulerZ, Matrix3f matrix)
          Converts Euler angles to a Matrix3f.
static Matrix3f eulerToMatrix3f(Tuple3f euler)
          Converts Euler angles to a Matrix3f.
static void eulerToMatrix3f(Tuple3f euler, Matrix3f matrix)
          Converts Euler angles to a Matrix3f.
static Matrix4f eulerToMatrix4f(float eulerX, float eulerY, float eulerZ)
          Converts Euler angles to a Matrix4f.
static void eulerToMatrix4f(float eulerX, float eulerY, float eulerZ, Matrix4f matrix)
          Converts Euler angles to a Matrix4f.
static Matrix4f eulerToMatrix4f(Tuple3f euler)
          Converts Euler angles to a Matrix4f.
static void eulerToMatrix4f(Tuple3f euler, Matrix4f matrix)
          Converts Euler angles to a Matrix4f.
static Matrix3f getRotationMatrix(float axisX, float axisY, float axisZ, float angle)
          Creates a 3x3 rotation matrix by a specified vector.
static void getRotationMatrix(float axisX, float axisY, float axisZ, float angle, Matrix3f out)
          Creates a 3x3 rotation matrix by a specified vector.
static Matrix3f getRotationMatrix(Tuple3f axis, float angle)
          Creates a 3x3 rotation matrix by a specified vector.
static void getRotationMatrix(Tuple3f axis, float angle, Matrix3f out)
          Creates a 3x3 rotation matrix by a specified vector.
static Matrix3f getRotationMatrixX(float angle)
          Creates a 3x3 rotation matrix by the x-axis.
static Matrix3f getRotationMatrixY(float angle)
          Creates a 3x3 rotation matrix by the y-axis.
static Matrix3f getRotationMatrixZ(float angle)
          Creates a 3x3 rotation matrix by the z-axis.
static Tuple3f matrixToEuler(Matrix3f matrix)
          Converts a Matrix3f to a Tuple3f with Euler angles.
static void matrixToEuler(Matrix3f matrix, Tuple3f euler)
          Converts a Matrix3f to a Tuple3f with Euler angles.
static Tuple3f matrixToEuler(Matrix4f matrix)
          Converts a Matrix4f to a Vector3f with Euler angles.
static void matrixToEuler(Matrix4f matrix, Tuple3f euler)
          Converts a Matrix4f to a Tuple3f with Euler angles.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatrixUtils

public MatrixUtils()
Method Detail

matrixToEuler

public static void matrixToEuler(Matrix3f matrix,
                                 Tuple3f euler)
Converts a Matrix3f to a Tuple3f with Euler angles.

Parameters:
matrix - the Matrix3f to be converted

matrixToEuler

public static Tuple3f matrixToEuler(Matrix3f matrix)
Converts a Matrix3f to a Tuple3f with Euler angles.

Parameters:
matrix - the Matrix3f to be converted
Returns:
the Vector3f containing the euler angles

matrixToEuler

public static void matrixToEuler(Matrix4f matrix,
                                 Tuple3f euler)
Converts a Matrix4f to a Tuple3f with Euler angles.

Parameters:
matrix - the Matrix4f to be converted

matrixToEuler

public static Tuple3f matrixToEuler(Matrix4f matrix)
Converts a Matrix4f to a Vector3f with Euler angles.

Parameters:
matrix - the Matrix4f to be converted
Returns:
the Tuple3f containing the euler angles

eulerToMatrix3f

public static void eulerToMatrix3f(float eulerX,
                                   float eulerY,
                                   float eulerZ,
                                   Matrix3f matrix)
Converts Euler angles to a Matrix3f.

Parameters:
eulerX - the x-Euler-angle
eulerY - the y-Euler-angle
eulerZ - the z-Euler-angle
matrix - the Matrix3f instance to write rotational values to

eulerToMatrix3f

public static void eulerToMatrix3f(Tuple3f euler,
                                   Matrix3f matrix)
Converts Euler angles to a Matrix3f.

Parameters:
euler - the Tuple3f containing all three Euler angles
matrix - the Matrix3f instance to write rotational values to

eulerToMatrix3f

public static Matrix3f eulerToMatrix3f(float eulerX,
                                       float eulerY,
                                       float eulerZ)
Converts Euler angles to a Matrix3f.

Parameters:
eulerX - the x-Euler-angle
eulerY - the y-Euler-angle
eulerZ - the z-Euler-angle
Returns:
the new Matrix3f instance reflecting the rotation

eulerToMatrix3f

public static Matrix3f eulerToMatrix3f(Tuple3f euler)
Converts Euler angles to a Matrix3f.

Parameters:
euler - the Tuple3f containing all three Euler angles
Returns:
the new Matrix3f instance reflecting the rotation

eulerToMatrix4f

public static void eulerToMatrix4f(float eulerX,
                                   float eulerY,
                                   float eulerZ,
                                   Matrix4f matrix)
Converts Euler angles to a Matrix4f.

Parameters:
eulerX - the x-Euler-angle
eulerY - the y-Euler-angle
eulerZ - the z-Euler-angle
matrix - the Matrix4f instance to write rotational values to

eulerToMatrix4f

public static void eulerToMatrix4f(Tuple3f euler,
                                   Matrix4f matrix)
Converts Euler angles to a Matrix4f.

Parameters:
euler - the Tuple3f containing all three Euler angles
matrix - the Matrix4f instance to write rotational values to

eulerToMatrix4f

public static Matrix4f eulerToMatrix4f(Tuple3f euler)
Converts Euler angles to a Matrix4f.

Parameters:
euler - the Tuple3f containing all three Euler angles
Returns:
the new Matrix4f instance reflecting the rotation

eulerToMatrix4f

public static Matrix4f eulerToMatrix4f(float eulerX,
                                       float eulerY,
                                       float eulerZ)
Converts Euler angles to a Matrix4f.

Parameters:
eulerX - the x-Euler-angle
eulerY - the y-Euler-angle
eulerZ - the z-Euler-angle
Returns:
the new Matrix4f instance reflecting the rotation

getRotationMatrix

public static final void getRotationMatrix(float axisX,
                                           float axisY,
                                           float axisZ,
                                           float angle,
                                           Matrix3f out)
Creates a 3x3 rotation matrix by a specified vector.

Parameters:
axisX - the x-component of the vector (axis) to rotate about
axisY - the y-component of the vector (axis) to rotate about
axisZ - the z-component of the vector (axis) to rotate about
angle - the angle to rotate by
out - the Matrix3f to write the result to

getRotationMatrix

public static final Matrix3f getRotationMatrix(float axisX,
                                               float axisY,
                                               float axisZ,
                                               float angle)
Creates a 3x3 rotation matrix by a specified vector.

Parameters:
axisX - the vector (axis) to rotate around
axisY - the vector (axis) to rotate around
axisZ - the vector (axis) to rotate around
angle - the angle to rotate by
Returns:
the created 3x3 rotation matrix

getRotationMatrixX

public static final Matrix3f getRotationMatrixX(float angle)
Creates a 3x3 rotation matrix by the x-axis.

Parameters:
angle - the angle to rotate by
Returns:
the created 3x3 rotation matrix

getRotationMatrixY

public static final Matrix3f getRotationMatrixY(float angle)
Creates a 3x3 rotation matrix by the y-axis.

Parameters:
angle - the angle to rotate by
Returns:
the created 3x3 rotation matrix

getRotationMatrixZ

public static final Matrix3f getRotationMatrixZ(float angle)
Creates a 3x3 rotation matrix by the z-axis.

Parameters:
angle - the angle to rotate by
Returns:
the created 3x3 rotation matrix

getRotationMatrix

public static void getRotationMatrix(Tuple3f axis,
                                     float angle,
                                     Matrix3f out)
Creates a 3x3 rotation matrix by a specified vector.

Parameters:
axis - Rotation axis
angle - the angle to rotate by
out - the Matrix3f to write the result to

getRotationMatrix

public static Matrix3f getRotationMatrix(Tuple3f axis,
                                         float angle)
Creates a 3x3 rotation matrix by a specified vector.

Parameters:
axis - Rotation axis
angle - the angle to rotate by
Returns:
the created 3x3 rotation matrix

computeRotation

public static final Matrix3f computeRotation(float v1x,
                                             float v1y,
                                             float v1z,
                                             float v2x,
                                             float v2y,
                                             float v2z,
                                             int normalize,
                                             Matrix3f result)
Computes the rotation between the vectors v1 ans v2.

Parameters:
v1x - the first vector
v1y - the first vector
v1z - the first vector
v2x - the second vector
v2y - the second vector
v2z - the second vector
normalize - normalize input vectors (bitmask)
result - the result object
Returns:
the result object back again

computeRotation

public static final Matrix3f computeRotation(Tuple3f v1,
                                             Tuple3f v2,
                                             int normalize,
                                             Matrix3f result)
Computes the rotation between the vectors v1 ans v2.

Parameters:
v1 - the first vector
v2 - the second vector
normalize - normalize input vectors (bitmask)
result - the result object
Returns:
the result object back again