net.java.joglutils.msg.math
Class Mat4f

java.lang.Object
  extended by net.java.joglutils.msg.math.Mat4f

public class Mat4f
extends Object

A (very incomplete) 4x4 matrix class. Representation assumes row-major order and multiplication by column vectors on the right.


Constructor Summary
Mat4f()
          Creates new matrix initialized to the zero matrix
Mat4f(Mat4f arg)
          Creates new matrix initialized to argument's contents
 
Method Summary
 float get(int i, int j)
          Gets the (i,j)th element of this matrix, where i is the row index and j is the column index
 void getColumnMajorData(float[] out)
          Copies data in column-major (OpenGL format) order into passed float array, which must have length 16 or greater.
 void getRotation(Rotf rot)
          Gets the upper left 3x3 of this matrix as a rotation.
 float[] getRowMajorData()
          Returns the matrix data in row-major format, which is the opposite of OpenGL's convention.
 void invert()
          Performs general 4x4 matrix inversion.
 void invertRigid()
          Inverts this matrix assuming that it represents a rigid transform (i.e., some combination of rotations and translations).
 void makeIdent()
          Sets this matrix to the identity matrix
 Mat4f mul(Mat4f b)
          Returns this * b; creates new matrix
 void mul(Mat4f a, Mat4f b)
          this = a * b
 void set(int i, int j, float val)
          Sets the (i,j)th element of this matrix, where i is the row index and j is the column index
 void set(Mat4f arg)
          Sets this matrix to be equivalent to the given one
 void setRotation(Rotf rot)
          Sets the rotation component of this matrix (i.e., the upper left 3x3) without touching any of the other parts of the matrix
 void setRotation(Vec3f x, Vec3f y, Vec3f z)
          Sets the upper-left 3x3 of this matrix assuming that the given x, y, and z vectors form an orthonormal basis
 void setScale(Vec3f scale)
          Sets the elements (0, 0), (1, 1), and (2, 2) with the appropriate elements of the given three-dimensional scale vector.
 void setTranslation(Vec3f trans)
          Sets the translation component of this matrix (i.e., the three top elements of the third column) without touching any of the other parts of the matrix
 Matf toMatf()
           
 String toString()
           
 void transpose()
          Transpose this matrix in place.
 void xformDir(Vec3f src, Vec3f dest)
          Transforms src using only the upper left 3x3.
 Line xformLine(Line line)
          Transforms the given line (origin plus direction) by this matrix.
 void xformPt(Vec3f src, Vec3f dest)
          Transforms a 3D vector as though it had a homogeneous coordinate and assuming that this matrix represents only rigid transformations; i.e., is not a full transformation.
 void xformVec(Vec4f src, Vec4f dest)
          Multiply a 4D vector by this matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Mat4f

public Mat4f()
Creates new matrix initialized to the zero matrix


Mat4f

public Mat4f(Mat4f arg)
Creates new matrix initialized to argument's contents

Method Detail

makeIdent

public void makeIdent()
Sets this matrix to the identity matrix


set

public void set(Mat4f arg)
Sets this matrix to be equivalent to the given one


get

public float get(int i,
                 int j)
Gets the (i,j)th element of this matrix, where i is the row index and j is the column index


set

public void set(int i,
                int j,
                float val)
Sets the (i,j)th element of this matrix, where i is the row index and j is the column index


setTranslation

public void setTranslation(Vec3f trans)
Sets the translation component of this matrix (i.e., the three top elements of the third column) without touching any of the other parts of the matrix


setRotation

public void setRotation(Rotf rot)
Sets the rotation component of this matrix (i.e., the upper left 3x3) without touching any of the other parts of the matrix


setRotation

public void setRotation(Vec3f x,
                        Vec3f y,
                        Vec3f z)
Sets the upper-left 3x3 of this matrix assuming that the given x, y, and z vectors form an orthonormal basis


getRotation

public void getRotation(Rotf rot)
Gets the upper left 3x3 of this matrix as a rotation. Currently does not work if there are scales. Ignores translation component.


setScale

public void setScale(Vec3f scale)
Sets the elements (0, 0), (1, 1), and (2, 2) with the appropriate elements of the given three-dimensional scale vector. Does not perform a full multiplication of the upper-left 3x3; use this with an identity matrix in conjunction with mul for that.


invertRigid

public void invertRigid()
Inverts this matrix assuming that it represents a rigid transform (i.e., some combination of rotations and translations). Assumes column vectors. Algorithm: transposes upper left 3x3; negates translation in rightmost column and transforms by inverted rotation.


invert

public void invert()
            throws SingularMatrixException
Performs general 4x4 matrix inversion.

Throws:
SingularMatrixException - if this matrix is singular (i.e., non-invertible)

mul

public Mat4f mul(Mat4f b)
Returns this * b; creates new matrix


mul

public void mul(Mat4f a,
                Mat4f b)
this = a * b


transpose

public void transpose()
Transpose this matrix in place.


xformVec

public void xformVec(Vec4f src,
                     Vec4f dest)
Multiply a 4D vector by this matrix. NOTE: src and dest must be different vectors.


xformPt

public void xformPt(Vec3f src,
                    Vec3f dest)
Transforms a 3D vector as though it had a homogeneous coordinate and assuming that this matrix represents only rigid transformations; i.e., is not a full transformation. NOTE: src and dest must be different vectors.


xformDir

public void xformDir(Vec3f src,
                     Vec3f dest)
Transforms src using only the upper left 3x3. NOTE: src and dest must be different vectors.


xformLine

public Line xformLine(Line line)
Transforms the given line (origin plus direction) by this matrix.


getColumnMajorData

public void getColumnMajorData(float[] out)
Copies data in column-major (OpenGL format) order into passed float array, which must have length 16 or greater.


getRowMajorData

public float[] getRowMajorData()
Returns the matrix data in row-major format, which is the opposite of OpenGL's convention.


toMatf

public Matf toMatf()

toString

public String toString()
Overrides:
toString in class Object