Class Mat4
java.lang.Object
lol.trq.helios.math.Mat4
4x4 matrix operations on
float[16] arrays in OpenGL's column-major order: element (row r, column c) is at
m[c * 4 + r]. Every method writes into an output array; only multiply(float[], float[], float[]) with an aliased output
allocates (one temporary array). Outputs may alias inputs unless a method says otherwise.-
Method Summary
Modifier and TypeMethodDescriptionstatic float[]identity(float[] out) Sets the identity.static booleaninvert(float[] m, float[] out) Inverts a matrix.static float[]multiply(float[] a, float[] b, float[] out) Multipliesa * b: applying the result is applyingbfirst, thena.static float[]ortho(float left, float right, float bottom, float top, float near, float far, float[] out) An orthographic projection, asglOrtho.static float[]perspective(float fovYDegrees, float aspect, float near, float far, float[] out) A perspective projection, asgluPerspective.static float[]rotation(float degrees, float x, float y, float z, float[] out) A rotation about an axis, asglRotatef.static float[]transform(float[] m, double x, double y, double z, double w, float[] out) Transforms a point:m * (x, y, z, w).static float[]translation(float x, float y, float z, float[] out) A translation.
-
Method Details
-
identity
public static float[] identity(float[] out) Sets the identity.- Parameters:
out- the matrix- Returns:
out
-
multiply
public static float[] multiply(float[] a, float[] b, float[] out) Multipliesa * b: applying the result is applyingbfirst, thena.- Parameters:
a- the left matrixb- the right matrixout- receives the product; may beaorb- Returns:
out
-
perspective
public static float[] perspective(float fovYDegrees, float aspect, float near, float far, float[] out) A perspective projection, asgluPerspective.- Parameters:
fovYDegrees- vertical field of viewaspect- width over heightnear- near plane distance, positivefar- far plane distanceout- receives the matrix- Returns:
out
-
ortho
public static float[] ortho(float left, float right, float bottom, float top, float near, float far, float[] out) An orthographic projection, asglOrtho.- Parameters:
left- left planeright- right planebottom- bottom planetop- top planenear- near planefar- far planeout- receives the matrix- Returns:
out
-
translation
public static float[] translation(float x, float y, float z, float[] out) A translation.- Parameters:
x- x offsety- y offsetz- z offsetout- receives the matrix- Returns:
out
-
rotation
public static float[] rotation(float degrees, float x, float y, float z, float[] out) A rotation about an axis, asglRotatef.- Parameters:
degrees- the angle, counter-clockwise looking down the axisx- axis xy- axis yz- axis zout- receives the matrix- Returns:
out
-
transform
public static float[] transform(float[] m, double x, double y, double z, double w, float[] out) Transforms a point:m * (x, y, z, w).- Parameters:
m- the matrixx- xy- yz- zw- w, 1 for points and 0 for directionsout- receives the four components- Returns:
out
-
invert
public static boolean invert(float[] m, float[] out) Inverts a matrix.- Parameters:
m- the matrixout- receives the inverse; must not bem- Returns:
- false, leaving
outunspecified, when the matrix is singular
-