HE_Mesh2014  2.0.11
Static Public Member Functions | List of all members
wblut.math.WB_Math Class Reference

Static Public Member Functions

static double fastAbs (final double x)
 
static double max (final double x, final double y)
 
static double min (final double x, final double y)
 
static int max (final int x, final int y)
 
static int min (final int x, final int y)
 
static double max (final double x, final double y, final double z)
 
static double min (final double x, final double y, final double z)
 
static final int floor (final float x)
 
static final float fastLog2 (final float i)
 
static final float fastPow2 (final float i)
 
static final float fastPow (final float a, final float b)
 
static final float fastInvSqrt (float x)
 
static final float fastSqrt (final float x)
 
static int getExp (final double v)
 
static double hypot (final double a, final double b)
 
static double logBase2 (final double value)
 
static boolean isPowerOfTwo (final int value)
 
static int powerOfTwoCeiling (final int reference)
 
static int powerOfTwoFloor (final int reference)
 
static double clamp (final double v, final double min, final double max)
 
static int clamp (final int v, final int min, final int max)
 

Detailed Description

A collection of fast and approximated math functions. Not as robust as the JAVA implementations when dealing with special values (NaN etc). Some functions only give an approximation.

Author
Frederik Vanhoutte, W:Blut

Member Function Documentation

static double wblut.math.WB_Math.clamp ( final double  v,
final double  min,
final double  max 
)
static

Clamps a value to a given range.

Parameters
vthe value to clamp.
minthe floor.
maxthe ceiling
Returns
the nearest value such that min <= v <= max.
static int wblut.math.WB_Math.clamp ( final int  v,
final int  min,
final int  max 
)
static

Clamps an integer value to a given range.

Parameters
vthe value to clamp.
minthe floor.
maxthe ceiling
Returns
the nearest value such that min <= v <= max.
static double wblut.math.WB_Math.fastAbs ( final double  x)
static

Fast absolute value.

Parameters
xthe x
Returns
abs(x)
static final float wblut.math.WB_Math.fastInvSqrt ( float  x)
static

Fast inverse sqrt approximation for floats.

Parameters
xthe x
Returns
result
static final float wblut.math.WB_Math.fastLog2 ( final float  i)
static

Fast log2 approximation for floats.

Parameters
ithe i
Returns
result
static final float wblut.math.WB_Math.fastPow ( final float  a,
final float  b 
)
static

Fast power approximation for floats.

Parameters
athe a
bexponent
Returns
result
static final float wblut.math.WB_Math.fastPow2 ( final float  i)
static

Fast square power approximation for floats.

Parameters
ithe i
Returns
result
static final float wblut.math.WB_Math.fastSqrt ( final float  x)
static

Fast sqrt approximation for floats.

Parameters
xthe x
Returns
result
static final int wblut.math.WB_Math.floor ( final float  x)
static

Largest integer smaller than value.

Parameters
xthe x
Returns
result
static int wblut.math.WB_Math.getExp ( final double  v)
static
Parameters
v
Returns
static double wblut.math.WB_Math.hypot ( final double  a,
final double  b 
)
static

sqrt(a^2 + b^2) without under/overflow. *

Parameters
a
b
Returns
static boolean wblut.math.WB_Math.isPowerOfTwo ( final int  value)
static

Convenience method for testing whether a value is a power of two.

Parameters
valuethe value to test for power of 2
Returns
true if power of 2, else false
static double wblut.math.WB_Math.logBase2 ( final double  value)
static

Convenience method to compute the log base 2 of a value.

Parameters
valuethe value to take the log of.
Returns
the log base 2 of the specified value.
static double wblut.math.WB_Math.max ( final double  x,
final double  y 
)
static

Fast max.

Parameters
xthe x
ythe y
Returns
max(x,y)
static int wblut.math.WB_Math.max ( final int  x,
final int  y 
)
static

Fast max.

Parameters
xthe x
ythe y
Returns
max(x,y)
static double wblut.math.WB_Math.max ( final double  x,
final double  y,
final double  z 
)
static

Maximum of three values.

Parameters
xthe x
ythe y
zthe z
Returns
max(x,y,z)
static double wblut.math.WB_Math.min ( final double  x,
final double  y 
)
static

Fast min.

Parameters
xthe x
ythe y
Returns
min(x,y)
static int wblut.math.WB_Math.min ( final int  x,
final int  y 
)
static

Fast min.

Parameters
xthe x
ythe y
Returns
min(x,y)
static double wblut.math.WB_Math.min ( final double  x,
final double  y,
final double  z 
)
static

Minimum of three values.

Parameters
xthe x
ythe y
zthe z
Returns
min(x,y,z)
static int wblut.math.WB_Math.powerOfTwoCeiling ( final int  reference)
static

Returns the value that is the nearest power of 2 greater than or equal to the given value.

Parameters
referencethe reference value. The power of 2 returned is greater than or equal to this value.
Returns
the value that is the nearest power of 2 greater than or equal to the reference value
static int wblut.math.WB_Math.powerOfTwoFloor ( final int  reference)
static

Returns the value that is the nearest power of 2 less than or equal to the given value.

Parameters
referencethe reference value. The power of 2 returned is less than or equal to this value.
Returns
the value that is the nearest power of 2 less than or equal to the reference value

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