Package com.boole.jgmp.math.helpers
Class JGMPFloatH
java.lang.Object
com.boole.jgmp.math.helpers.JGMPFloatH
Floats Helper with useful algorithms and tools for optimized usage of floats and floating point mathematical calculations.
Includes Linear Algebra types and functions such as Vector Math.
Includes Linear Algebra types and functions such as Vector Math.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
approxEqual
(float a, float b) Checks whether 2 floats are approximately equal with a relative error of the epsilon.static float
bezierInterp1D
(JGMPVector2 initial, JGMPVector2 ending, float r) 1D Cubic Bezier Curve Interpolationstatic JGMPVector2
bezierInterp2D
(JGMPVector2[] points, float r) 2D Cubic Bezier Curve Interpolationstatic float
clamp
(float v, float min, float max) Clamps a float between the min and maxstatic float
inverseLerp
(float initial, float ending, float t) Inverse Lerping floats given start and endstatic float
lerp
(float initial, float ending, float t) Lerping floats given start and endstatic float
max
(float a, float b) Maximum between 2 floatsstatic float
min
(float a, float b) Minimum between 2 floatsstatic float
remap
(float fval, float fmin, float fmax, float tmin, float tmax) Remapping float valuesstatic float
roundDownToMultiple
(float v, float mult) Rounds the given float value down to a near multiple.static float
roundToMultiple
(float v, float mult) Rounds the given float value to a near multiple.static float
roundUpToMultiple
(float v, float mult) Rounds the given float value up to a near multiple.static float
sign
(float v) Sign of the given float
-
Constructor Details
-
JGMPFloatH
public JGMPFloatH()
-
-
Method Details
-
min
public static float min(float a, float b) Minimum between 2 floats- Parameters:
a
- floatb
- float- Returns:
- minimum of the 2 floats
-
max
public static float max(float a, float b) Maximum between 2 floats- Parameters:
a
- floatb
- float- Returns:
- maximum of the 2 floats
-
clamp
public static float clamp(float v, float min, float max) Clamps a float between the min and max- Parameters:
v
- float valuemin
- min float capacitymax
- max float capacity- Returns:
- clamped float value
-
lerp
public static float lerp(float initial, float ending, float t) Lerping floats given start and end- Parameters:
initial
- starting point floatending
- ending point floatt
- float t- Returns:
- lerped float value
-
inverseLerp
public static float inverseLerp(float initial, float ending, float t) Inverse Lerping floats given start and end- Parameters:
initial
- starting point floatending
- ending point floatt
- float t- Returns:
- inversely lerped float value
-
bezierInterp1D
1D Cubic Bezier Curve Interpolation- Parameters:
initial
- starting pointending
- ending pointr
- ratio float- Returns:
- interp float value
-
bezierInterp2D
2D Cubic Bezier Curve Interpolation- Parameters:
points
- array of pointsr
- ratio float- Returns:
- interp float value
-
remap
public static float remap(float fval, float fmin, float fmax, float tmin, float tmax) Remapping float values- Parameters:
fval
- float valuefmin
- min float capacityfmax
- max float capacitytmin
- t min float capacitytmax
- t max float capacity- Returns:
- remapping float values
-
approxEqual
public static boolean approxEqual(float a, float b) Checks whether 2 floats are approximately equal with a relative error of the epsilon.- Parameters:
a
- first float value to compareb
- second float value to compare- Returns:
- boolean indicating if the 2 floats are approximately equal.
-
sign
public static float sign(float v) Sign of the given float- Parameters:
v
- float value- Returns:
- sign float value of v
-
roundToMultiple
public static float roundToMultiple(float v, float mult) Rounds the given float value to a near multiple.
This is not entirely accurate, but the algorithm works accurate enough.- Parameters:
v
- float valuemult
- float multiple- Returns:
- rounded multiple
-
roundUpToMultiple
public static float roundUpToMultiple(float v, float mult) Rounds the given float value up to a near multiple.
This is not entirely accurate, but the algorithm works accurate enough.- Parameters:
v
- float valuemult
- float multiple- Returns:
- rounded up multiple
-
roundDownToMultiple
public static float roundDownToMultiple(float v, float mult) Rounds the given float value down to a near multiple.
This is not entirely accurate, but the algorithm works accurate enough.- Parameters:
v
- float valuemult
- float multiple- Returns:
- rounded down multiple
-