Math
Accessed via math
The math module provides common mathematical functions and constants.
Properties
The mathematical constant π (pi).
The mathematical constant e (Euler's number).
The mathematical constant τ (tau), equal to 2π.
A value equal to the largest number in TruScript that can be represented before infinity.
Functions
Returns the sine of x (in radians).
Returns the cosine of x (in radians).
Returns the tangent of x (in radians).
Returns the absolute value of x.
Returns x raised to the power of y.
Returns the arcsine of x (in radians).
Returns the arccosine of x (in radians).
Returns the arctangent of x (in radians).
Returns the arctangent of y/x (in radians), using the signs of both arguments to determine the quadrant.
Returns the hyperbolic sine of x.
Returns the hyperbolic cosine of x.
Returns the hyperbolic tangent of x.
Returns the inverse hyperbolic sine of x.
Returns the inverse hyperbolic cosine of x.
Returns the inverse hyperbolic tangent of x.
Returns e raised to the power of x.
Returns the natural logarithm of x.
Returns the base-10 logarithm of x.
Returns the base-2 logarithm of x.
Returns the logarithm of x to the given base.
Returns the square root of x.
Returns the cube root of x.
Returns the largest integer less than or equal to x.
Returns the smallest integer greater than or equal to x.
Returns the value of x rounded to the nearest integer.
Returns the value of x rounded to the specified number of decimal places.
Returns the integer part of x, removing any fractional digits.
Returns the sign of x: -1 if x is negative, 0 if x is zero, and 1 if x is positive.
Returns x if it is greater than y, or y if it is greater than x.
Returns x if it is less than y, or y if it is less than x.
Returns x clamped to the range [min_value, max_value].
Returns the linear interpolation between a and b by t. If t is outside the range [0, 1], the result is extrapolated.
Returns the parameter t that produces the given value when linearly interpolating between a and b. In other words, this solves for t in the equation value = lerp(a, b, t). If value is outside the range [a, b], the result is extrapolated.
Converts an angle from degrees to radians.
Converts an angle from radians to degrees.
Returns a smooth interpolation between 0 and 1 when x is in the range [edge0, edge1]. The result is 0 when x is less than or equal to edge0, and 1 when x is greater than or equal to edge1. The function uses a cubic Hermite interpolation to ensure smoothness at the edges.
Returns x wrapped to the range [min_value, max_value). If x is less than min_value, it wraps around to the upper end of the range. If x is greater than or equal to max_value, it wraps around to the lower end of the range.
Returns a value that oscillates between 0 and length as x increases. The function is similar to the wrap function, but it "bounces" back and forth between the two ends of the range instead of wrapping around.
Returns a value that repeats every length as x increases. The function is similar to the wrap function, but it always wraps around to the lower end of the range instead of bouncing back and forth.
Returns true if x is NaN, and false otherwise.
Returns true if x is positive or negative infinity, and false otherwise.
Returns the fractional (decimal) part of x.
Returns the value that is moved from current towards target by the maximum amount of max_delta.