Package org.lwjgl.util.vector

# Class Matrix4f

java.lang.Object
org.lwjgl.util.vector.Matrix
org.lwjgl.util.vector.Matrix4f

All Implemented Interfaces:
  `Serializable`

public class Matrix4f extends Matrix implements Serializable
Holds a 4x4 float matrix.

Author:
  foo
See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`float`
`m00`
`float`
`m01`
`float`
`m02`
`float`
`m03`
`float`
`m10`
`float`
`m11`
`float`
`m12`
`float`
`m13`
`float`
`m20`
`float`
`m21`
`float`
`m22`
`float`
`m23`
`float`
`m30`
`float`
`m31`
`float`
`m32`
`float`
`m33`

## Constructor Summary

Constructors
Constructor
Description
`Matrix4f()`
Construct a new matrix, initialized to the identity.
`Matrix4f(Matrix4f src)`

## Method Summary

Modifier and Type
Method
Description
`static Matrix4f`
`add(Matrix4f left, Matrix4f right, Matrix4f dest)`
Add two matrices together and place the result in a third matrix.
`float`
`determinant()`
`Matrix`
`invert()`
Invert this matrix
`static Matrix4f`
`invert(Matrix4f src, Matrix4f dest)`
Invert the source matrix and put the result in the destination
`Matrix`
`load(FloatBuffer buf)`
Load from a float buffer.
`Matrix4f`
`load(Matrix4f src)`
Load from another matrix4f
`static Matrix4f`
`load(Matrix4f src, Matrix4f dest)`
Copy the source matrix to the destination matrix
`Matrix`
`loadTranspose(FloatBuffer buf)`
Load from a float buffer.
`static Matrix4f`
`mul(Matrix4f left, Matrix4f right, Matrix4f dest)`
Multiply the right matrix by the left and place the result in a third matrix.
`Matrix`
`negate()`
Negate this matrix
`Matrix4f`
`negate(Matrix4f dest)`
Negate this matrix and place the result in a destination matrix.
`static Matrix4f`
`negate(Matrix4f src, Matrix4f dest)`
Negate this matrix and place the result in a destination matrix.
`Matrix4f`
`rotate(float angle, Vector3f axis)`
Rotates the matrix around the given axis the specified angle
`Matrix4f`
`rotate(float angle, Vector3f axis, Matrix4f dest)`
Rotates the matrix around the given axis the specified angle
`static Matrix4f`
`rotate(float angle, Vector3f axis, Matrix4f src, Matrix4f dest)`
Rotates the source matrix around the given axis the specified angle and put the result in the destination matrix.
`Matrix4f`
`scale(Vector3f vec)`
Scales this matrix
`static Matrix4f`
`scale(Vector3f vec, Matrix4f src, Matrix4f dest)`
Scales the source matrix and put the result in the destination matrix
`Matrix`
`setIdentity()`
Set this matrix to be the identity matrix.
`static Matrix4f`
`setIdentity(Matrix4f m)`
Set the given matrix to be the identity matrix.
`Matrix`
`setZero()`
Set this matrix to 0.
`static Matrix4f`
`setZero(Matrix4f m)`
Set the given matrix to 0.
`Matrix`
`store(FloatBuffer buf)`
Store this matrix in a float buffer.
`Matrix`
`store3f(FloatBuffer buf)`
Store the rotation portion of this matrix in a float buffer.
`Matrix`
`storeTranspose(FloatBuffer buf)`
Store this matrix in a float buffer.
`static Matrix4f`
`sub(Matrix4f left, Matrix4f right, Matrix4f dest)`
Subtract the right matrix from the left and place the result in a third matrix.
`String`
`toString()`
Returns a string representation of this matrix
`static Vector4f`
`transform(Matrix4f left, Vector4f right, Vector4f dest)`
Transform a Vector by a matrix and return the result in a destination vector.
`Matrix4f`
`translate(Vector2f vec)`
Translate this matrix
`Matrix4f`
`translate(Vector2f vec, Matrix4f dest)`
Translate this matrix and stash the result in another matrix
`static Matrix4f`
`translate(Vector2f vec, Matrix4f src, Matrix4f dest)`
Translate the source matrix and stash the result in the destination matrix
`Matrix4f`
`translate(Vector3f vec)`
Translate this matrix
`Matrix4f`
`translate(Vector3f vec, Matrix4f dest)`
Translate this matrix and stash the result in another matrix
`static Matrix4f`
`translate(Vector3f vec, Matrix4f src, Matrix4f dest)`
Translate the source matrix and stash the result in the destination matrix
`Matrix`
`transpose()`
Transpose this matrix
`Matrix4f`
`transpose(Matrix4f dest)`
Transpose this matrix and place the result in another matrix
`static Matrix4f`
`transpose(Matrix4f src, Matrix4f dest)`
Transpose the source matrix and place the result in the destination matrix

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### m00

public float m00

### m01

public float m01

### m02

public float m02

### m03

public float m03

### m10

public float m10

### m11

public float m11

### m12

public float m12

### m13

public float m13

### m20

public float m20

### m21

public float m21

### m22

public float m22

### m23

public float m23

### m30

public float m30

### m31

public float m31

### m32

public float m32

### m33

public float m33

## Constructor Details

### Matrix4f

public Matrix4f()
Construct a new matrix, initialized to the identity.

### Matrix4f

public Matrix4f(Matrix4f src)

## Method Details

### toString

public String toString()
Returns a string representation of this matrix

Overrides:
  `toString` in class `Object`

### setIdentity

public Matrix setIdentity()
Set this matrix to be the identity matrix.

Specified by:
  `setIdentity` in class `Matrix`
Returns:
  this

### setIdentity

public static Matrix4f setIdentity(Matrix4f m)
Set the given matrix to be the identity matrix.

Parameters:
  `m` - The matrix to set to the identity
Returns:
  m

### setZero

public Matrix setZero()
Set this matrix to 0.

Specified by:
  `setZero` in class `Matrix`
Returns:
  this

### setZero

public static Matrix4f setZero(Matrix4f m)
Set the given matrix to 0.

Parameters:
  `m` - The matrix to set to 0
Returns:
  m

### load

public Matrix4f load(Matrix4f src)
Load from another matrix4f

Parameters:
  `src` - The source matrix
Returns:
  this

### load

public static Matrix4f load(Matrix4f src, Matrix4f dest)
Copy the source matrix to the destination matrix

Parameters:
  `src` - The source matrix
  `dest` - The destination matrix, or null of a new one is to be created
Returns:
  The copied matrix

### load

public Matrix load(FloatBuffer buf)
Load from a float buffer. The buffer stores the matrix in column major (OpenGL) order.

Specified by:
  `load` in class `Matrix`
Parameters:
  `buf` - A float buffer to read from
Returns:
  this

### loadTranspose

public Matrix loadTranspose(FloatBuffer buf)
Load from a float buffer. The buffer stores the matrix in row major (maths) order.

Specified by:
  `loadTranspose` in class `Matrix`
Parameters:
  `buf` - A float buffer to read from
Returns:
  this

### store

public Matrix store(FloatBuffer buf)
Store this matrix in a float buffer. The matrix is stored in column major (openGL) order.

Specified by:
  `store` in class `Matrix`
Parameters:
  `buf` - The buffer to store this matrix in
Returns:
  this

### storeTranspose

public Matrix storeTranspose(FloatBuffer buf)
Store this matrix in a float buffer. The matrix is stored in row major (maths) order.

Specified by:
  `storeTranspose` in class `Matrix`
Parameters:
  `buf` - The buffer to store this matrix in
Returns:
  this

### store3f

public Matrix store3f(FloatBuffer buf)
Store the rotation portion of this matrix in a float buffer. The matrix is stored in column major (openGL) order.

Parameters:
  `buf` - The buffer to store this matrix in

### add

public static Matrix4f add(Matrix4f left, Matrix4f right, Matrix4f dest)
Add two matrices together and place the result in a third matrix.

Parameters:
  `left` - The left source matrix
  `right` - The right source matrix
  `dest` - The destination matrix, or null if a new one is to be created
Returns:
  the destination matrix

### sub

public static Matrix4f sub(Matrix4f left, Matrix4f right, Matrix4f dest)
Subtract the right matrix from the left and place the result in a third matrix.

Parameters:
  `left` - The left source matrix
  `right` - The right source matrix
  `dest` - The destination matrix, or null if a new one is to be created
Returns:
  the destination matrix

### mul

public static Matrix4f mul(Matrix4f left, Matrix4f right, Matrix4f dest)
Multiply the right matrix by the left and place the result in a third matrix.

Parameters:
  `left` - The left source matrix
  `right` - The right source matrix
  `dest` - The destination matrix, or null if a new one is to be created
Returns:
  the destination matrix

### transform

public static Vector4f transform(Matrix4f left, Vector4f right, Vector4f dest)
Transform a Vector by a matrix and return the result in a destination vector.

Parameters:
  `left` - The left matrix
  `right` - The right vector
  `dest` - The destination vector, or null if a new one is to be created
Returns:
  the destination vector

### transpose

public Matrix transpose()
Transpose this matrix

Specified by:
  `transpose` in class `Matrix`
Returns:
  this

### translate

public Matrix4f translate(Vector2f vec)
Translate this matrix

Parameters:
  `vec` - The vector to translate by
Returns:
  this

### translate

public Matrix4f translate(Vector3f vec)
Translate this matrix

Parameters:
  `vec` - The vector to translate by
Returns:
  this

### scale

public Matrix4f scale(Vector3f vec)
Scales this matrix

Parameters:
  `vec` - The vector to scale by
Returns:
  this

### scale

public static Matrix4f scale(Vector3f vec, Matrix4f src, Matrix4f dest)
Scales the source matrix and put the result in the destination matrix

Parameters:
  `vec` - The vector to scale by
  `src` - The source matrix
  `dest` - The destination matrix, or null if a new matrix is to be created
Returns:
  The scaled matrix

### rotate

public Matrix4f rotate(float angle, Vector3f axis)
Rotates the matrix around the given axis the specified angle

Parameters:
  `angle` - the angle, in radians.
  `axis` - The vector representing the rotation axis. Must be normalized.
Returns:
  this

### rotate

public Matrix4f rotate(float angle, Vector3f axis, Matrix4f dest)
Rotates the matrix around the given axis the specified angle

Parameters:
  `angle` - the angle, in radians.
  `axis` - The vector representing the rotation axis. Must be normalized.
  `dest` - The matrix to put the result, or null if a new matrix is to be created
Returns:
  The rotated matrix

### rotate

public static Matrix4f rotate(float angle, Vector3f axis, Matrix4f src, Matrix4f dest)
Rotates the source matrix around the given axis the specified angle and put the result in the destination matrix.

Parameters:
  `angle` - the angle, in radians.
  `axis` - The vector representing the rotation axis. Must be normalized.
  `src` - The matrix to rotate
  `dest` - The matrix to put the result, or null if a new matrix is to be created
Returns:
  The rotated matrix

### translate

public Matrix4f translate(Vector3f vec, Matrix4f dest)
Translate this matrix and stash the result in another matrix

Parameters:
  `vec` - The vector to translate by
  `dest` - The destination matrix or null if a new matrix is to be created
Returns:
  the translated matrix

### translate

public static Matrix4f translate(Vector3f vec, Matrix4f src, Matrix4f dest)
Translate the source matrix and stash the result in the destination matrix

Parameters:
  `vec` - The vector to translate by
  `src` - The source matrix
  `dest` - The destination matrix or null if a new matrix is to be created
Returns:
  The translated matrix

### translate

public Matrix4f translate(Vector2f vec, Matrix4f dest)
Translate this matrix and stash the result in another matrix

Parameters:
  `vec` - The vector to translate by
  `dest` - The destination matrix or null if a new matrix is to be created
Returns:
  the translated matrix

### translate

public static Matrix4f translate(Vector2f vec, Matrix4f src, Matrix4f dest)
Translate the source matrix and stash the result in the destination matrix

Parameters:
  `vec` - The vector to translate by
  `src` - The source matrix
  `dest` - The destination matrix or null if a new matrix is to be created
Returns:
  The translated matrix

### transpose

public Matrix4f transpose(Matrix4f dest)
Transpose this matrix and place the result in another matrix

Parameters:
  `dest` - The destination matrix or null if a new matrix is to be created
Returns:
  the transposed matrix

### transpose

public static Matrix4f transpose(Matrix4f src, Matrix4f dest)
Transpose the source matrix and place the result in the destination matrix

Parameters:
  `src` - The source matrix
  `dest` - The destination matrix or null if a new matrix is to be created
Returns:
  the transposed matrix

### determinant

public float determinant()

Specified by:
  `determinant` in class `Matrix`
Returns:
  the determinant of the matrix

### invert

public Matrix invert()
Invert this matrix

Specified by:
  `invert` in class `Matrix`
Returns:
  this if successful, null otherwise

### invert

public static Matrix4f invert(Matrix4f src, Matrix4f dest)
Invert the source matrix and put the result in the destination

Parameters:
  `src` - The source matrix
  `dest` - The destination matrix, or null if a new matrix is to be created
Returns:
  The inverted matrix if successful, null otherwise

### negate

public Matrix negate()
Negate this matrix

Specified by:
  `negate` in class `Matrix`
Returns:
  this

### negate

public Matrix4f negate(Matrix4f dest)
Negate this matrix and place the result in a destination matrix.

Parameters:
  `dest` - The destination matrix, or null if a new matrix is to be created
Returns:
  the negated matrix

### negate

public static Matrix4f negate(Matrix4f src, Matrix4f dest)
Negate this matrix and place the result in a destination matrix.

Parameters:
  `src` - The source matrix
  `dest` - The destination matrix, or null if a new matrix is to be created
Returns:
  The negated matrix