jglcore
Class JGL_3DMatrix

java.lang.Object
  extended by jglcore.JGL_3DMatrix

public final class JGL_3DMatrix
extends java.lang.Object

4x4 Matrix used for 3D Transformations. Supports rotations (quaternions and Euler angles), translations, scales, left and right multiplication, determinant compute, inversion.

Author:
Nicolas Devere

Field Summary
 float[] mat
          float array containing the matrix values
 
Constructor Summary
JGL_3DMatrix()
          Constructs an identity matrix.
JGL_3DMatrix(JGL_3DMatrix m)
          Constructs a matrix with same values than the specified matrix.
 
Method Summary
 void assign(JGL_3DMatrix m)
          Assigns values of the specified matrix to this matrix.
 float determinant()
          Returns the matrix's determinant.
 void identity()
          Resets the matrix to identity.
 void invert()
          Inverts the matrix.
 void multiplyLeft(JGL_3DMatrix m)
          Left-multiplies this matrix by the specified matrix.
 void multiplyRight(JGL_3DMatrix m)
          Right-multiplies this matrix by the specified matrix.
 void rotate(float angle, float x, float y, float z)
          Applies a rotation (in degrees) to the matrix around the specified axis.
 void rotate(float angleX, float angleY, float angleZ, int order)
          Applies a rotation to the matrix with the specified Euler angles, in the chosen order (the angles order is given by constants from the JGL class.
 void scale(float x, float y, float z)
          Applies a scale transformation on 3 axis to the matrix.
 void translate(float x, float y, float z)
          Applies a translation to the matrix.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mat

public float[] mat
float array containing the matrix values

Constructor Detail

JGL_3DMatrix

public JGL_3DMatrix()
Constructs an identity matrix.


JGL_3DMatrix

public JGL_3DMatrix(JGL_3DMatrix m)
Constructs a matrix with same values than the specified matrix.

Parameters:
m - : the matrix to copy
Method Detail

assign

public void assign(JGL_3DMatrix m)
Assigns values of the specified matrix to this matrix.

Parameters:
m - : the matrix to assign

identity

public void identity()
Resets the matrix to identity.


translate

public void translate(float x,
                      float y,
                      float z)
Applies a translation to the matrix.

Parameters:
x - : the X axis translation value
y - : the Y axis translation value
z - : the Z axis translation value

rotate

public void rotate(float angle,
                   float x,
                   float y,
                   float z)
Applies a rotation (in degrees) to the matrix around the specified axis.

Parameters:
angle - : the rotation angle (in degrees)
x - : the rotation axis's X value
y - : the rotation axis's Y value
z - : the rotation axis's Z value

rotate

public void rotate(float angleX,
                   float angleY,
                   float angleZ,
                   int order)
Applies a rotation to the matrix with the specified Euler angles, in the chosen order (the angles order is given by constants from the JGL class. Ex : JGL.ZXY means that the matrix is rotated around Z, then X, then Y).

Parameters:
angleX - : the rotation angle around the X axis
angleY - : the rotation angle around the Y axis
angleZ - : the rotation angle around the Z axis
order - : the 3 axis rotations order

scale

public void scale(float x,
                  float y,
                  float z)
Applies a scale transformation on 3 axis to the matrix.

Parameters:
x - : the X axis scale value
y - : the Y axis scale value
z - : the Z axis scale value

multiplyRight

public void multiplyRight(JGL_3DMatrix m)
Right-multiplies this matrix by the specified matrix.

Parameters:
m - : the matrix to multiply

multiplyLeft

public void multiplyLeft(JGL_3DMatrix m)
Left-multiplies this matrix by the specified matrix.

Parameters:
m - : the matrix to multiply

determinant

public float determinant()
Returns the matrix's determinant.

Returns:
the matrix's determinant

invert

public void invert()
Inverts the matrix.