Class JGMPFloatH

java.lang.Object
com.boole.jgmp.math.helpers.JGMPFloatH

public class JGMPFloatH extends Object
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.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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 Interpolation
    bezierInterp2D(JGMPVector2[] points, float r)
    2D Cubic Bezier Curve Interpolation
    static float
    clamp(float v, float min, float max)
    Clamps a float between the min and max
    static float
    inverseLerp(float initial, float ending, float t)
    Inverse Lerping floats given start and end
    static float
    lerp(float initial, float ending, float t)
    Lerping floats given start and end
    static float
    max(float a, float b)
    Maximum between 2 floats
    static float
    min(float a, float b)
    Minimum between 2 floats
    static float
    remap(float fval, float fmin, float fmax, float tmin, float tmax)
    Remapping float values
    static 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JGMPFloatH

      public JGMPFloatH()
  • Method Details

    • min

      public static float min(float a, float b)
      Minimum between 2 floats
      Parameters:
      a - float
      b - float
      Returns:
      minimum of the 2 floats
    • max

      public static float max(float a, float b)
      Maximum between 2 floats
      Parameters:
      a - float
      b - 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 value
      min - min float capacity
      max - 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 float
      ending - ending point float
      t - 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 float
      ending - ending point float
      t - float t
      Returns:
      inversely lerped float value
    • bezierInterp1D

      public static float bezierInterp1D(JGMPVector2 initial, JGMPVector2 ending, float r)
      1D Cubic Bezier Curve Interpolation
      Parameters:
      initial - starting point
      ending - ending point
      r - ratio float
      Returns:
      interp float value
    • bezierInterp2D

      public static JGMPVector2 bezierInterp2D(JGMPVector2[] points, float r)
      2D Cubic Bezier Curve Interpolation
      Parameters:
      points - array of points
      r - 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 value
      fmin - min float capacity
      fmax - max float capacity
      tmin - t min float capacity
      tmax - 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 compare
      b - 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 value
      mult - 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 value
      mult - 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 value
      mult - float multiple
      Returns:
      rounded down multiple