Click or drag to resize

Mathf Methods

The Mathf type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAbs(Int32)
Returns the absolute value of `s` (i.e. positive value).
Public methodStatic memberAbs(Single)
Returns the absolute value of `s` (i.e. positive value).
Public methodStatic memberAcos
Returns the arc cosine of `s` in radians. Use to get the angle of cosine s.
Public methodStatic memberAsin
Returns the arc sine of `s` in radians. Use to get the angle of sine s.
Public methodStatic memberAtan
Returns the arc tangent of `s` in radians. Use to get the angle of tangent s. The method cannot know in which quadrant the angle should fall. See Atan2(Single, Single) if you have both `y` and `x`.
Public methodStatic memberAtan2
Returns the arc tangent of `y` and `x` in radians. Use to get the angle of the tangent of `y/x`. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant. Important note: The Y coordinate comes first, by convention.
Public methodStatic memberCartesian2Polar
Converts a 2D point expressed in the cartesian coordinate system (X and Y axis) to the polar coordinate system (a distance from the origin and an angle).
Public methodStatic memberCeil
Rounds `s` upward (towards positive infinity).
Public methodStatic memberCeilToInt
Rounds `s` upward (towards positive infinity). This is the same as Ceil(Single), but returns an `int`.
Public methodStatic memberClamp(Int32, Int32, Int32)
Clamps a `value` so that it is not less than `min` and not more than `max`.
Public methodStatic memberClamp(Single, Single, Single)
Clamps a `value` so that it is not less than `min` and not more than `max`.
Public methodStatic memberCos
Returns the cosine of angle `s` in radians.
Public methodStatic memberCosh
Returns the hyperbolic cosine of angle `s` in radians.
Public methodStatic memberDecimalCount(Decimal)
Returns the amount of digits after the decimal place.
Public methodStatic memberDecimalCount(Single)
Returns the amount of digits after the decimal place.
Public methodStatic memberDeg2Rad
Converts an angle expressed in degrees to radians.
Public methodStatic memberEase
Easing function, based on exponent. The curve values are: `0` is constant, `1` is linear, `0` to `1` is ease-in, `1` or more is ease-out. Negative values are in-out/out-in.
Public methodStatic memberExp
The natural exponential function. It raises the mathematical constant `e` to the power of `s` and returns it.
Public methodStatic memberFloor
Rounds `s` downward (towards negative infinity).
Public methodStatic memberFloorToInt
Rounds `s` downward (towards negative infinity). This is the same as Floor(Single), but returns an `int`.
Public methodStatic memberInverseLerp
Returns a normalized value considering the given range. This is the opposite of Lerp(Single, Single, Single).
Public methodStatic memberIsEqualApprox(Single, Single)
Returns true if `a` and `b` are approximately equal to each other. The comparison is done using a tolerance calculation with Epsilon.
Public methodStatic memberIsEqualApprox(Single, Single, Single)
Returns true if `a` and `b` are approximately equal to each other. The comparison is done using the provided tolerance value. If you want the tolerance to be calculated for you, use IsEqualApprox(Single, Single).
Public methodStatic memberIsInf
Returns whether `s` is an infinity value (either positive infinity or negative infinity).
Public methodStatic memberIsNaN
Returns whether `s` is a `NaN` ("Not a Number" or invalid) value.
Public methodStatic memberIsZeroApprox
Returns true if `s` is approximately zero. The comparison is done using a tolerance calculation with Epsilon. This method is faster than using IsEqualApprox(Single, Single) with one value as zero.
Public methodStatic memberLerp
Linearly interpolates between two values by a normalized value. This is the opposite InverseLerp(Single, Single, Single).
Public methodStatic memberLerpAngle
Linearly interpolates between two angles (in radians) by a normalized value. Similar to Lerp(Single, Single, Single), but interpolates correctly when the angles wrap around Tau.
Public methodStatic memberLog
Natural logarithm. The amount of time needed to reach a certain level of continuous growth. Note: This is not the same as the "log" function on most calculators, which uses a base 10 logarithm.
Public methodStatic memberMax(Int32, Int32)
Returns the maximum of two values.
Public methodStatic memberMax(Single, Single)
Returns the maximum of two values.
Public methodStatic memberMin(Int32, Int32)
Returns the minimum of two values.
Public methodStatic memberMin(Single, Single)
Returns the minimum of two values.
Public methodStatic memberMoveToward
Moves `from` toward `to` by the `delta` value. Use a negative delta value to move away.
Public methodStatic memberNearestPo2
Returns the nearest larger power of 2 for the integer `value`.
Public methodStatic memberPolar2Cartesian
Converts a 2D point expressed in the polar coordinate system (a distance from the origin `r` and an angle `th`) to the cartesian coordinate system (X and Y axis).
Public methodStatic memberPosMod(Int32, Int32)
Performs a canonical Modulus operation, where the output is on the range `[0, b)`.
Public methodStatic memberPosMod(Single, Single)
Performs a canonical Modulus operation, where the output is on the range `[0, b)`.
Public methodStatic memberPow
Returns the result of `x` raised to the power of `y`.
Public methodStatic memberRad2Deg
Converts an angle expressed in radians to degrees.
Public methodStatic memberRound
Rounds `s` to the nearest whole number, with halfway cases rounded towards the nearest multiple of two.
Public methodStatic memberRoundToInt
Public methodStatic memberSign(Int32)
Returns the sign of `s`: `-1` or `1`. Returns `0` if `s` is `0`.
Public methodStatic memberSign(Single)
Returns the sign of `s`: `-1` or `1`. Returns `0` if `s` is `0`.
Public methodStatic memberSin
Returns the sine of angle `s` in radians.
Public methodStatic memberSinh
Returns the hyperbolic sine of angle `s` in radians.
Public methodStatic memberSmoothStep
Returns a number smoothly interpolated between `from` and `to`, based on the `weight`. Similar to Lerp(Single, Single, Single), but interpolates faster at the beginning and slower at the end.
Public methodStatic memberSqrt
Returns the square root of `s`, where `s` is a non-negative number. If you need negative inputs, use `System.Numerics.Complex`.
Public methodStatic memberStepDecimals
Returns the position of the first non-zero digit, after the decimal point. Note that the maximum return value is 10, which is a design decision in the implementation.
Public methodStatic memberStepify
Snaps float value `s` to a given `step`. This can also be used to round a floating point number to an arbitrary number of decimals.
Public methodStatic memberTan
Returns the tangent of angle `s` in radians.
Public methodStatic memberTanh
Returns the hyperbolic tangent of angle `s` in radians.
Public methodStatic memberWrap(Int32, Int32, Int32)
Wraps `value` between `min` and `max`. Usable for creating loop-alike behavior or infinite surfaces. If `min` is `0`, this is equivalent to PosMod(Int32, Int32), so prefer using that instead.
Public methodStatic memberWrap(Single, Single, Single)
Wraps `value` between `min` and `max`. Usable for creating loop-alike behavior or infinite surfaces. If `min` is `0`, this is equivalent to PosMod(Single, Single), so prefer using that instead.
Top
See Also