gnu.gleem.linalg Class Mat4f

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

public class Mat4f
extends java.lang.Object

A (very incomplete) 4x4 matrix class. Representation assumes multiplication by column vectors on the right.

 Constructor Summary Mat4f()           Creates new matrix initialized to the zero matrix

 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. 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 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() java.lang.String toString() void xformDir(Vec3f src, Vec3f dest)           Transforms src using only the upper left 3x3. 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

 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.

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.

mul

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

mul

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

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.

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.

toMatf

public Matf toMatf()

toString

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