Mathf
static class in UnityEngine · UnityEngine.CoreModule
Float math helpers. Behavior (rounding mode, edge cases, constants) is verified against Unity in conformance/recordings/math_mathf.jsonl.
Fields 6
const float Deg2Radstatic readonly float EpsilonThe smallest positive float (denormal) on desktop platforms.
const float Infinityconst float NegativeInfinityconst float PIconst float Rad2DegMethods 43
static float Abs(float f)static int Abs(int value)static float Acos(float f)static bool Approximately(float a, float b)True if a and b differ by less than a millionth of the larger magnitude.
static float Asin(float f)static float Atan(float f)static float Atan2(float y, float x)static float Ceil(float f)static int CeilToInt(float f)static float Clamp(float value, float min, float max)static int Clamp(int value, int min, int max)static float Clamp01(float value)static int ClosestPowerOfTwo(int value)Ties round up (96 gives 128).
static float Cos(float f)static float DeltaAngle(float current, float target)Shortest signed difference between two angles, in (-180, 180].
static float Exp(float power)static float Floor(float f)static int FloorToInt(float f)static float GammaToLinearSpace(float value)sRGB transfer function, gamma to linear.
static float InverseLerp(float a, float b, float value)static bool IsPowerOfTwo(int value)Note: 0 counts as a power of two, as in Unity.
static float Lerp(float a, float b, float t)static float LerpAngle(float a, float b, float t)Lerp that takes the short way around 360 degrees.
static float LerpUnclamped(float a, float b, float t)static float LinearToGammaSpace(float value)sRGB transfer function, linear to gamma.
static float Log(float f, float p)static float Log(float f)static float Log10(float f)static float Max(float a, float b)static float Max(params float[] values)static int Max(int a, int b)static int Max(params int[] values)static float Min(float a, float b)static float Min(params float[] values)static int Min(int a, int b)static int Min(params int[] values)static float MoveTowards(float current, float target, float maxDelta)static float MoveTowardsAngle(float current, float target, float maxDelta)static int NextPowerOfTwo(int value)static float PerlinNoise(float x, float y)2D Perlin noise, roughly in [0, 1]. Matches Unity: Ken Perlin's improved noise at z = 0, on |x| and |y| (so it mirrors around 0), mapped by (n + 0.69) / 1.483 (0.4652731 at integer coordinates).
static float PingPong(float t, float length)static float Pow(float f, float p)static float Repeat(float t, float length)Wraps t into [0, length].
static float Round(float f)static int RoundToInt(float f)static float Sign(float f)1 for zero and positive values, -1 for negative ones.
static float Sin(float f)static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime)static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed)static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime)Critically damped spring towards target (the approximation from Game Programming Gems 4, ch. 1.10).
static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime)static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed)static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime)static float SmoothStep(float from, float to, float t)static float Sqrt(float f)static float Tan(float f)Not in Tassix yet 5
CorrelatedColorTemperatureToRGB FloatToHalf Gamma HalfToFloat PerlinNoise1D
Checked against Unity
Conformance scenarios that exercise it, recorded in Unity and compared event by event.