mikera.util.mathz
Class FloatMaths
- java.lang.Object
-
- mikera.util.mathz.FloatMaths
-
public final class FloatMaths extends java.lang.ObjectStatic class for specialised maths functions that return floats
-
-
Constructor Summary
Constructors Constructor and Description FloatMaths()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static floatabs(float a)float abs functionstatic floatalternateSqrt(float x)Interesting way to approximate a square root....static floatapproxSqrt(float x)Fast approximate square rootstatic floatbound(float v, float min, float max)Bound a value within a given rangestatic floatcos(double a)Float-returning version of Math.cosstatic floatcos(float a)Float-returning version of Math.cosstatic floatfastInverseSqrt(float x)Fast inverse square root on floats - amusing hack used in Quakestatic floatfastPower(float a, float b)Computes a fast approximation toMath.pow(a, b).static floatlerp(float t, float a, float b)Linear interpolation between a and bstatic floatmod(float n, float d)Mod function implemented for float valuesstatic floatround(float f, int dp)Float round to a specified number of decimal placesstatic floatsin(double a)Float-returning version of Math.sinstatic floatsin(float a)Float-returning version of Math.sinstatic floatsmoothFactor(float x)Smooth factor function for linear interpolation, with dy/dx=0 at x=0 and x=1static floatsmoothStep(float a, float b, float x)static floatsqrt(float a)float square rootstatic floatsquare(float x)Square functionstatic floattanh(float x)float version of Math.tanhstatic floattanhDerivative(float x)
-
-
-
Method Detail
-
round
public static float round(float f, int dp)Float round to a specified number of decimal places
-
fastPower
public static final float fastPower(float a, float b)Computes a fast approximation toMath.pow(a, b). Adapted fromhttp://www.dctsystems.co.uk/Software/power.html .- Parameters:
a- a positive numberb- a number- Returns:
- a^b
-
lerp
public static final float lerp(float t, float a, float b)Linear interpolation between a and b
-
smoothFactor
public static final float smoothFactor(float x)
Smooth factor function for linear interpolation, with dy/dx=0 at x=0 and x=1
-
mod
public static float mod(float n, float d)Mod function implemented for float values
-
smoothStep
public static final float smoothStep(float a, float b, float x)
-
bound
public static final float bound(float v, float min, float max)Bound a value within a given range
-
abs
public static float abs(float a)
float abs function
-
square
public static float square(float x)
Square function
-
sqrt
public static float sqrt(float a)
float square root
-
alternateSqrt
public static float alternateSqrt(float x)
Interesting way to approximate a square root.... however seems to be slower than standard Math.sqrt() approach- Parameters:
x-- Returns:
-
approxSqrt
public static float approxSqrt(float x)
Fast approximate square root
-
fastInverseSqrt
public static float fastInverseSqrt(float x)
Fast inverse square root on floats - amusing hack used in Quake
-
sin
public static float sin(double a)
Float-returning version of Math.sin
-
cos
public static float cos(double a)
Float-returning version of Math.cos
-
sin
public static float sin(float a)
Float-returning version of Math.sin
-
tanh
public static float tanh(float x)
float version of Math.tanh
-
tanhDerivative
public static float tanhDerivative(float x)
-
cos
public static float cos(float a)
Float-returning version of Math.cos
-
-
DMelt 3.0 © DataMelt by jWork.ORG