Show / Hide Table of Contents

Struct Mathf

Inherited Members
ValueType.Equals(Object)
ValueType.GetHashCode()
ValueType.ToString()
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetType()
Namespace: UnityEngine
Assembly: UnityEngine.dll
Syntax
public struct Mathf

Fields

| Improve this Doc View Source

Deg2Rad

Declaration
public const float Deg2Rad = 0.0174532924F
Field Value
Type Description
Single
| Improve this Doc View Source

Epsilon

Declaration
public static readonly float Epsilon
Field Value
Type Description
Single
| Improve this Doc View Source

Infinity

Declaration
public const float Infinity = InfinityF
Field Value
Type Description
Single
| Improve this Doc View Source

NegativeInfinity

Declaration
public const float NegativeInfinity = -InfinityF
Field Value
Type Description
Single
| Improve this Doc View Source

PI

Declaration
public const float PI = 3.14159274F
Field Value
Type Description
Single
| Improve this Doc View Source

Rad2Deg

Declaration
public const float Rad2Deg = 57.29578F
Field Value
Type Description
Single

Methods

| Improve this Doc View Source

Abs(Int32)

Declaration
public static int Abs(int value)
Parameters
Type Name Description
Int32 value
Returns
Type Description
Int32
| Improve this Doc View Source

Abs(Single)

Declaration
public static float Abs(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

Acos(Single)

Declaration
public static float Acos(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

Approximately(Single, Single)

Declaration
public static bool Approximately(float a, float b)
Parameters
Type Name Description
Single a
Single b
Returns
Type Description
Boolean
| Improve this Doc View Source

Asin(Single)

Declaration
public static float Asin(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

Atan(Single)

Declaration
public static float Atan(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

Atan2(Single, Single)

Declaration
public static float Atan2(float y, float x)
Parameters
Type Name Description
Single y
Single x
Returns
Type Description
Single
| Improve this Doc View Source

Ceil(Single)

Declaration
public static float Ceil(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

CeilToInt(Single)

Declaration
public static int CeilToInt(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Int32
| Improve this Doc View Source

Clamp(Int32, Int32, Int32)

Declaration
public static int Clamp(int value, int min, int max)
Parameters
Type Name Description
Int32 value
Int32 min
Int32 max
Returns
Type Description
Int32
| Improve this Doc View Source

Clamp(Single, Single, Single)

Declaration
public static float Clamp(float value, float min, float max)
Parameters
Type Name Description
Single value
Single min
Single max
Returns
Type Description
Single
| Improve this Doc View Source

Clamp01(Single)

Declaration
public static float Clamp01(float value)
Parameters
Type Name Description
Single value
Returns
Type Description
Single

ClosestPowerOfTwo(Int32)

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

CorrelatedColorTemperatureToRGB(Single)

Declaration
public static Color CorrelatedColorTemperatureToRGB(float kelvin)
Parameters
Type Name Description
Single kelvin
Returns
Type Description
Color
| Improve this Doc View Source

Cos(Single)

Declaration
public static float Cos(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

DeltaAngle(Single, Single)

Declaration
public static float DeltaAngle(float current, float target)
Parameters
Type Name Description
Single current
Single target
Returns
Type Description
Single
| Improve this Doc View Source

Exp(Single)

Declaration
public static float Exp(float power)
Parameters
Type Name Description
Single power
Returns
Type Description
Single

FloatToHalf(Single)

Declaration
public static ushort FloatToHalf(float val)
Parameters
Type Name Description
Single val
Returns
Type Description
UInt16
| Improve this Doc View Source

Floor(Single)

Declaration
public static float Floor(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

FloorToInt(Single)

Declaration
public static int FloorToInt(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Int32
| Improve this Doc View Source

Gamma(Single, Single, Single)

Declaration
public static float Gamma(float value, float absmax, float gamma)
Parameters
Type Name Description
Single value
Single absmax
Single gamma
Returns
Type Description
Single

GammaToLinearSpace(Single)

Declaration
public static float GammaToLinearSpace(float value)
Parameters
Type Name Description
Single value
Returns
Type Description
Single

HalfToFloat(UInt16)

Declaration
public static float HalfToFloat(ushort val)
Parameters
Type Name Description
UInt16 val
Returns
Type Description
Single
| Improve this Doc View Source

InverseLerp(Single, Single, Single)

Declaration
public static float InverseLerp(float a, float b, float value)
Parameters
Type Name Description
Single a
Single b
Single value
Returns
Type Description
Single

IsPowerOfTwo(Int32)

Declaration
public static bool IsPowerOfTwo(int value)
Parameters
Type Name Description
Int32 value
Returns
Type Description
Boolean
| Improve this Doc View Source

Lerp(Single, Single, Single)

Declaration
public static float Lerp(float a, float b, float t)
Parameters
Type Name Description
Single a
Single b
Single t
Returns
Type Description
Single
| Improve this Doc View Source

LerpAngle(Single, Single, Single)

Declaration
public static float LerpAngle(float a, float b, float t)
Parameters
Type Name Description
Single a
Single b
Single t
Returns
Type Description
Single
| Improve this Doc View Source

LerpUnclamped(Single, Single, Single)

Declaration
public static float LerpUnclamped(float a, float b, float t)
Parameters
Type Name Description
Single a
Single b
Single t
Returns
Type Description
Single

LinearToGammaSpace(Single)

Declaration
public static float LinearToGammaSpace(float value)
Parameters
Type Name Description
Single value
Returns
Type Description
Single
| Improve this Doc View Source

Log(Single)

Declaration
public static float Log(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

Log(Single, Single)

Declaration
public static float Log(float f, float p)
Parameters
Type Name Description
Single f
Single p
Returns
Type Description
Single
| Improve this Doc View Source

Log10(Single)

Declaration
public static float Log10(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

Max(Int32, Int32)

Declaration
public static int Max(int a, int b)
Parameters
Type Name Description
Int32 a
Int32 b
Returns
Type Description
Int32
| Improve this Doc View Source

Max(Int32[])

Declaration
public static int Max(params int[] values)
Parameters
Type Name Description
Int32[] values
Returns
Type Description
Int32
| Improve this Doc View Source

Max(Single, Single)

Declaration
public static float Max(float a, float b)
Parameters
Type Name Description
Single a
Single b
Returns
Type Description
Single
| Improve this Doc View Source

Max(Single[])

Declaration
public static float Max(params float[] values)
Parameters
Type Name Description
Single[] values
Returns
Type Description
Single
| Improve this Doc View Source

Min(Int32, Int32)

Declaration
public static int Min(int a, int b)
Parameters
Type Name Description
Int32 a
Int32 b
Returns
Type Description
Int32
| Improve this Doc View Source

Min(Int32[])

Declaration
public static int Min(params int[] values)
Parameters
Type Name Description
Int32[] values
Returns
Type Description
Int32
| Improve this Doc View Source

Min(Single, Single)

Declaration
public static float Min(float a, float b)
Parameters
Type Name Description
Single a
Single b
Returns
Type Description
Single
| Improve this Doc View Source

Min(Single[])

Declaration
public static float Min(params float[] values)
Parameters
Type Name Description
Single[] values
Returns
Type Description
Single
| Improve this Doc View Source

MoveTowards(Single, Single, Single)

Declaration
public static float MoveTowards(float current, float target, float maxDelta)
Parameters
Type Name Description
Single current
Single target
Single maxDelta
Returns
Type Description
Single
| Improve this Doc View Source

MoveTowardsAngle(Single, Single, Single)

Declaration
public static float MoveTowardsAngle(float current, float target, float maxDelta)
Parameters
Type Name Description
Single current
Single target
Single maxDelta
Returns
Type Description
Single

NextPowerOfTwo(Int32)

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

PerlinNoise(Single, Single)

Declaration
public static float PerlinNoise(float x, float y)
Parameters
Type Name Description
Single x
Single y
Returns
Type Description
Single
| Improve this Doc View Source

PingPong(Single, Single)

Declaration
public static float PingPong(float t, float length)
Parameters
Type Name Description
Single t
Single length
Returns
Type Description
Single
| Improve this Doc View Source

Pow(Single, Single)

Declaration
public static float Pow(float f, float p)
Parameters
Type Name Description
Single f
Single p
Returns
Type Description
Single
| Improve this Doc View Source

Repeat(Single, Single)

Declaration
public static float Repeat(float t, float length)
Parameters
Type Name Description
Single t
Single length
Returns
Type Description
Single
| Improve this Doc View Source

Round(Single)

Declaration
public static float Round(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

RoundToInt(Single)

Declaration
public static int RoundToInt(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Int32
| Improve this Doc View Source

Sign(Single)

Declaration
public static float Sign(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

Sin(Single)

Declaration
public static float Sin(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

SmoothDamp(Single, Single, ref Single, Single)

Declaration
[ExcludeFromDocs]
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime)
Parameters
Type Name Description
Single current
Single target
Single currentVelocity
Single smoothTime
Returns
Type Description
Single
| Improve this Doc View Source

SmoothDamp(Single, Single, ref Single, Single, Single)

Declaration
[ExcludeFromDocs]
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed)
Parameters
Type Name Description
Single current
Single target
Single currentVelocity
Single smoothTime
Single maxSpeed
Returns
Type Description
Single
| Improve this Doc View Source

SmoothDamp(Single, Single, ref Single, Single, Single, Single)

Declaration
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, [DefaultValue("Mathf.Infinity")] float maxSpeed, [DefaultValue("Time.deltaTime")] float deltaTime)
Parameters
Type Name Description
Single current
Single target
Single currentVelocity
Single smoothTime
Single maxSpeed
Single deltaTime
Returns
Type Description
Single
| Improve this Doc View Source

SmoothDampAngle(Single, Single, ref Single, Single)

Declaration
[ExcludeFromDocs]
public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime)
Parameters
Type Name Description
Single current
Single target
Single currentVelocity
Single smoothTime
Returns
Type Description
Single
| Improve this Doc View Source

SmoothDampAngle(Single, Single, ref Single, Single, Single)

Declaration
[ExcludeFromDocs]
public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed)
Parameters
Type Name Description
Single current
Single target
Single currentVelocity
Single smoothTime
Single maxSpeed
Returns
Type Description
Single
| Improve this Doc View Source

SmoothDampAngle(Single, Single, ref Single, Single, Single, Single)

Declaration
public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, [DefaultValue("Mathf.Infinity")] float maxSpeed, [DefaultValue("Time.deltaTime")] float deltaTime)
Parameters
Type Name Description
Single current
Single target
Single currentVelocity
Single smoothTime
Single maxSpeed
Single deltaTime
Returns
Type Description
Single
| Improve this Doc View Source

SmoothStep(Single, Single, Single)

Declaration
public static float SmoothStep(float from, float to, float t)
Parameters
Type Name Description
Single from
Single to
Single t
Returns
Type Description
Single
| Improve this Doc View Source

Sqrt(Single)

Declaration
public static float Sqrt(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single
| Improve this Doc View Source

Tan(Single)

Declaration
public static float Tan(float f)
Parameters
Type Name Description
Single f
Returns
Type Description
Single

Extension Methods

MustExtensions.MustBeEqual<T>(T, T)
MustExtensions.MustBeEqual<T>(T, T, String)
MustExtensions.MustNotBeEqual<T>(T, T)
MustExtensions.MustNotBeEqual<T>(T, T, String)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX