MathHelperStay organized with collectionsSave and categorize content based on your preferences.
Page Summary
TheMathHelperclass 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.
public
static
booleanalmostEqualRelativeAndAbs(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
floatclamp(float value, float min, float max)
Clamps a value between a minimum and maximum range.
Parameters
value
min
max
public
static
floatlerp(float a, float b, float t)
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-26 UTC."],[],["The `MathHelper` class provides static functions for math operations. It includes `almostEqualRelativeAndAbs(float a, float b)` to compare floats within a tolerance, `clamp(float value, float min, float max)` to restrict a value within a range, and `lerp(float a, float b, float t)` for linear interpolation between two values by a given ratio. Additionally, the class inherits several methods from `java.lang.Object` like `equals()`, `hashCode()`, and `toString()`.\n"]]