Mathf Methods |
The Mathf type exposes the following members.
Name | Description | |
---|---|---|
Abs(Int32) |
Returns the absolute value of `s` (i.e. positive value).
| |
Abs(Single) |
Returns the absolute value of `s` (i.e. positive value).
| |
Acos |
Returns the arc cosine of `s` in radians. Use to get the angle of cosine s.
| |
Asin |
Returns the arc sine of `s` in radians. Use to get the angle of sine s.
| |
Atan |
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`.
| |
Atan2 |
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.
| |
Cartesian2Polar |
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).
| |
Ceil |
Rounds `s` upward (towards positive infinity).
| |
CeilToInt |
Rounds `s` upward (towards positive infinity).
This is the same as Ceil(Single), but returns an `int`.
| |
Clamp(Int32, Int32, Int32) |
Clamps a `value` so that it is not less than `min` and not more than `max`.
| |
Clamp(Single, Single, Single) |
Clamps a `value` so that it is not less than `min` and not more than `max`.
| |
Cos |
Returns the cosine of angle `s` in radians.
| |
Cosh |
Returns the hyperbolic cosine of angle `s` in radians.
| |
DecimalCount(Decimal) |
Returns the amount of digits after the decimal place.
| |
DecimalCount(Single) |
Returns the amount of digits after the decimal place.
| |
Deg2Rad |
Converts an angle expressed in degrees to radians.
| |
Ease |
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.
| |
Exp |
The natural exponential function. It raises the mathematical
constant `e` to the power of `s` and returns it.
| |
Floor |
Rounds `s` downward (towards negative infinity).
| |
FloorToInt |
Rounds `s` downward (towards negative infinity).
This is the same as Floor(Single), but returns an `int`.
| |
InverseLerp |
Returns a normalized value considering the given range.
This is the opposite of Lerp(Single, Single, Single).
| |
IsEqualApprox(Single, Single) |
Returns true if `a` and `b` are approximately equal to each other.
The comparison is done using a tolerance calculation with Epsilon.
| |
IsEqualApprox(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).
| |
IsInf |
Returns whether `s` is an infinity value (either positive infinity or negative infinity).
| |
IsNaN |
Returns whether `s` is a `NaN` ("Not a Number" or invalid) value.
| |
IsZeroApprox |
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.
| |
Lerp |
Linearly interpolates between two values by a normalized value.
This is the opposite InverseLerp(Single, Single, Single).
| |
LerpAngle |
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.
| |
Log |
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.
| |
Max(Int32, Int32) |
Returns the maximum of two values.
| |
Max(Single, Single) |
Returns the maximum of two values.
| |
Min(Int32, Int32) |
Returns the minimum of two values.
| |
Min(Single, Single) |
Returns the minimum of two values.
| |
MoveToward |
Moves `from` toward `to` by the `delta` value.
Use a negative delta value to move away.
| |
NearestPo2 |
Returns the nearest larger power of 2 for the integer `value`.
| |
Polar2Cartesian |
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).
| |
PosMod(Int32, Int32) |
Performs a canonical Modulus operation, where the output is on the range `[0, b)`.
| |
PosMod(Single, Single) |
Performs a canonical Modulus operation, where the output is on the range `[0, b)`.
| |
Pow |
Returns the result of `x` raised to the power of `y`.
| |
Rad2Deg |
Converts an angle expressed in radians to degrees.
| |
Round |
Rounds `s` to the nearest whole number,
with halfway cases rounded towards the nearest multiple of two.
| |
RoundToInt | ||
Sign(Int32) |
Returns the sign of `s`: `-1` or `1`. Returns `0` if `s` is `0`.
| |
Sign(Single) |
Returns the sign of `s`: `-1` or `1`. Returns `0` if `s` is `0`.
| |
Sin |
Returns the sine of angle `s` in radians.
| |
Sinh |
Returns the hyperbolic sine of angle `s` in radians.
| |
SmoothStep |
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.
| |
Sqrt |
Returns the square root of `s`, where `s` is a non-negative number.
If you need negative inputs, use `System.Numerics.Complex`.
| |
StepDecimals |
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.
| |
Stepify |
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.
| |
Tan |
Returns the tangent of angle `s` in radians.
| |
Tanh |
Returns the hyperbolic tangent of angle `s` in radians.
| |
Wrap(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.
| |
Wrap(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.
|