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

Basic Float math utility functions. More...

Collaboration diagram for com.jogamp.math.FloatUtil:

Static Public Member Functions

static float[] makeIdentity (final float[] m)
 Make matrix an identity matrix. More...
 
static float[] makeTranslation (final float[] m, final boolean initM, final float tx, final float ty, final float tz)
 Make a translation matrix in column-major order from the given axis deltas. More...
 
static float[] makeScale (final float[] m, final boolean initM, final float sx, final float sy, final float sz)
 Make a scale matrix in column-major order from the given axis factors. More...
 
static float[] makeFrustum (final float[] m, final int m_offset, final boolean initM, final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) throws GLException
 Make given matrix the frustum matrix based on given parameters. More...
 
static float[] makePerspective (final float[] m, final int m_off, final boolean initM, final float fovy_rad, final float aspect, final float zNear, final float zFar) throws GLException
 Make given matrix the perspective frustum matrix based on given parameters. More...
 
static float[] makeLookAt (final float[] m, final int m_offset, final float[] eye, final int eye_offset, final float[] center, final int center_offset, final float[] up, final int up_offset, final float[] mat4Tmp)
 Make given matrix the look-at matrix based on given parameters. More...
 
static float[] makePick (final float[] m, final float x, final float y, final float deltaX, final float deltaY, final int[] viewport, final int viewport_offset, final float[] mat4Tmp)
 Make given matrix the pick matrix based on given parameters. More...
 
static float[] transposeMatrix (final float[] msrc, final float[] mres)
 Transpose the given matrix. More...
 
static float matrixDeterminant (final float[] m)
 Returns the determinant of the given matrix. More...
 
static float[] invertMatrix (final float[] msrc, final float[] mres)
 Invert the given matrix. More...
 
static boolean mapObjToWin (final float objx, final float objy, final float objz, final float[] modelMatrix, final int modelMatrix_offset, final float[] projMatrix, final int projMatrix_offset, final int[] viewport, final int viewport_offset, final float[] win_pos, final int win_pos_offset, final float[] vec4Tmp1, final float[] vec4Tmp2)
 Map object coordinates to window coordinates. More...
 
static boolean mapWinToObj (final float winx, final float winy, final float winz, final float[] modelMatrix, final int modelMatrix_offset, final float[] projMatrix, final int projMatrix_offset, final int[] viewport, final int viewport_offset, final float[] obj_pos, final int obj_pos_offset, final float[] mat4Tmp1, final float[] mat4Tmp2)
 Map window coordinates to object coordinates. More...
 
static boolean mapWinToObj4 (final float winx, final float winy, final float winz, final float clipw, final float[] modelMatrix, final int modelMatrix_offset, final float[] projMatrix, final int projMatrix_offset, final int[] viewport, final int viewport_offset, final float near, final float far, final float[] obj_pos, final int obj_pos_offset, final float[] mat4Tmp1, final float[] mat4Tmp2)
 Map window coordinates to object coordinates. More...
 
static void multMatrix (final float[] a, final int a_off, final float[] b, final int b_off, final float[] d, final int d_off)
 Multiply matrix: [d] = [a] x [b]. More...
 
static float[] multMatrix (final float[] a, final float[] b, final float[] d)
 Multiply matrix: [d] = [a] x [b]. More...
 
static void multMatrix (final float[] a, final int a_off, final float[] b, final int b_off)
 Multiply matrix: [a] = [a] x [b]. More...
 
static float[] multMatrix (final float[] a, final float[] b)
 Multiply matrix: [a] = [a] x [b]. More...
 
static void multMatrix (final FloatBuffer a, final FloatBuffer b, final float[] d)
 Multiply matrix: [d] = [a] x [b]. More...
 
static void multMatrix (final FloatBuffer a, final FloatBuffer b)
 Multiply matrix: [a] = [a] x [b]. More...
 
static void multMatrixVec (final float[] m_in, final int m_in_off, final float[] v_in, final int v_in_off, final float[] v_out, final int v_out_off)
 
static void multMatrixVec (final float[] m_in, final int m_in_off, final float[] v_in, final float[] v_out)
 
static float[] multMatrixVec (final float[] m_in, final float[] v_in, final float[] v_out)
 
static void multMatrixVec (final FloatBuffer m_in, final float[] v_in, final float[] v_out)
 
static float[] multMatrixVec3 (final float[] m_in, final float[] v_in, final float[] v_out)
 Affine 3f-vector transformation by 4x4 matrix. More...
 
static StringBuilder matrixRowToString (StringBuilder sb, final String f, final FloatBuffer a, final int aOffset, final int rows, final int columns, final boolean rowMajorOrder, final int row)
 
static StringBuilder matrixRowToString (StringBuilder sb, final String f, final float[] a, final int aOffset, final int rows, final int columns, final boolean rowMajorOrder, final int row)
 
static StringBuilder matrixToString (StringBuilder sb, final String rowPrefix, final String f, final FloatBuffer a, final int aOffset, final int rows, final int columns, final boolean rowMajorOrder)
 
static StringBuilder matrixToString (StringBuilder sb, final String rowPrefix, final String f, final float[] a, final int aOffset, final int rows, final int columns, final boolean rowMajorOrder)
 
static float getMachineEpsilon ()
 Return computed machine Epsilon value. More...
 
static float adegToRad (final float arc_degree)
 Converts arc-degree to radians. More...
 
static float radToADeg (final float rad)
 Converts radians to arc-degree. More...
 
static boolean isEqualRaw (final float a, final float b)
 Returns true if both values are equal disregarding EPSILON but considering NaN, -Inf and +Inf. More...
 
static boolean isEqual (final float a, final float b, final float epsilon)
 Returns true if both values are equal, i.e. More...
 
static boolean isEqual (final float a, final float b)
 Returns true if both values are equal, i.e. More...
 
static boolean isEqual2 (final float a, final float b)
 Returns true if both values are equal, i.e. More...
 
static int compare (final float a, final float b)
 Returns -1, 0 or 1 if a is less, equal or greater than b, disregarding epsilon but considering NaN, -Inf and +Inf. More...
 
static int compare (final float a, final float b, final float epsilon)
 Returns -1, 0 or 1 if a is less, equal or greater than b, considering epsilon and NaN, -Inf and +Inf. More...
 
static boolean isZero (final float a, final float epsilon)
 Returns true if value is zero, i.e. More...
 
static boolean isZero (final float a)
 Returns true if value is zero, i.e. More...
 
static boolean isZeroRaw (final float a)
 Returns true if value is zero, disregarding EPSILON but considering NaN, -Inf and +Inf. More...
 
static float abs (final float a)
 Invokes Math#abs(float). More...
 
static float pow (final float a, final float b)
 
static float sin (final float a)
 
static float asin (final float a)
 
static float cos (final float a)
 
static float acos (final float a)
 
static float tan (final float a)
 
static float atan (final float a)
 
static float atan2 (final float y, final float x)
 
static float sqrt (final float a)
 
static float getZBufferEpsilon (final int zBits, final float z, final float zNear)
 Returns resolution of Z buffer of given parameter, see Love Your Z-Buffer. More...
 
static int getZBufferValue (final int zBits, final float z, final float zNear, final float zFar)
 Returns Z buffer value of given parameter, see Love Your Z-Buffer. More...
 
static float getOrthoWinZ (final float orthoZ, final float zNear, final float zFar)
 Returns orthogonal distance (1f/zNear-1f/orthoZ) / (1f/zNear-1f/zFar);. More...
 

Static Public Attributes

static final boolean DEBUG = Debug.debugExplicit("Math")
 
static final float E = 2.7182818284590452354f
 
static final float PI = 3.14159265358979323846f
 The value PI, i.e. More...
 
static final float TWO_PI = 2f * PI
 The value 2PI, i.e. More...
 
static final float HALF_PI = PI / 2f
 The value PI/2, i.e. More...
 
static final float QUARTER_PI = PI / 4f
 The value PI/4, i.e. More...
 
static final float SQUARED_PI = PI * PI
 The value PI^2. More...
 
static final float EPSILON = 1.1920929E-7f
 Epsilon for floating point {@value}, as once computed via getMachineEpsilon() on an AMD-64 CPU. More...
 
static final float INV_DEVIANCE = 1.0E-5f
 Inversion Epsilon, used with equals method to determine if two inverted matrices are close enough to be considered equal. More...
 
static final int IEC559_SIGN_BIT = 1 << 31
 Signed bit 31 of IEEE 754 (IEC 559) single float-point bit layout, i.e. More...
 

Detailed Description

Basic Float math utility functions.

Implementation assumes linear matrix layout 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:

Definition at line 83 of file FloatUtil.java.

Member Function Documentation

◆ abs()

static float com.jogamp.math.FloatUtil.abs ( final float  a)
static

Invokes Math#abs(float).

Parameters
afloat to process
Returns
absolute value of a
Deprecated:
use Math#abs(float) directly

Definition at line 1597 of file FloatUtil.java.

◆ acos()

static float com.jogamp.math.FloatUtil.acos ( final float  a)
static

Definition at line 1607 of file FloatUtil.java.

Here is the caller graph for this function:

◆ adegToRad()

static float com.jogamp.math.FloatUtil.adegToRad ( final float  arc_degree)
static

Converts arc-degree to radians.

Definition at line 1368 of file FloatUtil.java.

Here is the caller graph for this function:

◆ asin()

static float com.jogamp.math.FloatUtil.asin ( final float  a)
static

Definition at line 1603 of file FloatUtil.java.

Here is the caller graph for this function:

◆ atan()

static float com.jogamp.math.FloatUtil.atan ( final float  a)
static

Definition at line 1611 of file FloatUtil.java.

Here is the caller graph for this function:

◆ atan2()

static float com.jogamp.math.FloatUtil.atan2 ( final float  y,
final float  x 
)
static

Definition at line 1613 of file FloatUtil.java.

Here is the caller graph for this function:

◆ compare() [1/2]

static int com.jogamp.math.FloatUtil.compare ( final float  a,
final float  b 
)
static

Returns -1, 0 or 1 if a is less, equal or greater than b, disregarding epsilon but considering NaN, -Inf and +Inf.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
  • NaN > 0
  • +Inf > -Inf
See also
compare(float, float, float)

Definition at line 1508 of file FloatUtil.java.

Here is the caller graph for this function:

◆ compare() [2/2]

static int com.jogamp.math.FloatUtil.compare ( final float  a,
final float  b,
final float  epsilon 
)
static

Returns -1, 0 or 1 if a is less, equal or greater than b, considering epsilon and NaN, -Inf and +Inf.

epsilon must be > 0.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
  • NaN > 0
  • +Inf > -Inf
See also
EPSILON

Definition at line 1544 of file FloatUtil.java.

Here is the call graph for this function:

◆ cos()

static float com.jogamp.math.FloatUtil.cos ( final float  a)
static

Definition at line 1605 of file FloatUtil.java.

Here is the caller graph for this function:

◆ getMachineEpsilon()

static float com.jogamp.math.FloatUtil.getMachineEpsilon ( )
static

Return computed machine Epsilon value.

The machine Epsilon value is computed once.

On a reference machine the result was EPSILON in 23 iterations.

See also
EPSILON

Definition at line 1338 of file FloatUtil.java.

◆ getOrthoWinZ()

static float com.jogamp.math.FloatUtil.getOrthoWinZ ( final float  orthoZ,
final float  zNear,
final float  zFar 
)
static

Returns orthogonal distance (1f/zNear-1f/orthoZ) / (1f/zNear-1f/zFar);.

Definition at line 1661 of file FloatUtil.java.

Here is the caller graph for this function:

◆ getZBufferEpsilon()

static float com.jogamp.math.FloatUtil.getZBufferEpsilon ( final int  zBits,
final float  z,
final float  zNear 
)
static

Returns resolution of Z buffer of given parameter, see Love Your Z-Buffer.

 return z * z / ( zNear * (1<<zBits) - z )

Examples:

1.5256461E-4 = 16 zBits, -0.2 zDist, 0.1 zNear
6.1033297E-6 = 16 zBits, -1.0 zDist, 0.1 zNear
Parameters
zBitsnumber of bits of Z precision, i.e. z-buffer depth
zdistance from the eye to the object
zNeardistance from eye to near clip plane
Returns
smallest resolvable Z separation at this range.

Definition at line 1633 of file FloatUtil.java.

Here is the caller graph for this function:

◆ getZBufferValue()

static int com.jogamp.math.FloatUtil.getZBufferValue ( final int  zBits,
final float  z,
final float  zNear,
final float  zFar 
)
static

Returns Z buffer value of given parameter, see Love Your Z-Buffer.

 float a = zFar / ( zFar - zNear )
 float b = zFar * zNear / ( zNear - zFar )
 return (int) ( (1<<zBits) * ( a + b / z ) )
Parameters
zBitsnumber of bits of Z precision, i.e. z-buffer depth
zdistance from the eye to the object
zNeardistance from eye to near clip plane
zFardistance from eye to far clip plane
Returns
z buffer value

Definition at line 1651 of file FloatUtil.java.

◆ invertMatrix()

static float[] com.jogamp.math.FloatUtil.invertMatrix ( final float[]  msrc,
final float[]  mres 
)
static

Invert the given matrix.

Returns null if inversion is not possible, e.g. matrix is singular due to a bad matrix.

Parameters
msrc4x4 matrix in column-major order, the source
mres4x4 matrix in column-major order, the result - may be msrc (in-place)
Returns
given result matrix mres for chaining if successful, otherwise null. See above.

Definition at line 512 of file FloatUtil.java.

Here is the caller graph for this function:

◆ isEqual() [1/2]

static boolean com.jogamp.math.FloatUtil.isEqual ( final float  a,
final float  b 
)
static

Returns true if both values are equal, i.e.

their absolute delta < EPSILON, considering EPSILON and NaN, -Inf and +Inf.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
See also
EPSILON

Definition at line 1472 of file FloatUtil.java.

◆ isEqual() [2/2]

static boolean com.jogamp.math.FloatUtil.isEqual ( final float  a,
final float  b,
final float  epsilon 
)
static

Returns true if both values are equal, i.e.

their absolute delta < epsilon, considering epsilon and NaN, -Inf and +Inf.

epsilon must be > 0.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
See also
EPSILON

Definition at line 1450 of file FloatUtil.java.

Here is the caller graph for this function:

◆ isEqual2()

static boolean com.jogamp.math.FloatUtil.isEqual2 ( final float  a,
final float  b 
)
static

Returns true if both values are equal, i.e.

their absolute delta < EPSILON, considering EPSILON but disregarding NaN, -Inf and +Inf.

Implementation does not consider corner cases like isEqual(float, float, float).

See also
EPSILON

Definition at line 1489 of file FloatUtil.java.

Here is the caller graph for this function:

◆ isEqualRaw()

static boolean com.jogamp.math.FloatUtil.isEqualRaw ( final float  a,
final float  b 
)
static

Returns true if both values are equal disregarding EPSILON but considering NaN, -Inf and +Inf.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
See also
isEqual(float, float, float)

Definition at line 1429 of file FloatUtil.java.

◆ isZero() [1/2]

static boolean com.jogamp.math.FloatUtil.isZero ( final float  a)
static

Returns true if value is zero, i.e.

it's absolute value < EPSILON.

See also
EPSILON

Definition at line 1569 of file FloatUtil.java.

◆ isZero() [2/2]

static boolean com.jogamp.math.FloatUtil.isZero ( final float  a,
final float  epsilon 
)
static

Returns true if value is zero, i.e.

it's absolute value < epsilon.

epsilon must be > 0.

Parameters
avalue to test
epsilonoptional positive epsilon value, must be > 0
See also
EPSILON

Definition at line 1561 of file FloatUtil.java.

Here is the caller graph for this function:

◆ isZeroRaw()

static boolean com.jogamp.math.FloatUtil.isZeroRaw ( final float  a)
static

Returns true if value is zero, disregarding EPSILON but considering NaN, -Inf and +Inf.

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf

Definition at line 1585 of file FloatUtil.java.

◆ makeFrustum()

static float[] com.jogamp.math.FloatUtil.makeFrustum ( final float[]  m,
final int  m_offset,
final boolean  initM,
final float  left,
final float  right,
final float  bottom,
final float  top,
final float  zNear,
final float  zFar 
) throws GLException
static

Make given matrix the frustum matrix based on given parameters.

 Frustum matrix (Column Order):
 2*zNear/dx   0          0   0
 0            2*zNear/dy 0   0
 A            B          C  -1
 0            0          D   0

<p<blockquote>‍

All matrix fields are only set if initM is true.

Parameters
m4x4 matrix in column-major order (also result)
m_offsetoffset in given array m, i.e. start of the 4x4 matrix
initMif true, given matrix will be initialized w/ identity matrix, otherwise only the frustum fields are set.
left
right
bottom
top
zNear
zFar
Returns
given matrix for chaining
Exceptions
GLExceptionif zNear <= 0 or zFar <= zNear or left == right, or bottom == top.

Definition at line 218 of file FloatUtil.java.

Here is the caller graph for this function:

◆ makeIdentity()

static float[] com.jogamp.math.FloatUtil.makeIdentity ( final float[]  m)
static

Make matrix an identity matrix.

Parameters
m4x4 matrix in column-major order (also result)
Returns
given matrix for chaining

Definition at line 96 of file FloatUtil.java.

Here is the caller graph for this function:

◆ makeLookAt()

static float[] com.jogamp.math.FloatUtil.makeLookAt ( final float[]  m,
final int  m_offset,
final float[]  eye,
final int  eye_offset,
final float[]  center,
final int  center_offset,
final float[]  up,
final int  up_offset,
final float[]  mat4Tmp 
)
static

Make given matrix 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 modelview multiplication, i.e.
         M = M x R,
         with M being the modelview matrix.

All matrix fields are set.

Parameters
m4x4 matrix in column-major order, result only
m_offsetoffset in given array m, i.e. start of the 4x4 matrix
eye3 component eye vector
eye_offset
center3 component center vector
center_offset
up3 component up vector
up_offset
mat4Tmptemp float[16] storage
Returns
given matrix m for chaining

Definition at line 329 of file FloatUtil.java.

Here is the call graph for this function:

◆ makePerspective()

static float[] com.jogamp.math.FloatUtil.makePerspective ( final float[]  m,
final int  m_off,
final boolean  initM,
final float  fovy_rad,
final float  aspect,
final float  zNear,
final float  zFar 
) throws GLException
static

Make given matrix the perspective frustum matrix based on given parameters.

All matrix fields are only set if initM is true.

Parameters
m4x4 matrix in column-major order (also result)
m_offsetoffset in given array m, i.e. start of the 4x4 matrix
initMif true, given matrix will be initialized w/ identity matrix, otherwise only the frustum fields are set.
fovy_radangle in radians
aspectaspect ratio width / height
zNear
zFar
Returns
given matrix for chaining
Exceptions
GLExceptionif zNear <= 0 or zFar <= zNear
See also
makeFrustum(float[], int, boolean, float, float, float, float, float, float)

Definition at line 292 of file FloatUtil.java.

Here is the call graph for this function:

◆ makePick()

static float[] com.jogamp.math.FloatUtil.makePick ( final float[]  m,
final float  x,
final float  y,
final float  deltaX,
final float  deltaY,
final int[]  viewport,
final int  viewport_offset,
final float[]  mat4Tmp 
)
static

Make given matrix 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 makePick and multiply a custom perspective matrix by this pick matrix. Then you may load the result onto the perspective matrix stack.

All matrix fields are set.

Parameters
m4x4 matrix in column-major order, result only
m_offsetoffset in given array m, i.e. start of the 4x4 matrix
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.
viewport4 component viewport vector
viewport_offset
mat4Tmptemp float[16] storage
Returns
given matrix m for chaining or null if either delta value is <= zero.

Definition at line 415 of file FloatUtil.java.

Here is the call graph for this function:

◆ makeScale()

static float[] com.jogamp.math.FloatUtil.makeScale ( final float[]  m,
final boolean  initM,
final float  sx,
final float  sy,
final float  sz 
)
static

Make a scale matrix in column-major order from the given axis factors.

 Scale matrix (Any Order):
 x 0 0 0
 0 y 0 0
 0 0 z 0
 0 0 0 1

<p<blockquote>‍

All matrix fields are only set if initM is true.

Parameters
m4x4 matrix in column-major order (also result)
initMif true, given matrix will be initialized w/ identity matrix, otherwise only the diagonal and last-row is set. The latter can be utilized to share a once identity set matrix for scaling and translation, while leaving the other fields untouched for performance reasons.
Returns
given matrix for chaining

Definition at line 176 of file FloatUtil.java.

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

◆ makeTranslation()

static float[] com.jogamp.math.FloatUtil.makeTranslation ( final float[]  m,
final boolean  initM,
final float  tx,
final float  ty,
final float  tz 
)
static

Make a translation matrix in column-major order from the given axis deltas.

 Translation matrix (Column Order):
 1 0 0 0
 0 1 0 0
 0 0 1 0
 x y z 1

<p<blockquote>‍

All matrix fields are only set if initM is true.

Parameters
m4x4 matrix in column-major order (also result)
initMif true, given matrix will be initialized w/ identity matrix, otherwise only the diagonal and last-row is set. The latter can be utilized to share a once identity set matrix for scaling and translation, while leaving the other fields untouched for performance reasons.
Returns
given matrix for chaining

Definition at line 140 of file FloatUtil.java.

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

◆ mapObjToWin()

static boolean com.jogamp.math.FloatUtil.mapObjToWin ( final float  objx,
final float  objy,
final float  objz,
final float[]  modelMatrix,
final int  modelMatrix_offset,
final float[]  projMatrix,
final int  projMatrix_offset,
final int[]  viewport,
final int  viewport_offset,
final float[]  win_pos,
final int  win_pos_offset,
final float[]  vec4Tmp1,
final float[]  vec4Tmp2 
)
static

Map object coordinates to window coordinates.

Traditional gluProject implementation.

Parameters
objx
objy
objz
modelMatrix4x4 modelview matrix
modelMatrix_offset
projMatrix4x4 projection matrix
projMatrix_offset
viewport4 component viewport vector
viewport_offset
win_pos3 component window coordinate, the result
win_pos_offset
vec4Tmp14 component vector for temp storage
vec4Tmp24 component vector for temp storage
Returns
true if successful, otherwise false (z is 1)

Definition at line 607 of file FloatUtil.java.

Here is the call graph for this function:

◆ mapWinToObj()

static boolean com.jogamp.math.FloatUtil.mapWinToObj ( final float  winx,
final float  winy,
final float  winz,
final float[]  modelMatrix,
final int  modelMatrix_offset,
final float[]  projMatrix,
final int  projMatrix_offset,
final int[]  viewport,
final int  viewport_offset,
final float[]  obj_pos,
final int  obj_pos_offset,
final float[]  mat4Tmp1,
final float[]  mat4Tmp2 
)
static

Map window coordinates to object coordinates.

Traditional gluUnProject implementation.

Parameters
winx
winy
winz
modelMatrix4x4 modelview matrix
modelMatrix_offset
projMatrix4x4 projection matrix
projMatrix_offset
viewport4 component viewport vector
viewport_offset
obj_pos3 component object coordinate, the result
obj_pos_offset
mat4Tmp116 component matrix for temp storage
mat4Tmp216 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 665 of file FloatUtil.java.

Here is the call graph for this function:

◆ mapWinToObj4()

static boolean com.jogamp.math.FloatUtil.mapWinToObj4 ( final float  winx,
final float  winy,
final float  winz,
final float  clipw,
final float[]  modelMatrix,
final int  modelMatrix_offset,
final float[]  projMatrix,
final int  projMatrix_offset,
final int[]  viewport,
final int  viewport_offset,
final float  near,
final float  far,
final float[]  obj_pos,
final int  obj_pos_offset,
final float[]  mat4Tmp1,
final float[]  mat4Tmp2 
)
static

Map window coordinates to object coordinates.

Traditional gluUnProject4 implementation.

Parameters
winx
winy
winz
clipw
modelMatrix4x4 modelview matrix
modelMatrix_offset
projMatrix4x4 projection matrix
projMatrix_offset
viewport4 component viewport vector
viewport_offset
near
far
obj_pos4 component object coordinate, the result
obj_pos_offset
mat4Tmp116 component matrix for temp storage
mat4Tmp216 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 733 of file FloatUtil.java.

Here is the call graph for this function:

◆ matrixDeterminant()

static float com.jogamp.math.FloatUtil.matrixDeterminant ( final float[]  m)
static

Returns the determinant of the given matrix.

Parameters
m4x4 matrix in column-major order, the source
Returns
the matrix determinant

Definition at line 474 of file FloatUtil.java.

◆ matrixRowToString() [1/2]

static StringBuilder com.jogamp.math.FloatUtil.matrixRowToString ( StringBuilder  sb,
final String  f,
final float[]  a,
final int  aOffset,
final int  rows,
final int  columns,
final boolean  rowMajorOrder,
final int  row 
)
static
Parameters
sboptional passed StringBuilder instance to be used
fthe format string of one floating point, i.e. "%10.5f", see java.util.Formatter
amxn matrix (rows x columns)
aOffsetoffset to a's current position
rows
columns
rowMajorOrderif true floats are layed out in row-major-order, otherwise column-major-order (OpenGL)
rowrow number to print
Returns
matrix row string representation

Definition at line 1227 of file FloatUtil.java.

◆ matrixRowToString() [2/2]

static StringBuilder com.jogamp.math.FloatUtil.matrixRowToString ( StringBuilder  sb,
final String  f,
final FloatBuffer  a,
final int  aOffset,
final int  rows,
final int  columns,
final boolean  rowMajorOrder,
final int  row 
)
static
Parameters
sboptional passed StringBuilder instance to be used
fthe format string of one floating point, i.e. "%10.5f", see java.util.Formatter
amxn matrix (rows x columns)
aOffsetoffset to a's current position
rows
columns
rowMajorOrderif true floats are layed out in row-major-order, otherwise column-major-order (OpenGL)
rowrow number to print
Returns
matrix row string representation

Definition at line 1197 of file FloatUtil.java.

Here is the caller graph for this function:

◆ matrixToString() [1/2]

static StringBuilder com.jogamp.math.FloatUtil.matrixToString ( StringBuilder  sb,
final String  rowPrefix,
final String  f,
final float[]  a,
final int  aOffset,
final int  rows,
final int  columns,
final boolean  rowMajorOrder 
)
static
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
amxn matrix (rows x columns)
aOffsetoffset to a's current position
rows
columns
rowMajorOrderif true floats are laid out in row-major-order, otherwise column-major-order (OpenGL)
Returns
matrix string representation

Definition at line 1284 of file FloatUtil.java.

Here is the call graph for this function:

◆ matrixToString() [2/2]

static StringBuilder com.jogamp.math.FloatUtil.matrixToString ( StringBuilder  sb,
final String  rowPrefix,
final String  f,
final FloatBuffer  a,
final int  aOffset,
final int  rows,
final int  columns,
final boolean  rowMajorOrder 
)
static
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
amxn matrix (rows x columns)
aOffsetoffset to a's current position
rows
columns
rowMajorOrderif true floats are layed out in row-major-order, otherwise column-major-order (OpenGL)
Returns
matrix string representation

Definition at line 1255 of file FloatUtil.java.

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

◆ multMatrix() [1/6]

static float[] com.jogamp.math.FloatUtil.multMatrix ( final float[]  a,
final float[]  b 
)
static

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

Parameters
a4x4 matrix in column-major order (also result)
b4x4 matrix in column-major order
Returns
given result matrix a for chaining

Definition at line 970 of file FloatUtil.java.

◆ multMatrix() [2/6]

static float[] com.jogamp.math.FloatUtil.multMatrix ( final float[]  a,
final float[]  b,
final float[]  d 
)
static

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

Parameters
a4x4 matrix in column-major order
b4x4 matrix in column-major order
dresult a*b in column-major order
Returns
given result matrix d for chaining

Definition at line 847 of file FloatUtil.java.

◆ multMatrix() [3/6]

static void com.jogamp.math.FloatUtil.multMatrix ( final float[]  a,
final int  a_off,
final float[]  b,
final int  b_off 
)
static

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

Parameters
a4x4 matrix in column-major order (also result)
b4x4 matrix in column-major order

Definition at line 909 of file FloatUtil.java.

◆ multMatrix() [4/6]

static void com.jogamp.math.FloatUtil.multMatrix ( final float[]  a,
final int  a_off,
final float[]  b,
final int  b_off,
final float[]  d,
final int  d_off 
)
static

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

Parameters
a4x4 matrix in column-major order
b4x4 matrix in column-major order
dresult a*b in column-major order

Definition at line 785 of file FloatUtil.java.

Here is the caller graph for this function:

◆ multMatrix() [5/6]

static void com.jogamp.math.FloatUtil.multMatrix ( final FloatBuffer  a,
final FloatBuffer  b 
)
static

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

Parameters
a4x4 matrix in column-major order (also result)
b4x4 matrix in column-major order

Definition at line 1052 of file FloatUtil.java.

◆ multMatrix() [6/6]

static void com.jogamp.math.FloatUtil.multMatrix ( final FloatBuffer  a,
final FloatBuffer  b,
final float[]  d 
)
static

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

Parameters
a4x4 matrix in column-major order
b4x4 matrix in column-major order
dresult a*b in column-major order

Definition at line 1033 of file FloatUtil.java.

◆ multMatrixVec() [1/4]

static float[] com.jogamp.math.FloatUtil.multMatrixVec ( final float[]  m_in,
final float[]  v_in,
final float[]  v_out 
)
static
Parameters
m_in4x4 matrix in column-major order
m_in_off
v_in4-component column-vector
v_outm_in * v_in
Returns
given result vector v_out for chaining

Definition at line 1124 of file FloatUtil.java.

◆ multMatrixVec() [2/4]

static void com.jogamp.math.FloatUtil.multMatrixVec ( final float[]  m_in,
final int  m_in_off,
final float[]  v_in,
final float[]  v_out 
)
static
Parameters
m_in4x4 matrix in column-major order
m_in_off
v_in4-component column-vector
v_outm_in * v_in

Definition at line 1098 of file FloatUtil.java.

◆ multMatrixVec() [3/4]

static void com.jogamp.math.FloatUtil.multMatrixVec ( final float[]  m_in,
final int  m_in_off,
final float[]  v_in,
final int  v_in_off,
final float[]  v_out,
final int  v_out_off 
)
static
Parameters
m_in4x4 matrix in column-major order
m_in_off
v_in4-component column-vector
v_outm_in * v_in

Definition at line 1072 of file FloatUtil.java.

Here is the caller graph for this function:

◆ multMatrixVec() [4/4]

static void com.jogamp.math.FloatUtil.multMatrixVec ( final FloatBuffer  m_in,
final float[]  v_in,
final float[]  v_out 
)
static
Parameters
m_in4x4 matrix in column-major order
v_in4-component column-vector
v_outm_in * v_in

Definition at line 1146 of file FloatUtil.java.

◆ multMatrixVec3()

static float[] com.jogamp.math.FloatUtil.multMatrixVec3 ( final float[]  m_in,
final float[]  v_in,
final float[]  v_out 
)
static

Affine 3f-vector transformation by 4x4 matrix.

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

Parameters
m_in4x4 matrix in column-major order
m_in_off
v_in3-component column-vector
v_outm_in * v_in, 3-component column-vector
Returns
given result vector v_out for chaining

Definition at line 1172 of file FloatUtil.java.

Here is the caller graph for this function:

◆ pow()

static float com.jogamp.math.FloatUtil.pow ( final float  a,
final float  b 
)
static

Definition at line 1599 of file FloatUtil.java.

◆ radToADeg()

static float com.jogamp.math.FloatUtil.radToADeg ( final float  rad)
static

Converts radians to arc-degree.

Definition at line 1373 of file FloatUtil.java.

Here is the caller graph for this function:

◆ sin()

static float com.jogamp.math.FloatUtil.sin ( final float  a)
static

Definition at line 1601 of file FloatUtil.java.

Here is the caller graph for this function:

◆ sqrt()

static float com.jogamp.math.FloatUtil.sqrt ( final float  a)
static

Definition at line 1615 of file FloatUtil.java.

Here is the caller graph for this function:

◆ tan()

static float com.jogamp.math.FloatUtil.tan ( final float  a)
static

Definition at line 1609 of file FloatUtil.java.

Here is the caller graph for this function:

◆ transposeMatrix()

static float[] com.jogamp.math.FloatUtil.transposeMatrix ( final float[]  msrc,
final float[]  mres 
)
static

Transpose the given matrix.

Parameters
msrc4x4 matrix in column-major order, the source
mres4x4 matrix in column-major order, the result
Returns
given result matrix mres for chaining

Definition at line 442 of file FloatUtil.java.

Member Data Documentation

◆ DEBUG

final boolean com.jogamp.math.FloatUtil.DEBUG = Debug.debugExplicit("Math")
static

Definition at line 84 of file FloatUtil.java.

◆ E

final float com.jogamp.math.FloatUtil.E = 2.7182818284590452354f
static

Definition at line 1350 of file FloatUtil.java.

◆ EPSILON

final float com.jogamp.math.FloatUtil.EPSILON = 1.1920929E-7f
static

Epsilon for floating point {@value}, as once computed via getMachineEpsilon() on an AMD-64 CPU.

Definition of machine epsilon guarantees that:

       1.0f + EPSILON != 1.0f

In other words: machEps is the maximum relative error of the chosen rounding procedure.

A number can be considered zero if it is in the range (or in the set):

   MaybeZeroSet e ]-machEps .. machEps[  (exclusive)

While comparing floating point values, machEps allows to clip the relative error:

   boolean isZero    = afloat < EPSILON;
   boolean isNotZero = afloat >= EPSILON;

   boolean isEqual    = abs(bfloat - afloat) < EPSILON;
   boolean isNotEqual = abs(bfloat - afloat) >= EPSILON;
See also
isEqual(float, float, float)
isZero(float, float)

Definition at line 1403 of file FloatUtil.java.

◆ HALF_PI

final float com.jogamp.math.FloatUtil.HALF_PI = PI / 2f
static

The value PI/2, i.e.

90 degrees in radians.

Definition at line 1359 of file FloatUtil.java.

◆ IEC559_SIGN_BIT

final int com.jogamp.math.FloatUtil.IEC559_SIGN_BIT = 1 << 31
static

Signed bit 31 of IEEE 754 (IEC 559) single float-point bit layout, i.e.

0x80000000.

Definition at line 1414 of file FloatUtil.java.

◆ INV_DEVIANCE

final float com.jogamp.math.FloatUtil.INV_DEVIANCE = 1.0E-5f
static

Inversion Epsilon, used with equals method to determine if two inverted matrices are close enough to be considered equal.

Using {@value}, which is ~100 times FloatUtil#EPSILON.

Definition at line 1411 of file FloatUtil.java.

◆ PI

final float com.jogamp.math.FloatUtil.PI = 3.14159265358979323846f
static

The value PI, i.e.

180 degrees in radians.

Definition at line 1353 of file FloatUtil.java.

◆ QUARTER_PI

final float com.jogamp.math.FloatUtil.QUARTER_PI = PI / 4f
static

The value PI/4, i.e.

45 degrees in radians.

Definition at line 1362 of file FloatUtil.java.

◆ SQUARED_PI

final float com.jogamp.math.FloatUtil.SQUARED_PI = PI * PI
static

The value PI^2.

Definition at line 1365 of file FloatUtil.java.

◆ TWO_PI

final float com.jogamp.math.FloatUtil.TWO_PI = 2f * PI
static

The value 2PI, i.e.

360 degrees in radians.

Definition at line 1356 of file FloatUtil.java.


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