- Sceneform SDK for Android
was open sourced and archived ( github.com/google-ar/sceneform-android-sdk
) with version 1.16.0.
- This site ( developers.google.com/sceneform
) serves as the documentation archive for the previous version, Sceneform SDK for Android
1.15.0.
- Do not use version 1.17.0 of the Sceneform Maven artifacts
.
- The 1.17.1 Maven artifacts can be used. Other than the version, however, the 1.17.1 artifacts are identical to the 1.15.0 artifacts.
MathHelper
Stay organized with collections
Save and categorize content based on your preferences.
Static functions for common math operations.
Public Methods
static
boolean |
|
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
From class
java.lang.Object
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.
public
static
float
clamp
(float value, float min, float max)
Clamps a value between a minimum and maximum range.
public
static
float
lerp
(float a, float b, float t)
Linearly interpolates between a and b by a ratio.
Parameters
Returns
- interpolated value between the two floats
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-26 UTC.
[[["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."],[[["\u003cp\u003eThe \u003ccode\u003eMathHelper\u003c/code\u003e class provides static functions for common mathematical operations.\u003c/p\u003e\n"],["\u003cp\u003eIt includes methods for comparing floats with tolerance (\u003ccode\u003ealmostEqualRelativeAndAbs\u003c/code\u003e), clamping values within a range (\u003ccode\u003eclamp\u003c/code\u003e), and linear interpolation (\u003ccode\u003elerp\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eThese functions are designed to simplify common math tasks in AR development.\u003c/p\u003e\n"],["\u003cp\u003eThe 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.\u003c/p\u003e\n"]]],["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"],null,["# MathHelper\n\npublic class **MathHelper** \nStatic functions for common math operations. \n\n### Public Constructors\n\n|---|-------------------------------------------------------------------------------------------|\n| | [MathHelper](/sceneform/reference/com/google/ar/sceneform/math/MathHelper#MathHelper())() |\n\n### Public Methods\n\n|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static boolean | [almostEqualRelativeAndAbs](/sceneform/reference/com/google/ar/sceneform/math/MathHelper#almostEqualRelativeAndAbs(float,%20float))(float a, float b) Returns true if two floats are equal within a tolerance. |\n| static float | [clamp](/sceneform/reference/com/google/ar/sceneform/math/MathHelper#clamp(float,%20float,%20float))(float value, float min, float max) Clamps a value between a minimum and maximum range. |\n| static float | [lerp](/sceneform/reference/com/google/ar/sceneform/math/MathHelper#lerp(float,%20float,%20float))(float a, float b, float t) Linearly interpolates between a and b by a ratio. |\n\n### Inherited Methods\n\nFrom class java.lang.Object \n\n|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------|\n| [Object](https://developer.android.com/reference/java/lang/Object) | clone() |\n| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object) arg0) |\n| void | finalize() |\n| final [Class](https://developer.android.com/reference/java/lang/Class)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](https://developer.android.com/reference/java/lang/String) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public\n**MathHelper**\n()\n\n\u003cbr /\u003e\n\nPublic Methods\n--------------\n\n#### public static boolean\n**almostEqualRelativeAndAbs**\n(float a, float b)\n\nReturns true if two floats are equal within a tolerance. Useful for comparing floating point\nnumbers while accounting for the limitations in floating point precision. \n\n##### Parameters\n\n| a | |\n| b | |\n|---|---|\n\n#### public static float\n**clamp**\n(float value, float min, float max)\n\nClamps a value between a minimum and maximum range. \n\n##### Parameters\n\n| value | |\n| min | |\n| max | |\n|-------|---|\n\n#### public static float\n**lerp**\n(float a, float b, float t)\n\nLinearly interpolates between a and b by a ratio. \n\n##### Parameters\n\n| a | the beginning value |\n| b | the ending value |\n| t | ratio between the two floats |\n|---|------------------------------|\n\n##### Returns\n\n- interpolated value between the two floats"]]