Skip to content

API > Mathf


Mathf⚓︎

A collection of common math functions.
Unity Mathf

Members⚓︎

Static Properties⚓︎

Name Description
Mathf.Deg2Rad Static fieldPropertyReadonly Property Degrees-to-radians conversion constant (Read Only).
Mathf.Epsilon Static fieldPropertyReadonly Property A tiny numerical value (Read Only). The smallest value that a number (i.e. double) can have different from zero.
Mathf.Infinity Static fieldPropertyReadonly Property A representation of positive infinity (Read Only).
Mathf.NegativeInfinity Static fieldPropertyReadonly Property A representation of negative infinity (Read Only).
Mathf.PI Static fieldPropertyReadonly Property The well-known 3.14159265358979... value (Read Only).
Mathf.Rad2Deg Static fieldPropertyReadonly Property Radians-to-degrees conversion constant (Read Only).

Static Methods⚓︎

Name Description
Mathf.Abs(value) Static fieldMethod Returns the absolute value of f.
Mathf.Acos(f) Static fieldMethod Returns the arc-cosine of f - the angle in radians whose cosine is f.
Mathf.Approximately(a, b) Static fieldMethod Compares two floating point values and returns true if they are similar.
Mathf.Asin(f) Static fieldMethod Returns the arc-sine of f - the angle in radians whose sine is f.
Mathf.Atan(f) Static fieldMethod Returns the arc-tangent of f - the angle in radians whose tangent is f.
Mathf.Atan2(y, x) Static fieldMethod Returns the angle in radians whose Tan is y/x.
Mathf.Ceil(f) Static fieldMethod Returns the smallest integer greater to or equal to f.
Mathf.Clamp(value, min, max) Static fieldMethod Clamps the given value between the given minimum float and maximum float values. Returns the given value if it is within the min and max range.
Mathf.Clamp01(value) Static fieldMethod Clamps value between 0 and 1 and returns value.
Mathf.ClosestPowerOfTwo(value) Static fieldMethod Returns the closest power of two value.
Mathf.CorrelatedColorTemperatureToRGB(Kelvin) Static fieldMethod Convert a color temperature in Kelvin to RGB color.
Mathf.Cos(f) Static fieldMethod Returns the cosine of angle f.
Mathf.DeltaAngle(current, target) Static fieldMethod Calculates the shortest difference between two given angles given in degrees.
Mathf.Exp(power) Static fieldMethod Returns e raised to the specified power.
Mathf.Floor(f) Static fieldMethod Returns the largest integer smaller than or equal to f.
Mathf.GammaToLinearSpace(value) Static fieldMethod Converts the given value from gamma (sRGB) to linear color space.
Mathf.InverseLerp(a, b, value) Static fieldMethod Calculates the linear parameter t that produces the interpolant value within the range [a, b].
Mathf.IsPowerOfTwo(value) Static fieldMethod Returns true if the value is power of two.
Mathf.Lerp(a, b, t) Static fieldMethod Linearly interpolates between a and b by t.
Mathf.LerpAngle(a, b, t) Static fieldMethod Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
Mathf.LerpUnclamped(a, b, t) Static fieldMethod Linearly interpolates between a and b by t with no limit to t.
Mathf.Log(f, p) Static fieldMethod Returns the logarithm of a specified number in a specified base.
Mathf.Log(f) Static fieldMethod Returns the natural (base e) logarithm of a specified number.
Mathf.Log10(f) Static fieldMethod Returns the base 10 logarithm of a specified number.
Mathf.Max(a, b) Static fieldMethod Returns largest of two or more values.
Mathf.Max( values[]) Static fieldMethod Returns largest of two or more values.
Mathf.Min(a, b) Static fieldMethod Returns the smallest of two values.
Mathf.Min( values[]) Static fieldMethod Returns the smallest of the values.
Mathf.MoveTowards(current, target, maxDelta) Static fieldMethod Moves a value current towards target.
Mathf.MoveTowardsAngle(current, target, maxDelta) Static fieldMethod Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
Mathf.NextPowerOfTwo(value) Static fieldMethod Returns the next power of two that is equal to, or greater than, the argument.
Mathf.PerlinNoise(x, y) Static fieldMethod Generate 2D Perlin noise.
Mathf.PingPong(t, length) Static fieldMethod PingPong returns a value that will increment and decrement between the value 0 and length.
Mathf.Pow(f, p) Static fieldMethod Returns f raised to power p.
Mathf.Repeat(t, length) Static fieldMethod Loops the value t, so that it is never larger than length and never smaller than 0.
Mathf.Round(f) Static fieldMethod Returns f rounded to the nearest integer.
Mathf.Sign(f) Static fieldMethod Returns the sign of f.
Mathf.Sin(f) Static fieldMethod Returns the sine of angle f.
Mathf.SmoothStep(from, to, t) Static fieldMethod Interpolates between min and max with smoothing at the limits.
Mathf.Sqrt(f) Static fieldMethod Returns square root of f.
Mathf.Tan(f) Static fieldMethod Returns the tangent of angle f in radians.