MathHelper

public class MathHelper

Static functions for common math operations.

Public Constructors

Public Methods

static boolean
almostEqualRelativeAndAbs(float a, float b)
Returns true if two floats are equal within a tolerance.
static float
clamp(float value, float min, float max)
Clamps a value between a minimum and maximum range.
static float
lerp(float a, float b, float t)
Linearly interpolates between a and b by a ratio.

Inherited Methods

Public Constructors

public MathHelper ()

Public Methods

public static boolean almostEqualRelativeAndAbs (float a, float b)

Returns true if two floats are equal within a tolerance. Useful for comparing floating point numbers while accounting for the limitations in floating point precision.

Parameters
a
b

public static float clamp (float value, float min, float max)

Clamps a value between a minimum and maximum range.

Parameters
value
min
max

public static float lerp (float a, float b, float t)

Linearly interpolates between a and b by a ratio.

Parameters
a the beginning value
b the ending value
t ratio between the two floats
Returns
  • interpolated value between the two floats