glmodel
Class GL_Matrix

java.lang.Object
  extended by glmodel.GL_Matrix

public class GL_Matrix
extends java.lang.Object

Define a 4x4 matrix, and provide functions to create common matrices for 3D operations, such as rotate, scale and translate.


Field Summary
 float m00
           
 float m01
           
 float m02
           
 float m03
           
 float m10
           
 float m11
           
 float m12
           
 float m13
           
 float m20
           
 float m21
           
 float m22
           
 float m23
           
 float m30
           
 float m31
           
 float m32
           
 float m33
           
 
Constructor Summary
GL_Matrix()
          Default to the identity matrix
GL_Matrix(GL_Vector right, GL_Vector up, GL_Vector forward)
          Create a matrix with the three given axes
 
Method Summary
static void createBillboardMatrix(java.nio.FloatBuffer matrix, GL_Vector right, GL_Vector up, GL_Vector look, GL_Vector pos)
          vCreate the billboard matrix: a rotation matrix created from an arbitrary set of axis.
 float[][] exportToArray()
          return a two dimensional float array containing this Matrix
 GL_Matrix getClone()
          return a copy of this matrix
 void importFromArray(float[][] data)
          copy a two dimensional float array into this Matrix
 GL_Matrix inverse()
          return the inverse of this matrix
static GL_Matrix multiply(GL_Matrix m1, GL_Matrix m2)
          Multiply the two matrices.
 void preTransform(GL_Matrix n)
          transforms this matrix by matrix n from right (this=this x n)
 void reset()
          reset to the identity matrix
 void rotate(float dx, float dy, float dz)
           
static GL_Matrix rotateMatrix(float dx, float dy, float dz)
          create a rotation matrix
 void rotateSelf(float dx, float dy, float dz)
           
 void scale(float d)
           
 void scale(float dx, float dy, float dz)
           
static GL_Matrix scaleMatrix(float d)
          create a Matrix to scale all axes equally
static GL_Matrix scaleMatrix(float dx, float dy, float dz)
          create a Matrix to change scale
 void scaleSelf(float d)
           
 void scaleSelf(float dx, float dy, float dz)
           
 java.lang.String toString()
          return a string representation of this matrix
 void transform(GL_Matrix n)
          transforms this matrix by matrix n from left (this=n x this)
 GL_Vector transform(GL_Vector v)
          Transform the given vector using this matrix.
 void translate(float dx, float dy, float dz)
           
static GL_Matrix translateMatrix(float dx, float dy, float dz)
          create a Matrix shifted by the given amounts
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m00

public float m00

m01

public float m01

m02

public float m02

m03

public float m03

m10

public float m10

m11

public float m11

m12

public float m12

m13

public float m13

m20

public float m20

m21

public float m21

m22

public float m22

m23

public float m23

m30

public float m30

m31

public float m31

m32

public float m32

m33

public float m33
Constructor Detail

GL_Matrix

public GL_Matrix()
Default to the identity matrix


GL_Matrix

public GL_Matrix(GL_Vector right,
                 GL_Vector up,
                 GL_Vector forward)
Create a matrix with the three given axes

Method Detail

importFromArray

public void importFromArray(float[][] data)
copy a two dimensional float array into this Matrix


exportToArray

public float[][] exportToArray()
return a two dimensional float array containing this Matrix


translateMatrix

public static GL_Matrix translateMatrix(float dx,
                                        float dy,
                                        float dz)
create a Matrix shifted by the given amounts


scaleMatrix

public static GL_Matrix scaleMatrix(float dx,
                                    float dy,
                                    float dz)
create a Matrix to change scale


scaleMatrix

public static GL_Matrix scaleMatrix(float d)
create a Matrix to scale all axes equally


rotateMatrix

public static GL_Matrix rotateMatrix(float dx,
                                     float dy,
                                     float dz)
create a rotation matrix


translate

public void translate(float dx,
                      float dy,
                      float dz)

scale

public void scale(float dx,
                  float dy,
                  float dz)

scale

public void scale(float d)

rotate

public void rotate(float dx,
                   float dy,
                   float dz)

scaleSelf

public void scaleSelf(float dx,
                      float dy,
                      float dz)

scaleSelf

public void scaleSelf(float d)

rotateSelf

public void rotateSelf(float dx,
                       float dy,
                       float dz)

reset

public void reset()
reset to the identity matrix


transform

public GL_Vector transform(GL_Vector v)
Transform the given vector using this matrix. Return the transformed vector (the original vector is not modified).

Parameters:
v - GL_Vector to be transformed
Returns:
the transformed GL_Vector

transform

public void transform(GL_Matrix n)
transforms this matrix by matrix n from left (this=n x this)


preTransform

public void preTransform(GL_Matrix n)
transforms this matrix by matrix n from right (this=this x n)


multiply

public static GL_Matrix multiply(GL_Matrix m1,
                                 GL_Matrix m2)
Multiply the two matrices. Return m1 x m2


toString

public java.lang.String toString()
return a string representation of this matrix

Overrides:
toString in class java.lang.Object

getClone

public GL_Matrix getClone()
return a copy of this matrix


inverse

public GL_Matrix inverse()
return the inverse of this matrix


createBillboardMatrix

public static void createBillboardMatrix(java.nio.FloatBuffer matrix,
                                         GL_Vector right,
                                         GL_Vector up,
                                         GL_Vector look,
                                         GL_Vector pos)
vCreate the billboard matrix: a rotation matrix created from an arbitrary set of axis. Store those axis values in the first 3 columns of the matrix. Col 1 is the X axis, col 2 is the Y axis, and col 3 is the Z axis. We are rotating right into X, up into Y, and look into Z. The rotation matrix created from the rows will translate the arbitrary axis set to the global vaxis set. Lastly, OpenGl stores the matrices by columns, so enter the data into the array columns first. pos: position of billboard right, up, look: orientation of billboard x,y,z axes