Page Summary
-
The
MathHelperclass provides static functions for common mathematical operations. -
It includes methods for comparing floats with tolerance (
almostEqualRelativeAndAbs), clamping values within a range (clamp), and linear interpolation (lerp). -
These functions are designed to simplify common math tasks in AR development.
-
The class is part of the Sceneform library and helps with tasks like comparing float values, clamping them within bounds, and smooth transitions between values using interpolation.
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