docs.unity3d.com
    Show / Hide Table of Contents

    Class MathUtility

    Math utilities.

    Inheritance
    Object
    MathUtility
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.XR.CoreUtils
    Syntax
    public static class MathUtility

    Methods

    Approximately(Single, Single)

    A faster replacement for Approximately.

    Declaration
    public static bool Approximately(float a, float b)
    Parameters
    Type Name Description
    Single a

    The first float to compare.

    Single b

    The second float to compare.

    Returns
    Type Description
    Boolean
    Remarks

    Compares two floating point values and returns true if they are similar. As an optimization, this method does not take into account the magnitude of the values it is comparing. This method may not provide the same results as Mathf.Approximately for extremely large values.

    ApproximatelyZero(Single)

    A slightly faster way to do Approximately(a, 0f).

    Declaration
    public static bool ApproximatelyZero(float a)
    Parameters
    Type Name Description
    Single a

    The floating point value to compare with 0.

    Returns
    Type Description
    Boolean

    Clamp(Double, Double, Double)

    Constrains a value between a minimum and a maximum.

    Declaration
    public static double Clamp(double input, double min, double max)
    Parameters
    Type Name Description
    Double input

    The input number.

    Double min

    The minimum output.

    Double max

    The maximum output.

    Returns
    Type Description
    Double

    The input number, clamped between min and max (inclusive).

    FirstActiveFlagIndex(Int32)

    Returns the index of the first true bit of a flag.

    Declaration
    public static int FirstActiveFlagIndex(int value)
    Parameters
    Type Name Description
    Int32 value

    The flags value to check.

    Returns
    Type Description
    Int32

    The index of the first active flag.

    IsAxisAligned(Vector3)

    Checks if a vector is aligned with one of the axis vectors.

    Declaration
    public static bool IsAxisAligned(this Vector3 v)
    Parameters
    Type Name Description
    Vector3 v

    The vector.

    Returns
    Type Description
    Boolean

    True if the vector is aligned with any axis, otherwise false.

    IsPositivePowerOfTwo(Int32)

    Checks if a value is a positive power of two.

    Declaration
    public static bool IsPositivePowerOfTwo(int value)
    Parameters
    Type Name Description
    Int32 value

    The value to check.

    Returns
    Type Description
    Boolean

    True if the value is a positive power of two, false otherwise.

    IsUndefined(Single)

    Checks whether a value is undefined (PositiveInfinity, NegativeInfinity, or NaN).

    Declaration
    public static bool IsUndefined(this float value)
    Parameters
    Type Name Description
    Single value

    The float value.

    Returns
    Type Description
    Boolean

    True if the value is infinity or NaN (not a number), otherwise false.

    See Also
    IsInfinity(Single)
    IsNaN(Single)

    ShortestAngleDistance(Double, Double, Double, Double)

    Finds the smallest angle between two angles.

    Declaration
    public static double ShortestAngleDistance(double start, double end, double halfMax, double max)
    Parameters
    Type Name Description
    Double start

    The start value.

    Double end

    The end value.

    Double halfMax

    Half of the max angle.

    Double max

    The max angle value.

    Returns
    Type Description
    Double

    The angle distance between start and end.

    ShortestAngleDistance(Single, Single, Single, Single)

    Finds the smallest angle between two angles.

    Declaration
    public static float ShortestAngleDistance(float start, float end, float halfMax, float max)
    Parameters
    Type Name Description
    Single start

    The start value.

    Single end

    The end value.

    Single halfMax

    Half of the max angle.

    Single max

    The max angle value.

    Returns
    Type Description
    Single

    The angle distance between start and end.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023