# Mathf

> A collection of common math functions.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public struct Mathf
```

## Static Fields

| Value                                                                                     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Deg2Rad](/engine/6000.0/script-reference/unityengine/mathf/deg2rad.md)                   | Degrees-to-radians conversion constant (Read Only).                                                                                                                                                                                                                                                                                                                                                                                               |
| [Epsilon](/engine/6000.0/script-reference/unityengine/mathf/epsilon.md)                   | The smallest positive non-zero value that a float can represent. Using `Mathf.Epsilon` as a delta for equality makes the comparison effectively identical to exact equality on normal-range numbers. For an approximately equal value, use [Mathf.Approximately](/engine/6000.0/script-reference/unityengine/mathf/approximately.md) or a tolerance that reflects your data’s scale, typically a combination of absolute and relative tolerances. |
| [Infinity](/engine/6000.0/script-reference/unityengine/mathf/infinity.md)                 | A representation of positive infinity (Read Only).                                                                                                                                                                                                                                                                                                                                                                                                |
| [NegativeInfinity](/engine/6000.0/script-reference/unityengine/mathf/negativeinfinity.md) | A representation of negative infinity (Read Only).                                                                                                                                                                                                                                                                                                                                                                                                |
| [PI](/engine/6000.0/script-reference/unityengine/mathf/pi.md)                             | The well-known *3.14159265358979...* value (Read Only).                                                                                                                                                                                                                                                                                                                                                                                           |
| [Rad2Deg](/engine/6000.0/script-reference/unityengine/mathf/rad2deg.md)                   | Radians-to-degrees conversion constant (Read Only).                                                                                                                                                                                                                                                                                                                                                                                               |

## Static Methods

| Method                                                                                                                  | Description                                                                                                                                                                              |
| ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Abs](/engine/6000.0/script-reference/unityengine/mathf/abs.md)                                                         | Returns the absolute value of `value`.                                                                                                                                                   |
| [Acos](/engine/6000.0/script-reference/unityengine/mathf/acos.md)                                                       | Returns the arc-cosine of f - the angle in radians whose cosine is f.                                                                                                                    |
| [Approximately](/engine/6000.0/script-reference/unityengine/mathf/approximately.md)                                     | Compares two floating point values and returns true if they are similar.                                                                                                                 |
| [Asin](/engine/6000.0/script-reference/unityengine/mathf/asin.md)                                                       | Returns the arc-sine of f - the angle in radians whose sine is f.                                                                                                                        |
| [Atan](/engine/6000.0/script-reference/unityengine/mathf/atan.md)                                                       | Returns the arc-tangent of f - the angle in radians whose tangent is f.                                                                                                                  |
| [Atan2](/engine/6000.0/script-reference/unityengine/mathf/atan2.md)                                                     | Returns the angle in radians whose [Mathf.Tan](/engine/6000.0/script-reference/unityengine/mathf/tan.md) is `y/x`.                                                                       |
| [Ceil](/engine/6000.0/script-reference/unityengine/mathf/ceil.md)                                                       | Returns the smallest integer greater than or equal to f.                                                                                                                                 |
| [CeilToInt](/engine/6000.0/script-reference/unityengine/mathf/ceiltoint.md)                                             | Returns the smallest integer greater to or equal to f.                                                                                                                                   |
| [Clamp](/engine/6000.0/script-reference/unityengine/mathf/clamp.md)                                                     | Clamps the given value between a range defined by the given minimum integer and maximum integer values. Returns the given value if it is within min and max.                             |
| [Clamp01](/engine/6000.0/script-reference/unityengine/mathf/clamp01.md)                                                 | Clamps value between 0 and 1 and returns value.                                                                                                                                          |
| [ClosestPowerOfTwo](/engine/6000.0/script-reference/unityengine/mathf/closestpoweroftwo.md)                             | Returns the closest power of two value.                                                                                                                                                  |
| [CorrelatedColorTemperatureToRGB](/engine/6000.0/script-reference/unityengine/mathf/correlatedcolortemperaturetorgb.md) | Convert a color temperature in Kelvin to RGB color.                                                                                                                                      |
| [Cos](/engine/6000.0/script-reference/unityengine/mathf/cos.md)                                                         | Returns the cosine of angle f.                                                                                                                                                           |
| [DeltaAngle](/engine/6000.0/script-reference/unityengine/mathf/deltaangle.md)                                           | Calculates the shortest difference between two angles.                                                                                                                                   |
| [Exp](/engine/6000.0/script-reference/unityengine/mathf/exp.md)                                                         | Returns e raised to the specified power.                                                                                                                                                 |
| [FloatToHalf](/engine/6000.0/script-reference/unityengine/mathf/floattohalf.md)                                         | Encode a floating point value into a 16-bit representation.                                                                                                                              |
| [Floor](/engine/6000.0/script-reference/unityengine/mathf/floor.md)                                                     | Returns the largest integer smaller than or equal to f.                                                                                                                                  |
| [FloorToInt](/engine/6000.0/script-reference/unityengine/mathf/floortoint.md)                                           | Returns the largest integer smaller to or equal to f.                                                                                                                                    |
| [GammaToLinearSpace](/engine/6000.0/script-reference/unityengine/mathf/gammatolinearspace.md)                           | Converts the given value from gamma (sRGB) to linear color space.                                                                                                                        |
| [HalfToFloat](/engine/6000.0/script-reference/unityengine/mathf/halftofloat.md)                                         | Convert a half precision float to a 32-bit floating point value.                                                                                                                         |
| [InverseLerp](/engine/6000.0/script-reference/unityengine/mathf/inverselerp.md)                                         | Determines where a value lies between two points.                                                                                                                                        |
| [IsPowerOfTwo](/engine/6000.0/script-reference/unityengine/mathf/ispoweroftwo.md)                                       | Returns true if the value is power of two.                                                                                                                                               |
| [Lerp](/engine/6000.0/script-reference/unityengine/mathf/lerp.md)                                                       | Linearly interpolates between a and b by t.                                                                                                                                              |
| [LerpAngle](/engine/6000.0/script-reference/unityengine/mathf/lerpangle.md)                                             | Same as [Mathf.Lerp](/engine/6000.0/script-reference/unityengine/mathf/lerp.md) but makes sure the values interpolate correctly when they wrap around 360 degrees.                       |
| [LerpUnclamped](/engine/6000.0/script-reference/unityengine/mathf/lerpunclamped.md)                                     | Linearly interpolates between a and b by t with no limit to t.                                                                                                                           |
| [LinearToGammaSpace](/engine/6000.0/script-reference/unityengine/mathf/lineartogammaspace.md)                           | Converts the given value from linear to gamma (sRGB) color space.                                                                                                                        |
| [Log](/engine/6000.0/script-reference/unityengine/mathf/log.md)                                                         | Returns the natural (base e) logarithm of a specified number.                                                                                                                            |
| [Log10](/engine/6000.0/script-reference/unityengine/mathf/log10.md)                                                     | Returns the base 10 logarithm of a specified number.                                                                                                                                     |
| [Max](/engine/6000.0/script-reference/unityengine/mathf/max.md)                                                         | Returns the largest value. When comparing negative values, values closer to zero are considered larger.                                                                                  |
| [Min](/engine/6000.0/script-reference/unityengine/mathf/min.md)                                                         | Returns the smallest of two or more values.                                                                                                                                              |
| [MoveTowards](/engine/6000.0/script-reference/unityengine/mathf/movetowards.md)                                         | Moves a value current towards target.                                                                                                                                                    |
| [MoveTowardsAngle](/engine/6000.0/script-reference/unityengine/mathf/movetowardsangle.md)                               | Same as [Mathf.MoveTowards](/engine/6000.0/script-reference/unityengine/mathf/movetowards.md) but makes sure the values interpolate correctly when they wrap around 360 degrees.         |
| [NextPowerOfTwo](/engine/6000.0/script-reference/unityengine/mathf/nextpoweroftwo.md)                                   | Returns the next power of two that is equal to, or greater than, the argument.                                                                                                           |
| [PerlinNoise](/engine/6000.0/script-reference/unityengine/mathf/perlinnoise.md)                                         | Generate 2D Perlin noise.                                                                                                                                                                |
| [PerlinNoise1D](/engine/6000.0/script-reference/unityengine/mathf/perlinnoise1d.md)                                     | Generates a 1D pseudo-random pattern of float values across a 2D plane.                                                                                                                  |
| [PingPong](/engine/6000.0/script-reference/unityengine/mathf/pingpong.md)                                               | PingPong returns a value that increments and decrements between zero and the length. It follows the triangle wave formula where the bottom is set to zero and the peak is set to length. |
| [Pow](/engine/6000.0/script-reference/unityengine/mathf/pow.md)                                                         | Returns f raised to power p.                                                                                                                                                             |
| [Repeat](/engine/6000.0/script-reference/unityengine/mathf/repeat.md)                                                   | Loops the value t, so that it is never larger than length and never smaller than 0.                                                                                                      |
| [Round](/engine/6000.0/script-reference/unityengine/mathf/round.md)                                                     | Returns f rounded to the nearest integer.                                                                                                                                                |
| [RoundToInt](/engine/6000.0/script-reference/unityengine/mathf/roundtoint.md)                                           | Returns f rounded to the nearest integer.                                                                                                                                                |
| [Sign](/engine/6000.0/script-reference/unityengine/mathf/sign.md)                                                       | Returns the sign of f.                                                                                                                                                                   |
| [Sin](/engine/6000.0/script-reference/unityengine/mathf/sin.md)                                                         | Returns the sine of angle f.                                                                                                                                                             |
| [SmoothDamp](/engine/6000.0/script-reference/unityengine/mathf/smoothdamp.md)                                           | Gradually moves the current value towards a target value, over a specified time and at a specified velocity.                                                                             |
| [SmoothDampAngle](/engine/6000.0/script-reference/unityengine/mathf/smoothdampangle.md)                                 | Gradually changes an angle given in degrees towards a desired goal angle over time.                                                                                                      |
| [SmoothStep](/engine/6000.0/script-reference/unityengine/mathf/smoothstep.md)                                           | Interpolates between from and to with smoothing at the limits.                                                                                                                           |
| [Sqrt](/engine/6000.0/script-reference/unityengine/mathf/sqrt.md)                                                       | Returns square root of f.                                                                                                                                                                |
| [Tan](/engine/6000.0/script-reference/unityengine/mathf/tan.md)                                                         | Returns the tangent of angle f in radians.                                                                                                                                               |
