de.javagl.swogl
Class MatrixUtils

java.lang.Object
  extended by de.javagl.swogl.MatrixUtils

public class MatrixUtils
extends java.lang.Object

Matrix utility methods


Method Summary
static javax.vecmath.Matrix4f identity()
          Creates and returns an identity matrix
static javax.vecmath.Matrix4f mul(javax.vecmath.Matrix4f... matrices)
          Returns the product of the given matrices
static javax.vecmath.Matrix4f rotate(javax.vecmath.Vector3f axis, double angleRad)
          Creates a matrix that describes a rotation of the given angle around the given axis
static javax.vecmath.Matrix4f rotateX(double angleRad)
          Creates and returns a rotation matrix.
static javax.vecmath.Matrix4f rotateY(double angleRad)
          Creates and returns a rotation matrix.
static javax.vecmath.Matrix4f rotateZ(double angleRad)
          Creates and returns a rotation matrix.
static javax.vecmath.Matrix4f scale(float s)
          Creates and returns a scaling matrix.
static javax.vecmath.Matrix4f scale(float x, float y, float z)
          Creates and returns a scaling matrix
static javax.vecmath.Matrix4f translate(float dx, float dy, float dz)
          Creates and returns a translation matrix.
static javax.vecmath.Matrix4f translate(javax.vecmath.Tuple3f t)
          Creates and returns a translation matrix.
static javax.vecmath.Matrix4f writeBufferToMatrix(java.nio.FloatBuffer buffer, javax.vecmath.Matrix4f matrix)
          Write the contents of the given buffer into the given matrix in column-major order and returns it.
static java.nio.FloatBuffer writeMatrixToBuffer(javax.vecmath.Matrix4f matrix, java.nio.FloatBuffer buffer)
          Write the contents of the given matrix into the given buffer in column-major order and returns it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

scale

public static javax.vecmath.Matrix4f scale(float s)
Creates and returns a scaling matrix.

Parameters:
s - The scaling
Returns:
The matrix

scale

public static javax.vecmath.Matrix4f scale(float x,
                                           float y,
                                           float z)
Creates and returns a scaling matrix

Parameters:
x - Scaling in x-direction
y - Scaling in y-direction
z - Scaling in z-direction
Returns:
A matrix describing the specified scaling

rotateX

public static javax.vecmath.Matrix4f rotateX(double angleRad)
Creates and returns a rotation matrix.

Parameters:
angleRad - The angle
Returns:
The matrix

rotateY

public static javax.vecmath.Matrix4f rotateY(double angleRad)
Creates and returns a rotation matrix.

Parameters:
angleRad - The angle
Returns:
The matrix

rotateZ

public static javax.vecmath.Matrix4f rotateZ(double angleRad)
Creates and returns a rotation matrix.

Parameters:
angleRad - The angle
Returns:
The matrix

rotate

public static javax.vecmath.Matrix4f rotate(javax.vecmath.Vector3f axis,
                                            double angleRad)
Creates a matrix that describes a rotation of the given angle around the given axis

Parameters:
axis - The axis of rotation
angleRad - The rotation angle, in radians
Returns:
The resulting rotation matrix

translate

public static javax.vecmath.Matrix4f translate(javax.vecmath.Tuple3f t)
Creates and returns a translation matrix.

Parameters:
t - The translation
Returns:
The matrix

translate

public static javax.vecmath.Matrix4f translate(float dx,
                                               float dy,
                                               float dz)
Creates and returns a translation matrix.

Parameters:
dx - The x-translation
dy - The y-translation
dz - The z-translation
Returns:
The matrix

identity

public static javax.vecmath.Matrix4f identity()
Creates and returns an identity matrix

Returns:
An identity matrix

mul

public static javax.vecmath.Matrix4f mul(javax.vecmath.Matrix4f... matrices)
Returns the product of the given matrices

Parameters:
matrices - The matrices
Returns:
The product of the matrices

writeMatrixToBuffer

public static java.nio.FloatBuffer writeMatrixToBuffer(javax.vecmath.Matrix4f matrix,
                                                       java.nio.FloatBuffer buffer)
Write the contents of the given matrix into the given buffer in column-major order and returns it. It is assumed that the given buffer has enough space for the matrix. If the given buffer is null, a new direct buffer will be created and returned.

Parameters:
matrix - The matrix
buffer - The buffer to write to
Returns:
The given buffer, now containing the matrix data

writeBufferToMatrix

public static javax.vecmath.Matrix4f writeBufferToMatrix(java.nio.FloatBuffer buffer,
                                                         javax.vecmath.Matrix4f matrix)
Write the contents of the given buffer into the given matrix in column-major order and returns it. It is assumed that the given buffer has enough remaining data to fill the matrix. If the given matrix is null, a new matrix is created and returned.

Parameters:
buffer - The buffer to read from
matrix - The matrix to fill
Returns:
The given matrix, now containing the buffer data