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

Basic Double math utility functions. More...

Collaboration diagram for com.jogamp.math.DoubleUtil:

Static Public Member Functions

static double getMachineEpsilon ()
 Return computed machine Epsilon value. More...
 
static double adegToRad (final double arc_degree)
 Converts arc-degree to radians. More...
 
static double radToADeg (final double rad)
 Converts radians to arc-degree. More...
 
static boolean isEqualRaw (final double a, final double b)
 Return true if both values are equal w/o regarding an epsilon. More...
 
static boolean isEqual (final double a, final double b, final double epsilon)
 Returns true if both values are equal, i.e. More...
 
static boolean isEqual (final double a, final double b)
 Returns true if both values are equal, i.e. More...
 
static boolean isEqual2 (final double a, final double b)
 Returns true if both values are equal, i.e. More...
 
static int compare (final double a, final double b)
 Returns true if both values are equal w/o regarding an epsilon. More...
 
static int compare (final double a, final double b, final double epsilon)
 Returns -1, 0 or 1 if a is less, equal or greater than b, taking epsilon into account for equality. More...
 
static boolean isZero (final double a, final double epsilon)
 Returns true if value is zero, i.e. More...
 
static boolean isZero (final double a)
 Returns true if value is zero, i.e. More...
 

Static Public Attributes

static final double E = 2.7182818284590452354
 
static final double PI = 3.14159265358979323846
 The value PI, i.e. More...
 
static final double TWO_PI = 2.0 * PI
 The value 2PI, i.e. More...
 
static final double HALF_PI = PI / 2.0
 The value PI/2, i.e. More...
 
static final double QUARTER_PI = PI / 4.0
 The value PI/4, i.e. More...
 
static final double SQUARED_PI = PI * PI
 The value PI^2. More...
 
static final double EPSILON = 2.220446049250313E-16
 Epsilon for floating point {@value}, as once computed via getMachineEpsilon() on an AMD-64 CPU. More...
 
static final double INV_DEVIANCE = 1.0E-8f
 Inversion Epsilon, used with equals method to determine if two inverted matrices are close enough to be considered equal. More...
 

Detailed Description

Basic Double math utility functions.

Definition at line 33 of file DoubleUtil.java.

Member Function Documentation

◆ adegToRad()

static double com.jogamp.math.DoubleUtil.adegToRad ( final double  arc_degree)
static

Converts arc-degree to radians.

Definition at line 89 of file DoubleUtil.java.

◆ compare() [1/2]

static int com.jogamp.math.DoubleUtil.compare ( final double  a,
final double  b 
)
static

Returns true if both values are equal w/o regarding an epsilon.

Implementation considers following corner cases:

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

Definition at line 223 of file DoubleUtil.java.

Here is the caller graph for this function:

◆ compare() [2/2]

static int com.jogamp.math.DoubleUtil.compare ( final double  a,
final double  b,
final double  epsilon 
)
static

Returns -1, 0 or 1 if a is less, equal or greater than b, taking epsilon into account for equality.

epsilon is allowed to be 0.

Implementation considers following corner cases:

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

Definition at line 259 of file DoubleUtil.java.

Here is the call graph for this function:

◆ getMachineEpsilon()

static double com.jogamp.math.DoubleUtil.getMachineEpsilon ( )
static

Return computed machine Epsilon value.

The machine Epsilon value is computed once.

See also
EPSILON

Definition at line 59 of file DoubleUtil.java.

◆ isEqual() [1/2]

static boolean com.jogamp.math.DoubleUtil.isEqual ( final double  a,
final double  b 
)
static

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

their absolute delta < EPSILON.

Implementation considers following corner cases:

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

Definition at line 189 of file DoubleUtil.java.

◆ isEqual() [2/2]

static boolean com.jogamp.math.DoubleUtil.isEqual ( final double  a,
final double  b,
final double  epsilon 
)
static

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

their absolute delta < epsilon if 0 != epsilon, otherwise == 0.

epsilon is allowed to be 0.

Implementation considers following corner cases:

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

Definition at line 167 of file DoubleUtil.java.

Here is the caller graph for this function:

◆ isEqual2()

static boolean com.jogamp.math.DoubleUtil.isEqual2 ( final double  a,
final double  b 
)
static

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

their absolute delta < EPSILON.

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

See also
EPSILON

Definition at line 205 of file DoubleUtil.java.

◆ isEqualRaw()

static boolean com.jogamp.math.DoubleUtil.isEqualRaw ( final double  a,
final double  b 
)
static

Return true if both values are equal w/o regarding an epsilon.

Implementation considers following corner cases:

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

Definition at line 146 of file DoubleUtil.java.

◆ isZero() [1/2]

static boolean com.jogamp.math.DoubleUtil.isZero ( final double  a)
static

Returns true if value is zero, i.e.

it's absolute value < EPSILON.

See also
EPSILON

Definition at line 290 of file DoubleUtil.java.

◆ isZero() [2/2]

static boolean com.jogamp.math.DoubleUtil.isZero ( final double  a,
final double  epsilon 
)
static

Returns true if value is zero, i.e.

it's absolute value < epsilon if 0 != epsilon, otherwise 0 == a.

epsilon is allowed to be 0.

   return 0 == epsilon && 0 == a || 0 != epsilon && Math.abs(a) < epsilon
Parameters
avalue to test
epsilonoptional positive epsilon value, maybe 0
See also
EPSILON

Definition at line 281 of file DoubleUtil.java.

Here is the caller graph for this function:

◆ radToADeg()

static double com.jogamp.math.DoubleUtil.radToADeg ( final double  rad)
static

Converts radians to arc-degree.

Definition at line 94 of file DoubleUtil.java.

Member Data Documentation

◆ E

final double com.jogamp.math.DoubleUtil.E = 2.7182818284590452354
static

Definition at line 71 of file DoubleUtil.java.

◆ EPSILON

final double com.jogamp.math.DoubleUtil.EPSILON = 2.220446049250313E-16
static

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

Definition of machine epsilon guarantees that:

       1.0 + EPSILON != 1.0

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 124 of file DoubleUtil.java.

◆ HALF_PI

final double com.jogamp.math.DoubleUtil.HALF_PI = PI / 2.0
static

The value PI/2, i.e.

90 degrees in radians.

Definition at line 80 of file DoubleUtil.java.

◆ INV_DEVIANCE

final double com.jogamp.math.DoubleUtil.INV_DEVIANCE = 1.0E-8f
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 DoubleUtil#EPSILON.

Definition at line 132 of file DoubleUtil.java.

◆ PI

final double com.jogamp.math.DoubleUtil.PI = 3.14159265358979323846
static

The value PI, i.e.

180 degrees in radians.

Definition at line 74 of file DoubleUtil.java.

◆ QUARTER_PI

final double com.jogamp.math.DoubleUtil.QUARTER_PI = PI / 4.0
static

The value PI/4, i.e.

45 degrees in radians.

Definition at line 83 of file DoubleUtil.java.

◆ SQUARED_PI

final double com.jogamp.math.DoubleUtil.SQUARED_PI = PI * PI
static

The value PI^2.

Definition at line 86 of file DoubleUtil.java.

◆ TWO_PI

final double com.jogamp.math.DoubleUtil.TWO_PI = 2.0 * PI
static

The value 2PI, i.e.

360 degrees in radians.

Definition at line 77 of file DoubleUtil.java.


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