gnu.gleem.linalg
Class Mat2f

java.lang.Object
  |
  +--gnu.gleem.linalg.Mat2f

public class Mat2f
extends java.lang.Object

2x2 matrix class useful for simple linear algebra. Representation is (as Mat4f) in row major order and assumes multiplication by column vectors on the right.


Constructor Summary
Mat2f()
          Creates new matrix initialized to the zero matrix
 
Method Summary
 float determinant()
          Return the determinant.
 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
 boolean invert()
          Full matrix inversion in place.
 void makeIdent()
          Initialize to the identity matrix.
 Mat2f mul(Mat2f b)
          Returns this * b; creates new matrix
 void mul(Mat2f a, Mat2f 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 setCol(int i, Vec2f v)
          Set column i (i=[0..1]) to vector v.
 void setRow(int i, Vec2f v)
          Set row i (i=[0..1]) to vector v.
 Matf toMatf()
           
 java.lang.String toString()
           
 void transpose()
          Transpose this matrix in place.
 void xformVec(Vec2f src, Vec2f dest)
          Multiply a 2D vector by this matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Mat2f

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

Method Detail

makeIdent

public void makeIdent()
Initialize to the identity matrix.


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


setCol

public void setCol(int i,
                   Vec2f v)
Set column i (i=[0..1]) to vector v.


setRow

public void setRow(int i,
                   Vec2f v)
Set row i (i=[0..1]) to vector v.


transpose

public void transpose()
Transpose this matrix in place.


determinant

public float determinant()
Return the determinant.


invert

public boolean invert()
Full matrix inversion in place. If matrix is singular, returns false and matrix contents are untouched. If you know the matrix is orthonormal, you can call transpose() instead.


xformVec

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


mul

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


mul

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


toMatf

public Matf toMatf()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object