Scripting API

Home Scripting API Index Class Overview

nlvm.math3d

Class Matrix4x4f


public final class Matrix4x4f
extends Object

Represents a 4x4 matrix using floats. Objects of this class are mutable

Field Summary

static final int a1
Element index of first row, first column
static final int a2
Element index of first row, second column
static final int a3
Element index of first row, third column
static final int a4
Element index of first row, fourth column
static final int b1
Element index of second row, first column
static final int b2
Element index of second row, second column
static final int b3
Element index of second row, third column
static final int b4
Element index of second row, fourth column
static final int c1
Element index of third row, first column
static final int c2
Element index of third row, second column
static final int c3
Element index of third row, third column
static final int c4
Element index of third row, fourth column
static final int d1
Element index of fourth row, first column
static final int d2
Element index of fourth row, second column
static final int d3
Element index of fourth row, third column
static final int d4
Element index of fourth row, fourth column


Constructor Summary

Matrix4x4f()
    Constructs a zero filled matrix
Matrix4x4f(Matrix4x4f m)
    Constructs a copy of m


Method Summary

Matrix4x4f dup()
  Creates a copy
float elemAt(int col, int row)
  Returns the matrix element at column and row
float[] elems()
  Returns the internal vector of matrix elements
bool equals(Object obj)
Vector3f getTrans()
  Returns the translation components into a new Vector3f
void getTrans(Vector3f v)
  Stores the translation components into v
void initIdentity()
  Initialzes using the identity matrix
void initMatrix(Matrix4x4f m)
  Initializes using a copy of m
void initScal(float x, float y, float z)
  Initialzes as a 3d scaling matrix
void initScal(Vector3f v)
  Initialzes as a 3d scaling matrix
void initTrans(float x, float y, float z)
  Initializes as a 3d translation matrix
void initTrans(Vector3f v)
  Initializes as a 3d translation matrix
void initXRot(float rad)
  Initialzes as a 3d rotation matrix around the x axis
void initYRot(float rad)
  Initialzes as a 3d rotation matrix around the y axis
void initZRot(float rad)
  Initialzes as a 3d rotation matrix around the z axis
void initZero()
  Initializes using zeros
bool invert()
  Inverts the matrix if it is non singular.
void multLeft(Matrix4x4f m)
  Does a left multiply with Matrix m and will save the result to itself.
void multRight(Matrix4x4f m)
  Does a right multiply with Matrix m and will save the result to itself.
void multVector(Vector4f in, Vector4f out)
  Will transform the in vector by the matrix and write the result to the out vector.
void multVector3Hg(Vector3f in, Vector3f out)
  Will transform the in vector by the first 3 rows of the matrix, assuming a virtual fourth component of the vector to be 1.
void multVector3x3(Vector3f in, Vector3f out)
  Will transform the in vector by the first 3 rows of the matrix, assuming a virtual fourth component of the Vector to be 0.
void setElemAt(int col, int row, float f)
  Sets the matrix element at column and row
String toString()


Field Detail


a1

public static final int a1

Element index of first row, first column


a2

public static final int a2

Element index of first row, second column


a3

public static final int a3

Element index of first row, third column


a4

public static final int a4

Element index of first row, fourth column


b1

public static final int b1

Element index of second row, first column


b2

public static final int b2

Element index of second row, second column


b3

public static final int b3

Element index of second row, third column


b4

public static final int b4

Element index of second row, fourth column


c1

public static final int c1

Element index of third row, first column


c2

public static final int c2

Element index of third row, second column


c3

public static final int c3

Element index of third row, third column


c4

public static final int c4

Element index of third row, fourth column


d1

public static final int d1

Element index of fourth row, first column


d2

public static final int d2

Element index of fourth row, second column


d3

public static final int d3

Element index of fourth row, third column


d4

public static final int d4

Element index of fourth row, fourth column


Constructor Detail


Matrix4x4f

public Matrix4x4f()

Constructs a zero filled matrix


Matrix4x4f

public Matrix4x4f(Matrix4x4f m)

Constructs a copy of m


Method Detail


dup

public final Matrix4x4f dup()

Creates a copy


elemAt

public final float elemAt(int col, int row)

Returns the matrix element at column and row


elems

public final float[] elems()

Returns the internal vector of matrix elements

The internal reference is returned, so changing the elements of the vector will change the matrix and vice versa. The constants a1,a2,a3 etc can be used to index specific elements of the matrix.

Returns:
    reference to internal vector of matrix elements (16)


equals

public bool equals(Object obj)


getTrans

public final Vector3f getTrans()

Returns the translation components into a new Vector3f


getTrans

public final void getTrans(Vector3f v)

Stores the translation components into v


initIdentity

public final void initIdentity()

Initialzes using the identity matrix


initMatrix

public final void initMatrix(Matrix4x4f m)

Initializes using a copy of m


initScal

public final void initScal(float x, float y, float z)

Initialzes as a 3d scaling matrix


initScal

public final void initScal(Vector3f v)

Initialzes as a 3d scaling matrix


initTrans

public final void initTrans(float x, float y, float z)

Initializes as a 3d translation matrix


initTrans

public final void initTrans(Vector3f v)

Initializes as a 3d translation matrix


initXRot

public final void initXRot(float rad)

Initialzes as a 3d rotation matrix around the x axis

Parameters:

rad - angle in radians

initYRot

public final void initYRot(float rad)

Initialzes as a 3d rotation matrix around the y axis

Parameters:

rad - angle in radians

initZRot

public final void initZRot(float rad)

Initialzes as a 3d rotation matrix around the z axis

Parameters:

rad - angle in radians

initZero

public final void initZero()

Initializes using zeros


invert

public final bool invert()

Inverts the matrix if it is non singular.

Returns false if the matrix is singular and cannot be inverted, otherwise true


multLeft

public final void multLeft(Matrix4x4f m)

Does a left multiply with Matrix m and will save the result to itself.

Pseudo Formula: this = m * this


multRight

public final void multRight(Matrix4x4f m)

Does a right multiply with Matrix m and will save the result to itself.

Pseudo Formula: this = this * m


multVector

public final void multVector(Vector4f in, Vector4f out)

Will transform the in vector by the matrix and write the result to the out vector.

Pseudo Formula: out = in.x * {m.a1, m.b1, m.c1, m.d1} + in.y * {m.a2, m.b2, m.c2, m.d2} + in.z * {m.a3, m.b3, m.c3, m.d3} + in.w * {m.a4, m.b4, m.c4, m.d4} out can be the same object as in


multVector3Hg

public final void multVector3Hg(Vector3f in, Vector3f out)

Will transform the in vector by the first 3 rows of the matrix, assuming a virtual fourth component of the vector to be 1.

Pseudo Formula: out = in.x * {m.a1, m.b1, m.c1} + in.y * {m.a2, m.b2, m.c2} + in.z * {m.a3, m.b3, m.c3} + {m.a4, m.b4, m.c4} out can be the same object as in


multVector3x3

public final void multVector3x3(Vector3f in, Vector3f out)

Will transform the in vector by the first 3 rows of the matrix, assuming a virtual fourth component of the Vector to be 0.

Pseudo Formula: out = in.x * {m.a1, m.b1, m.c1} + in.y * {m.a2, m.b2, m.c2} + in.z * {m.a3, m.b3, m.c3} out can be the same object as in


setElemAt

public final void setElemAt(int col, int row, float f)

Sets the matrix element at column and row


toString

public String toString()