JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
com.jogamp.math.Matrix4f Class Reference

Basic 4x4 float matrix implementation using fields for intensive use-cases (host operations). More...

Collaboration diagram for com.jogamp.math.Matrix4f:

Public Member Functions

 Matrix4f ()
 Creates a new identity matrix. More...
 
 Matrix4f (final Matrix4f src)
 Creates a new matrix copying the values of the given src matrix. More...
 
 Matrix4f (final float[] m)
 Creates a new matrix based on given float[4*4] column major order. More...
 
 Matrix4f (final float[] m, final int m_off)
 Creates a new matrix based on given float[4*4] column major order. More...
 
 Matrix4f (final FloatBuffer m)
 Creates a new matrix based on given FloatBuffer 4x4 column major order. More...
 
void set (final int i, final float v)
 Sets the ith component with float v 0 <= i < 16. More...
 
final Matrix4f loadIdentity ()
 Set this matrix to identity. More...
 
Matrix4f load (final Matrix4f src)
 Load the values of the given matrix src to this matrix. More...
 
Matrix4f load (final float[] src)
 Load the values of the given matrix src to this matrix. More...
 
Matrix4f load (final float[] src, final int src_off)
 Load the values of the given matrix src to this matrix. More...
 
Matrix4f load (final FloatBuffer src)
 Load the values of the given matrix src to this matrix. More...
 
float get (final int i)
 Gets the ith component, 0 <= i < 16. More...
 
Vec4f getColumn (final int column, final Vec4f v_out)
 Get the named column of the given column-major matrix to v_out. More...
 
Vec3f getColumn (final int column, final Vec3f v_out)
 Get the named column of the given column-major matrix to v_out. More...
 
Vec4f getRow (final int row, final Vec4f v_out)
 Get the named row of the given column-major matrix to v_out. More...
 
Vec3f getRow (final int row, final Vec3f v_out)
 Get the named row of the given column-major matrix to v_out. More...
 
float[] get (final float[] dst, final int dst_off)
 Get this matrix into the given float[16] array at dst_off in column major order. More...
 
float[] get (final float[] dst)
 Get this matrix into the given float[16] array in column major order. More...
 
FloatBuffer get (final FloatBuffer dst)
 Get this matrix into the given FloatBuffer in column major order. More...
 
float determinant ()
 Returns the determinant of this matrix. More...
 
final Matrix4f transpose ()
 Transpose this matrix. More...
 
final Matrix4f transpose (final Matrix4f src)
 Transpose the given src matrix into this matrix. More...
 
boolean invert ()
 Invert this matrix. More...
 
boolean invert (final Matrix4f src)
 Invert the src matrix values into this matrix. More...
 
final Matrix4f mul (final Matrix4f b)
 Multiply matrix: [this] = [this] x [b]. More...
 
final Matrix4f mul (final Matrix4f a, final Matrix4f b)
 Multiply matrix: [this] = [a] x [b]. More...
 
final Vec4f mulVec4f (final Vec4f v_in, final Vec4f v_out)
 
final Vec4f mulVec4f (final Vec4f v_inout)
 
final Vec3f mulVec3f (final Vec3f v_in, final Vec3f v_out)
 Affine 3f-vector transformation by 4x4 matrix. More...
 
final Vec3f mulVec3f (final Vec3f v_inout)
 Affine 3f-vector transformation by 4x4 matrix. More...
 
final Matrix4f setToTranslation (final float x, final float y, final float z)
 Set this matrix to translation. More...
 
final Matrix4f setToTranslation (final Vec3f t)
 Set this matrix to translation. More...
 
final Matrix4f setToScale (final float x, final float y, final float z)
 Set this matrix to scale. More...
 
final Matrix4f setToScale (final Vec3f s)
 Set this matrix to scale. More...
 
final Matrix4f setToRotationAxis (final float ang_rad, float x, float y, float z)
 Set this matrix to rotation from the given axis and angle in radians. More...
 
final Matrix4f setToRotationAxis (final float ang_rad, final Vec3f axis)
 Set this matrix to rotation from the given axis and angle in radians. More...
 
Matrix4f setToRotationEuler (final float bankX, final float headingY, final float attitudeZ)
 Set this matrix to rotation from the given Euler rotation angles in radians. More...
 
Matrix4f setToRotationEuler (final Vec3f angradXYZ)
 Set this matrix to rotation from the given Euler rotation angles in radians. More...
 
final Matrix4f setToRotation (final Quaternion q)
 Set this matrix to rotation using the given Quaternion. More...
 
final Quaternion getRotation (final Quaternion res)
 Returns the rotation [m00 . More...
 
Matrix4f setToOrtho (final float left, final float right, final float bottom, final float top, final float zNear, final float zFar)
 Set this matrix to orthogonal projection. More...
 
Matrix4f setToFrustum (final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) throws IllegalArgumentException
 Set this matrix to frustum. More...
 
Matrix4f setToPerspective (final float fovy_rad, final float aspect, final float zNear, final float zFar) throws IllegalArgumentException
 Set this matrix to perspective frustum projection. More...
 
Matrix4f setToPerspective (final FovHVHalves fovhv, final float zNear, final float zFar) throws IllegalArgumentException
 Set this matrix to perspective frustum projection. More...
 
Frustum getFrustum (final Frustum frustum)
 Calculate the frustum planes in world coordinates using this column major order matrix, usually a projection (P) or premultiplied P*MV matrix. More...
 
Matrix4f setToLookAt (final Vec3f eye, final Vec3f center, final Vec3f up, final Matrix4f tmp)
 Set this matrix to the look-at matrix based on given parameters. More...
 
Matrix4f setToPick (final float x, final float y, final float deltaX, final float deltaY, final Recti viewport, final Matrix4f mat4Tmp)
 Set this matrix to the pick matrix based on given parameters. More...
 
final Matrix4f rotate (final float ang_rad, final float x, final float y, final float z, final Matrix4f tmp)
 Rotate this matrix about give axis and angle in radians, i.e. More...
 
final Matrix4f rotate (final float ang_rad, final Vec3f axis, final Matrix4f tmp)
 Rotate this matrix about give axis and angle in radians, i.e. More...
 
final Matrix4f rotate (final Quaternion quat, final Matrix4f tmp)
 Rotate this matrix with the given Quaternion, i.e. More...
 
final Matrix4f translate (final float x, final float y, final float z, final Matrix4f tmp)
 Translate this matrix, i.e. More...
 
final Matrix4f translate (final Vec3f t, final Matrix4f tmp)
 Translate this matrix, i.e. More...
 
final Matrix4f scale (final float x, final float y, final float z, final Matrix4f tmp)
 Scale this matrix, i.e. More...
 
final Matrix4f scale (final float s, final Matrix4f tmp)
 Scale this matrix, i.e. More...
 
final void push ()
 Push the matrix to it's stack, while preserving this matrix values. More...
 
final void pop ()
 Pop the current matrix from it's stack, replacing this matrix values. More...
 
boolean isEqual (final Matrix4f o, final float epsilon)
 Equals check using a given FloatUtil#EPSILON value and FloatUtil#isEqual(float, float, float). More...
 
boolean isEqual (final Matrix4f o)
 Equals check using FloatUtil#EPSILON value and FloatUtil#isEqual(float, float, float). More...
 
boolean equals (final Object o)
 
StringBuilder toString (final StringBuilder sb, final String rowPrefix, final String f)
 
String toString ()
 

Static Public Member Functions

static boolean mapObjToWin (final Vec3f obj, final Matrix4f mMv, final Matrix4f mP, final Recti viewport, final Vec3f winPos)
 Map object coordinates to window coordinates. More...
 
static boolean mapObjToWin (final Vec3f obj, final Matrix4f mPMv, final Recti viewport, final Vec3f winPos)
 Map object coordinates to window coordinates. More...
 
static boolean mapWinToObj (final float winx, final float winy, final float winz, final Matrix4f mMv, final Matrix4f mP, final Recti viewport, final Vec3f objPos, final Matrix4f mat4Tmp)
 Map window coordinates to object coordinates. More...
 
static boolean mapWinToObj (final float winx, final float winy, final float winz, final Matrix4f invPMv, final Recti viewport, final Vec3f objPos)
 Map window coordinates to object coordinates. More...
 
static boolean mapWinToObj (final float winx, final float winy, final float winz1, final float winz2, final Matrix4f invPMv, final Recti viewport, final Vec3f objPos1, final Vec3f objPos2)
 Map two window coordinates to two object coordinates, distinguished by their z component. More...
 
static boolean mapWinToObj4 (final float winx, final float winy, final float winz, final float clipw, final Matrix4f mMv, final Matrix4f mP, final Recti viewport, final float near, final float far, final Vec4f objPos, final Matrix4f mat4Tmp)
 Map window coordinates to object coordinates. More...
 
static boolean mapWinToObj4 (final float winx, final float winy, final float winz, final float clipw, final Matrix4f invPMv, final Recti viewport, final float near, final float far, final Vec4f objPos)
 Map window coordinates to object coordinates. More...
 
static boolean mapWinToRay (final float winx, final float winy, final float winz0, final float winz1, final Matrix4f mMv, final Matrix4f mP, final Recti viewport, final Ray ray, final Matrix4f mat4Tmp1)
 Map two window coordinates w/ shared X/Y and distinctive Z to a Ray. More...
 
static boolean mapWinToRay (final float winx, final float winy, final float winz0, final float winz1, final Matrix4f invPMv, final Recti viewport, final Ray ray)
 Map two window coordinates w/ shared X/Y and distinctive Z to a Ray. More...
 

Detailed Description

Basic 4x4 float matrix implementation using fields for intensive use-cases (host operations).

Implementation covers FloatUtil matrix functionality, exposed in an object oriented manner.

Unlike PMVMatrix4f, this class only represents one single matrix.

For array operations the layout is expected in column-major order matching OpenGL's implementation, illustration:

 Row-Major                       Column-Major (OpenGL):

     |  0   1   2  tx |
     |                |
     |  4   5   6  ty |
 M = |                |
     |  8   9  10  tz |
     |                |
     | 12  13  14  15 |

        R   C                      R   C
      m[0*4+3] = tx;             m[0+4*3] = tx;
      m[1*4+3] = ty;             m[1+4*3] = ty;
      m[2*4+3] = tz;             m[2+4*3] = tz;

       RC (std subscript order)   RC (std subscript order)
      m03 = tx;                  m03 = tx;
      m13 = ty;                  m13 = ty;
      m23 = tz;                  m23 = tz;

Implementation utilizes unrolling of small vertices and matrices wherever possible while trying to access memory in a linear fashion for performance reasons, see:

See also
com.jogamp.math.util.PMVMatrix4f
FloatUtil

Definition at line 89 of file Matrix4f.java.

Constructor & Destructor Documentation

◆ Matrix4f() [1/5]

com.jogamp.math.Matrix4f.Matrix4f ( )

Creates a new identity matrix.

Definition at line 94 of file Matrix4f.java.

◆ Matrix4f() [2/5]

com.jogamp.math.Matrix4f.Matrix4f ( final Matrix4f  src)

Creates a new matrix copying the values of the given src matrix.

Definition at line 102 of file Matrix4f.java.

Here is the call graph for this function:

◆ Matrix4f() [3/5]

com.jogamp.math.Matrix4f.Matrix4f ( final float[]  m)

Creates a new matrix based on given float[4*4] column major order.

Parameters
m4x4 matrix in column-major order

Definition at line 110 of file Matrix4f.java.

Here is the call graph for this function:

◆ Matrix4f() [4/5]

com.jogamp.math.Matrix4f.Matrix4f ( final float[]  m,
final int  m_off 
)

Creates a new matrix based on given float[4*4] column major order.

Parameters
m4x4 matrix in column-major order
m_offoffset for matrix m

Definition at line 119 of file Matrix4f.java.

Here is the call graph for this function:

◆ Matrix4f() [5/5]

com.jogamp.math.Matrix4f.Matrix4f ( final FloatBuffer  m)

Creates a new matrix based on given FloatBuffer 4x4 column major order.

Parameters
m4x4 matrix in column-major order

Definition at line 127 of file Matrix4f.java.

Here is the call graph for this function:

Member Function Documentation

◆ determinant()

float com.jogamp.math.Matrix4f.determinant ( )

Returns the determinant of this matrix.

Returns
the matrix determinant

Definition at line 450 of file Matrix4f.java.

Here is the caller graph for this function:

◆ equals()

boolean com.jogamp.math.Matrix4f.equals ( final Object  o)

Definition at line 1671 of file Matrix4f.java.

Here is the call graph for this function:

◆ get() [1/4]

float[] com.jogamp.math.Matrix4f.get ( final float[]  dst)

Get this matrix into the given float[16] array in column major order.

Parameters
dstfloat[16] array storage in column major order
Returns
dst for chaining

Definition at line 392 of file Matrix4f.java.

◆ get() [2/4]

float[] com.jogamp.math.Matrix4f.get ( final float[]  dst,
final int  dst_off 
)

Get this matrix into the given float[16] array at dst_off in column major order.

Parameters
dstfloat[16] array storage in column major order
dst_offoffset
Returns
dst for chaining

Definition at line 366 of file Matrix4f.java.

◆ get() [3/4]

FloatBuffer com.jogamp.math.Matrix4f.get ( final FloatBuffer  dst)

Get this matrix into the given FloatBuffer in column major order.

Implementation uses relative FloatBuffer#put(float), hence caller may want to issue FloatBuffer#reset() thereafter.

Parameters
dstFloatBuffer array storage in column major order
Returns
dst for chaining

Definition at line 422 of file Matrix4f.java.

◆ get() [4/4]

float com.jogamp.math.Matrix4f.get ( final int  i)

Gets the ith component, 0 <= i < 16.

Definition at line 279 of file Matrix4f.java.

Here is the caller graph for this function:

◆ getColumn() [1/2]

Vec3f com.jogamp.math.Matrix4f.getColumn ( final int  column,
final Vec3f  v_out 
)

Get the named column of the given column-major matrix to v_out.

Parameters
columnnamed column to copy
v_outthe column-vector storage
Returns
given result vector v_out for chaining

Definition at line 325 of file Matrix4f.java.

Here is the call graph for this function:

◆ getColumn() [2/2]

Vec4f com.jogamp.math.Matrix4f.getColumn ( final int  column,
final Vec4f  v_out 
)

Get the named column of the given column-major matrix to v_out.

Parameters
columnnamed column to copy
v_outthe column-vector storage
Returns
given result vector v_out for chaining

Definition at line 311 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFrustum()

Frustum com.jogamp.math.Matrix4f.getFrustum ( final Frustum  frustum)

Calculate the frustum planes in world coordinates using this column major order matrix, usually a projection (P) or premultiplied P*MV matrix.

Frustum plane's normals will point to the inside of the viewing frustum, as required by the Frustum class.

See also
Frustum::setFromMat(Matrix4f)

Definition at line 1340 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRotation()

final Quaternion com.jogamp.math.Matrix4f.getRotation ( final Quaternion  res)

Returns the rotation [m00 .

. m22] fields converted to a Quaternion.

Parameters
resresulting Quaternion
Returns
the resulting Quaternion for chaining.
See also
Quaternion::setFromMat(float, float, float, float, float, float, float, float, float)
setToRotation(Quaternion)

Definition at line 1185 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRow() [1/2]

Vec3f com.jogamp.math.Matrix4f.getRow ( final int  row,
final Vec3f  v_out 
)

Get the named row of the given column-major matrix to v_out.

Parameters
rownamed row to copy
v_outthe row-vector storage
Returns
given result vector v_out for chaining

Definition at line 352 of file Matrix4f.java.

Here is the call graph for this function:

◆ getRow() [2/2]

Vec4f com.jogamp.math.Matrix4f.getRow ( final int  row,
final Vec4f  v_out 
)

Get the named row of the given column-major matrix to v_out.

Parameters
rownamed row to copy
v_outthe row-vector storage
Returns
given result vector v_out for chaining

Definition at line 338 of file Matrix4f.java.

Here is the call graph for this function:

◆ invert() [1/2]

boolean com.jogamp.math.Matrix4f.invert ( )

Invert this matrix.

Returns
false if this matrix is singular and inversion not possible, otherwise true

Definition at line 530 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invert() [2/2]

boolean com.jogamp.math.Matrix4f.invert ( final Matrix4f  src)

Invert the src matrix values into this matrix.

Parameters
srcthe source matrix, which values are to be inverted
Returns
false if src matrix is singular and inversion not possible, otherwise true

Definition at line 610 of file Matrix4f.java.

Here is the call graph for this function:

◆ isEqual() [1/2]

boolean com.jogamp.math.Matrix4f.isEqual ( final Matrix4f  o)

Equals check using FloatUtil#EPSILON value and FloatUtil#isEqual(float, float, float).

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
Parameters
ocomparison value
Returns
true if all components differ less than FloatUtil#EPSILON, otherwise false.

Definition at line 1666 of file Matrix4f.java.

Here is the call graph for this function:

◆ isEqual() [2/2]

boolean com.jogamp.math.Matrix4f.isEqual ( final Matrix4f  o,
final float  epsilon 
)

Equals check using a given FloatUtil#EPSILON value and FloatUtil#isEqual(float, float, float).

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
Parameters
ocomparison value
epsilonconsider using FloatUtil#EPSILON
Returns
true if all components differ less than epsilon, otherwise false.

Definition at line 1631 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load() [1/4]

Matrix4f com.jogamp.math.Matrix4f.load ( final float[]  src)

Load the values of the given matrix src to this matrix.

Parameters
src4x4 matrix float[16] in column-major order
Returns
this matrix for chaining

Definition at line 199 of file Matrix4f.java.

◆ load() [2/4]

Matrix4f com.jogamp.math.Matrix4f.load ( final float[]  src,
final int  src_off 
)

Load the values of the given matrix src to this matrix.

Parameters
src4x4 matrix float[16] in column-major order
src_offoffset for matrix src
Returns
this matrix for chaining

Definition at line 225 of file Matrix4f.java.

◆ load() [3/4]

Matrix4f com.jogamp.math.Matrix4f.load ( final FloatBuffer  src)

Load the values of the given matrix src to this matrix.

Implementation uses relative FloatBuffer#get(), hence caller may want to issue FloatBuffer#reset() thereafter.

Parameters
src4x4 matrix FloatBuffer in column-major order
Returns
this matrix for chaining

Definition at line 254 of file Matrix4f.java.

◆ load() [4/4]

Matrix4f com.jogamp.math.Matrix4f.load ( final Matrix4f  src)

Load the values of the given matrix src to this matrix.

Parameters
srcthe source values
Returns
this matrix for chaining

Definition at line 186 of file Matrix4f.java.

Here is the caller graph for this function:

◆ loadIdentity()

final Matrix4f com.jogamp.math.Matrix4f.loadIdentity ( )

Set this matrix to identity.

Translation matrix (Column Order):
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
 
Returns
this matrix for chaining

Definition at line 172 of file Matrix4f.java.

Here is the caller graph for this function:

◆ mapObjToWin() [1/2]

static boolean com.jogamp.math.Matrix4f.mapObjToWin ( final Vec3f  obj,
final Matrix4f  mMv,
final Matrix4f  mP,
final Recti  viewport,
final Vec3f  winPos 
)
static

Map object coordinates to window coordinates.

Traditional gluProject implementation.

Parameters
objobject position, 3 component vector
mMvmodelview matrix
mPprojection matrix
viewportRect4i viewport
winPos3 component window coordinate, the result
Returns
true if successful, otherwise false (z is 1)

Definition at line 1696 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mapObjToWin() [2/2]

static boolean com.jogamp.math.Matrix4f.mapObjToWin ( final Vec3f  obj,
final Matrix4f  mPMv,
final Recti  viewport,
final Vec3f  winPos 
)
static

Map object coordinates to window coordinates.

Traditional gluProject implementation.

Parameters
objobject position, 3 component vector
mPMv[projection] x [modelview] matrix, i.e. P x Mv
viewportRect4i viewport
winPos3 component window coordinate, the result
Returns
true if successful, otherwise false (z is 1)

Definition at line 1737 of file Matrix4f.java.

Here is the call graph for this function:

◆ mapWinToObj() [1/3]

static boolean com.jogamp.math.Matrix4f.mapWinToObj ( final float  winx,
final float  winy,
final float  winz,
final Matrix4f  invPMv,
final Recti  viewport,
final Vec3f  objPos 
)
static

Map window coordinates to object coordinates.

Traditional gluUnProject implementation.

Parameters
winx
winy
winz
invPMvinverse [projection] x [modelview] matrix, i.e. Inv(P x Mv), if null method returns false
viewportRect4i viewport
objPos3 component object coordinate, the result
Returns
true if successful, otherwise false (null invert matrix, or becomes infinity due to zero z)

Definition at line 1823 of file Matrix4f.java.

Here is the call graph for this function:

◆ mapWinToObj() [2/3]

static boolean com.jogamp.math.Matrix4f.mapWinToObj ( final float  winx,
final float  winy,
final float  winz,
final Matrix4f  mMv,
final Matrix4f  mP,
final Recti  viewport,
final Vec3f  objPos,
final Matrix4f  mat4Tmp 
)
static

Map window coordinates to object coordinates.

Traditional gluUnProject implementation.

Parameters
winx
winy
winz
mMv4x4 modelview matrix
mP4x4 projection matrix
viewportRect4i viewport
objPos3 component object coordinate, the result
mat4Tmp16 component matrix for temp storage
Returns
true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)

Definition at line 1778 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mapWinToObj() [3/3]

static boolean com.jogamp.math.Matrix4f.mapWinToObj ( final float  winx,
final float  winy,
final float  winz1,
final float  winz2,
final Matrix4f  invPMv,
final Recti  viewport,
final Vec3f  objPos1,
final Vec3f  objPos2 
)
static

Map two window coordinates to two object coordinates, distinguished by their z component.

Traditional gluUnProject implementation.

Parameters
winx
winy
winz1
winz2
invPMvinverse [projection] x [modelview] matrix, i.e. Inv(P x Mv), if null method returns false
viewportRect4i viewport vector
objPos13 component object coordinate, the result
Returns
true if successful, otherwise false (null invert matrix, or becomes infinity due to zero z)

Definition at line 1866 of file Matrix4f.java.

Here is the call graph for this function:

◆ mapWinToObj4() [1/2]

static boolean com.jogamp.math.Matrix4f.mapWinToObj4 ( final float  winx,
final float  winy,
final float  winz,
final float  clipw,
final Matrix4f  invPMv,
final Recti  viewport,
final float  near,
final float  far,
final Vec4f  objPos 
)
static

Map window coordinates to object coordinates.

Traditional gluUnProject4 implementation.

Parameters
winx
winy
winz
clipw
invPMvinverse [projection] x [modelview] matrix, i.e. Inv(P x Mv), if null method returns false
viewportRect4i viewport vector
near
far
obj_pos4 component object coordinate, the result
Returns
true if successful, otherwise false (null invert matrix, or becomes infinity due to zero z)

Definition at line 1973 of file Matrix4f.java.

Here is the call graph for this function:

◆ mapWinToObj4() [2/2]

static boolean com.jogamp.math.Matrix4f.mapWinToObj4 ( final float  winx,
final float  winy,
final float  winz,
final float  clipw,
final Matrix4f  mMv,
final Matrix4f  mP,
final Recti  viewport,
final float  near,
final float  far,
final Vec4f  objPos,
final Matrix4f  mat4Tmp 
)
static

Map window coordinates to object coordinates.

Traditional gluUnProject4 implementation.

Parameters
winx
winy
winz
clipw
mMv4x4 modelview matrix
mP4x4 projection matrix
viewportRect4i viewport vector
near
far
obj_pos4 component object coordinate, the result
mat4Tmp16 component matrix for temp storage
Returns
true if successful, otherwise false (failed to invert matrix, or becomes infinity due to zero z)

Definition at line 1926 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mapWinToRay() [1/2]

static boolean com.jogamp.math.Matrix4f.mapWinToRay ( final float  winx,
final float  winy,
final float  winz0,
final float  winz1,
final Matrix4f  invPMv,
final Recti  viewport,
final Ray  ray 
)
static

Map two window coordinates w/ shared X/Y and distinctive Z to a Ray.

The resulting Ray maybe used for picking using a AABBox#getRayIntersection(Vec3f, Ray, float, boolean).

Notes for picking winz0 and winz1:

Parameters
winx
winy
winz0
winz1
invPMvinverse [projection] x [modelview] matrix, i.e. Inv(P x Mv), if null method returns false
viewportRect4i viewport
raystorage for the resulting Ray
Returns
true if successful, otherwise false (null invert matrix, or becomes z is infinity)

Definition at line 2063 of file Matrix4f.java.

Here is the call graph for this function:

◆ mapWinToRay() [2/2]

static boolean com.jogamp.math.Matrix4f.mapWinToRay ( final float  winx,
final float  winy,
final float  winz0,
final float  winz1,
final Matrix4f  mMv,
final Matrix4f  mP,
final Recti  viewport,
final Ray  ray,
final Matrix4f  mat4Tmp1 
)
static

Map two window coordinates w/ shared X/Y and distinctive Z to a Ray.

The resulting Ray maybe used for picking using a AABBox#getRayIntersection(Vec3f, Ray, float, boolean).

Notes for picking winz0 and winz1:

Parameters
winx
winy
winz0
winz1
mMv4x4 modelview matrix
mP4x4 projection matrix
viewportRect4i viewport
raystorage for the resulting Ray
mat4Tmp116 component matrix for temp storage
mat4Tmp216 component matrix for temp storage
Returns
true if successful, otherwise false (failed to invert matrix, or becomes z is infinity)

Definition at line 2023 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mul() [1/2]

final Matrix4f com.jogamp.math.Matrix4f.mul ( final Matrix4f  a,
final Matrix4f  b 
)

Multiply matrix: [this] = [a] x [b].

Parameters
a4x4 matrix, can't be this matrix
b4x4 matrix, can't be this matrix
Returns
this matrix for chaining
See also
mul(Matrix4f)

Definition at line 773 of file Matrix4f.java.

◆ mul() [2/2]

final Matrix4f com.jogamp.math.Matrix4f.mul ( final Matrix4f  b)

Multiply matrix: [this] = [this] x [b].

Parameters
b4x4 matrix
Returns
this matrix for chaining
See also
mul(Matrix4f, Matrix4f)

Definition at line 726 of file Matrix4f.java.

Here is the caller graph for this function:

◆ mulVec3f() [1/2]

final Vec3f com.jogamp.math.Matrix4f.mulVec3f ( final Vec3f  v_in,
final Vec3f  v_out 
)

Affine 3f-vector transformation by 4x4 matrix.

4x4 matrix multiplication with 3-component vector, using 1 for for v_in.w() and dropping v_out.w(), which shall be 1.

Parameters
v_in3-component column-vector Vec3f, can be v_out for in-place transformation
v_outm_in * v_in, 3-component column-vector Vec3f
Returns
v_out for chaining

Definition at line 841 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mulVec3f() [2/2]

final Vec3f com.jogamp.math.Matrix4f.mulVec3f ( final Vec3f  v_inout)

Affine 3f-vector transformation by 4x4 matrix.

4x4 matrix multiplication with 3-component vector, using 1 for for v_inout.w() and dropping v_inout.w(), which shall be 1.

Parameters
v_inout3-component column-vector Vec3f input and output, i.e. in-place transformation
Returns
v_inout for chaining

Definition at line 860 of file Matrix4f.java.

Here is the call graph for this function:

◆ mulVec4f() [1/2]

final Vec4f com.jogamp.math.Matrix4f.mulVec4f ( final Vec4f  v_in,
final Vec4f  v_out 
)
Parameters
v_in4-component column-vector, can be v_out for in-place transformation
v_outthis * v_in
Returns
v_out for chaining

Definition at line 806 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mulVec4f() [2/2]

final Vec4f com.jogamp.math.Matrix4f.mulVec4f ( final Vec4f  v_inout)
Parameters
v_inout4-component column-vector input and output, i.e. in-place transformation
Returns
v_inout for chaining

Definition at line 820 of file Matrix4f.java.

Here is the call graph for this function:

◆ pop()

final void com.jogamp.math.Matrix4f.pop ( )

Pop the current matrix from it's stack, replacing this matrix values.

See also
push()

Definition at line 1610 of file Matrix4f.java.

Here is the caller graph for this function:

◆ push()

final void com.jogamp.math.Matrix4f.push ( )

Push the matrix to it's stack, while preserving this matrix values.

See also
pop()

Definition at line 1602 of file Matrix4f.java.

Here is the caller graph for this function:

◆ rotate() [1/3]

final Matrix4f com.jogamp.math.Matrix4f.rotate ( final float  ang_rad,
final float  x,
final float  y,
final float  z,
final Matrix4f  tmp 
)

Rotate this matrix about give axis and angle in radians, i.e.

multiply by axis-rotation matrix.

See also
Matrix-FAQ Q38
Parameters
angradangle in radians
xx of rotation axis
yy of rotation axis
zz of rotation axis
tmptemporary Matrix4f used for multiplication
Returns
this matrix for chaining

Definition at line 1525 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotate() [2/3]

final Matrix4f com.jogamp.math.Matrix4f.rotate ( final float  ang_rad,
final Vec3f  axis,
final Matrix4f  tmp 
)

Rotate this matrix about give axis and angle in radians, i.e.

multiply by axis-rotation matrix.

See also
Matrix-FAQ Q38
Parameters
angradangle in radians
axisrotation axis
tmptemporary Matrix4f used for multiplication
Returns
this matrix for chaining

Definition at line 1537 of file Matrix4f.java.

Here is the call graph for this function:

◆ rotate() [3/3]

final Matrix4f com.jogamp.math.Matrix4f.rotate ( final Quaternion  quat,
final Matrix4f  tmp 
)

Rotate this matrix with the given Quaternion, i.e.

multiply by Quaternion's rotation matrix.

Parameters
tmptemporary Matrix4f used for multiplication
Returns
this matrix for chaining

Definition at line 1546 of file Matrix4f.java.

Here is the call graph for this function:

◆ scale() [1/2]

final Matrix4f com.jogamp.math.Matrix4f.scale ( final float  s,
final Matrix4f  tmp 
)

Scale this matrix, i.e.

multiply by scale matrix.

Parameters
sscale for x-, y- and z-axis
tmptemporary Matrix4f used for multiplication
Returns
this matrix for chaining

Definition at line 1590 of file Matrix4f.java.

Here is the call graph for this function:

◆ scale() [2/2]

final Matrix4f com.jogamp.math.Matrix4f.scale ( final float  x,
final float  y,
final float  z,
final Matrix4f  tmp 
)

Scale this matrix, i.e.

multiply by scale matrix.

Parameters
xx scale
yy scale
zz scale
tmptemporary Matrix4f used for multiplication
Returns
this matrix for chaining

Definition at line 1580 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set()

void com.jogamp.math.Matrix4f.set ( final int  i,
final float  v 
)

Sets the ith component with float v 0 <= i < 16.

Definition at line 136 of file Matrix4f.java.

Here is the caller graph for this function:

◆ setToFrustum()

Matrix4f com.jogamp.math.Matrix4f.setToFrustum ( final float  left,
final float  right,
final float  bottom,
final float  top,
final float  zNear,
final float  zFar 
) throws IllegalArgumentException

Set this matrix to frustum.

Frustum matrix (Column Order):
2*zNear/dx   0          0   0
0            2*zNear/dy 0   0
A            B          C  -1
0            0          D   0
 
Parameters
left
right
bottom
top
zNear
zFar
Returns
this matrix for chaining
Exceptions
IllegalArgumentExceptionif zNear <= 0 or zFar <= zNear or left == right, or bottom == top.

Definition at line 1254 of file Matrix4f.java.

Here is the caller graph for this function:

◆ setToLookAt()

Matrix4f com.jogamp.math.Matrix4f.setToLookAt ( final Vec3f  eye,
final Vec3f  center,
final Vec3f  up,
final Matrix4f  tmp 
)

Set this matrix to the look-at matrix based on given parameters.

Consist out of two matrix multiplications:

  R = L x T,
  with L for look-at matrix and
       T for eye translation.

  Result R can be utilized for projection or modelview multiplication, i.e.
         M = M x R,
         with M being the projection or modelview matrix.
Parameters
eye3 component eye vector
center3 component center vector
up3 component up vector
tmptemporary Matrix4f used for multiplication
Returns
this matrix for chaining

Definition at line 1432 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setToOrtho()

Matrix4f com.jogamp.math.Matrix4f.setToOrtho ( final float  left,
final float  right,
final float  bottom,
final float  top,
final float  zNear,
final float  zFar 
)

Set this matrix to orthogonal projection.

Ortho matrix (Column Order):
2/dx  0     0    0
0     2/dy  0    0
0     0     2/dz 0
tx    ty    tz   1
 
Parameters
left
right
bottom
top
zNear
zFar
Returns
this matrix for chaining

Definition at line 1206 of file Matrix4f.java.

Here is the caller graph for this function:

◆ setToPerspective() [1/2]

Matrix4f com.jogamp.math.Matrix4f.setToPerspective ( final float  fovy_rad,
final float  aspect,
final float  zNear,
final float  zFar 
) throws IllegalArgumentException

Set this matrix to perspective frustum projection.

Parameters
fovy_radangle in radians
aspectaspect ratio width / height
zNear
zFar
Returns
this matrix for chaining
Exceptions
IllegalArgumentExceptionif zNear <= 0 or zFar <= zNear
See also
setToFrustum(float, float, float, float, float, float)

Definition at line 1303 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setToPerspective() [2/2]

Matrix4f com.jogamp.math.Matrix4f.setToPerspective ( final FovHVHalves  fovhv,
final float  zNear,
final float  zFar 
) throws IllegalArgumentException

Set this matrix to perspective frustum projection.

Parameters
fovhvFovHVHalves field of view in both directions, may not be centered, either in radians or tangent
zNear
zFar
Returns
this matrix for chaining
Exceptions
IllegalArgumentExceptionif zNear <= 0 or zFar <= zNear
See also
setToFrustum(float, float, float, float, float, float)
Frustum::updateByFovDesc(Matrix4f, com.jogamp.math.geom.Frustum.FovDesc)

Definition at line 1322 of file Matrix4f.java.

Here is the call graph for this function:

◆ setToPick()

Matrix4f com.jogamp.math.Matrix4f.setToPick ( final float  x,
final float  y,
final float  deltaX,
final float  deltaY,
final Recti  viewport,
final Matrix4f  mat4Tmp 
)

Set this matrix to the pick matrix based on given parameters.

Traditional gluPickMatrix implementation.

Consist out of two matrix multiplications:

  R = T x S,
  with T for viewport translation matrix and
       S for viewport scale matrix.

  Result R can be utilized for projection multiplication, i.e.
         P = P x R,
         with P being the projection matrix.

To effectively use the generated pick matrix for picking, call setToPick(..) and multiply a custom perspective matrix by this pick matrix. Then you may load the result onto the perspective matrix stack.

Parameters
xthe center x-component of a picking region in window coordinates
ythe center y-component of a picking region in window coordinates
deltaXthe width of the picking region in window coordinates.
deltaYthe height of the picking region in window coordinates.
viewportRect4i viewport
mat4Tmptemp storage
Returns
this matrix for chaining or null if either delta value is <= zero.

Definition at line 1498 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setToRotation()

final Matrix4f com.jogamp.math.Matrix4f.setToRotation ( final Quaternion  q)

Set this matrix to rotation using the given Quaternion.

Implementation Details:

Parameters
qthe Quaternion representing the rotation
Returns
this matrix for chaining
See also
Matrix-FAQ Q54
Quaternion::toMatrix(float[])
getRotation()

Definition at line 1124 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setToRotationAxis() [1/2]

final Matrix4f com.jogamp.math.Matrix4f.setToRotationAxis ( final float  ang_rad,
final Vec3f  axis 
)

Set this matrix to rotation from the given axis and angle in radians.

 Rotation matrix (Column Order):
 xx(1-c)+c  xy(1-c)+zs xz(1-c)-ys 0
 xy(1-c)-zs yy(1-c)+c  yz(1-c)+xs 0
 xz(1-c)+ys yz(1-c)-xs zz(1-c)+c  0
 0          0          0          1
See also
Matrix-FAQ Q38
Parameters
ang_radangle in radians
axisrotation axis
Returns
this matrix for chaining

Definition at line 1024 of file Matrix4f.java.

Here is the call graph for this function:

◆ setToRotationAxis() [2/2]

final Matrix4f com.jogamp.math.Matrix4f.setToRotationAxis ( final float  ang_rad,
float  x,
float  y,
float  z 
)

Set this matrix to rotation from the given axis and angle in radians.

 Rotation matrix (Column Order):
 xx(1-c)+c  xy(1-c)+zs xz(1-c)-ys 0
 xy(1-c)-zs yy(1-c)+c  yz(1-c)+xs 0
 xz(1-c)+ys yz(1-c)-xs zz(1-c)+c  0
 0          0          0          1
See also
Matrix-FAQ Q38
Parameters
ang_radangle in radians
xx of rotation axis
yy of rotation axis
zz of rotation axis
Returns
this matrix for chaining

Definition at line 973 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setToRotationEuler() [1/2]

Matrix4f com.jogamp.math.Matrix4f.setToRotationEuler ( final float  bankX,
final float  headingY,
final float  attitudeZ 
)

Set this matrix to rotation from the given Euler rotation angles in radians.

The rotations are applied in the given order:

  • y - heading
  • z - attitude
  • x - bank
Parameters
bankXthe Euler pitch angle in radians. (rotation about the X axis)
headingYthe Euler yaw angle in radians. (rotation about the Y axis)
attitudeZthe Euler roll angle in radians. (rotation about the Z axis)
Returns
this matrix for chaining

Implementation does not use Quaternion and hence is exposed to Gimbal-Lock, consider using setToRotation(Quaternion).

See also
Matrix-FAQ Q36
euclideanspace.com-eulerToMatrix
setToRotation(Quaternion)

Definition at line 1051 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setToRotationEuler() [2/2]

Matrix4f com.jogamp.math.Matrix4f.setToRotationEuler ( final Vec3f  angradXYZ)

Set this matrix to rotation from the given Euler rotation angles in radians.

The rotations are applied in the given order:

  • y - heading
  • z - attitude
  • x - bank
Parameters
angradXYZeuler angle vector in radians holding x-bank, y-heading and z-attitude
Returns
this quaternion for chaining.

Implementation does not use Quaternion and hence is exposed to Gimbal-Lock, consider using setToRotation(Quaternion).

See also
Matrix-FAQ Q36
euclideanspace.com-eulerToMatrix
setToRotation(Quaternion)

Definition at line 1104 of file Matrix4f.java.

Here is the call graph for this function:

◆ setToScale() [1/2]

final Matrix4f com.jogamp.math.Matrix4f.setToScale ( final float  x,
final float  y,
final float  z 
)

Set this matrix to scale.

Scale matrix (Any Order):
x 0 0 0
0 y 0 0
0 0 z 0
0 0 0 1
 
Parameters
xx-axis scale
yy-axis scale
zz-axis scale
Returns
this matrix for chaining

Definition at line 929 of file Matrix4f.java.

Here is the caller graph for this function:

◆ setToScale() [2/2]

final Matrix4f com.jogamp.math.Matrix4f.setToScale ( final Vec3f  s)

Set this matrix to scale.

Scale matrix (Any Order):
x 0 0 0
0 y 0 0
0 0 z 0
0 0 0 1
 
Parameters
sscale Vec3f
Returns
this matrix for chaining

Definition at line 953 of file Matrix4f.java.

Here is the call graph for this function:

◆ setToTranslation() [1/2]

final Matrix4f com.jogamp.math.Matrix4f.setToTranslation ( final float  x,
final float  y,
final float  z 
)

Set this matrix to translation.

Translation matrix (Column Order):
1 0 0 0
0 1 0 0
0 0 1 0
x y z 1
 
Parameters
xx-axis translate
yy-axis translate
zz-axis translate
Returns
this matrix for chaining

Definition at line 887 of file Matrix4f.java.

Here is the caller graph for this function:

◆ setToTranslation() [2/2]

final Matrix4f com.jogamp.math.Matrix4f.setToTranslation ( final Vec3f  t)

Set this matrix to translation.

Translation matrix (Column Order):
1 0 0 0
0 1 0 0
0 0 1 0
x y z 1
 
Parameters
ttranslate Vec3f
Returns
this matrix for chaining

Definition at line 911 of file Matrix4f.java.

Here is the call graph for this function:

◆ toString() [1/2]

String com.jogamp.math.Matrix4f.toString ( )

Definition at line 2092 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString() [2/2]

StringBuilder com.jogamp.math.Matrix4f.toString ( final StringBuilder  sb,
final String  rowPrefix,
final String  f 
)
Parameters
sboptional passed StringBuilder instance to be used
rowPrefixoptional prefix for each row
fthe format string of one floating point, i.e. "%10.5f", see java.util.Formatter
Returns
matrix string representation

Definition at line 2085 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ translate() [1/2]

final Matrix4f com.jogamp.math.Matrix4f.translate ( final float  x,
final float  y,
final float  z,
final Matrix4f  tmp 
)

Translate this matrix, i.e.

multiply by translation matrix.

Parameters
xx translation
yy translation
zz translation
tmptemporary Matrix4f used for multiplication
Returns
this matrix for chaining

Definition at line 1558 of file Matrix4f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ translate() [2/2]

final Matrix4f com.jogamp.math.Matrix4f.translate ( final Vec3f  t,
final Matrix4f  tmp 
)

Translate this matrix, i.e.

multiply by translation matrix.

Parameters
ttranslation Vec3f
tmptemporary Matrix4f used for multiplication
Returns
this matrix for chaining

Definition at line 1568 of file Matrix4f.java.

Here is the call graph for this function:

◆ transpose() [1/2]

final Matrix4f com.jogamp.math.Matrix4f.transpose ( )

Transpose this matrix.

Returns
this matrix for chaining

Definition at line 464 of file Matrix4f.java.

Here is the caller graph for this function:

◆ transpose() [2/2]

final Matrix4f com.jogamp.math.Matrix4f.transpose ( final Matrix4f  src)

Transpose the given src matrix into this matrix.

Parameters
srcsource 4x4 matrix
Returns
this matrix (result) for chaining

Definition at line 500 of file Matrix4f.java.

Here is the call graph for this function:

The documentation for this class was generated from the following file: