Two pi constants convenient for computation.
Returns the value itself if it's between min and max. Returns min if the value is lower than min. Returns max if the value is greater than max.
the value to clmap
the min value to clamp to (default: 0)
the max value to clamp to (default: 1)
the clamped value
Calculates the shortest difference between two given angles given in degrees.
current angle in degrees
target angle in degrees
the delta
Denormalize the value from 0.0 and 1.0 using min and max values
value to denormalize
max to denormalize between
min to denormalize between
the denormalized value
Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
spline value
spline value
spline value
spline value
input value
hermite result
Calculates the linear parameter t that produces the interpolant value within the range [a, b].
start value
target value
value between a and b
the inverseLerp value
Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
start value
target value
amount to lerp between
the lerped value
Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
start value
target value
amount to lerp between
the lerped value
the log2 of value.
the value to compute log2 of
the log2 of value.
Moves a value current towards target.
This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. Negative values of maxDelta pushes the value away from target.
current value
target value
max distance to move
resulting value
Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
current value
target value
max distance to move
resulting angle
Normalize the value between 0.0 and 1.0 using min and max values
value to normalize
max to normalize between
min to normalize between
the normalized value
Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
The angle to normalize in radian.
The converted angle.
This function returns number that corresponds to the percentage in a given range.
PercentToRange(0.34,0,100) will return 34.
to convert to number
min range
max range
the number
PingPongs the value t, so that it is never larger than length and never smaller than 0.
value
length
The returned value will move back and forth between 0 and length
Returns a random float number between and min and max values
min value of random
max value of random
random value
This function returns percentage of a number in a given range.
RangeToPercent(40,20,60) will return 0.5 (50%) RangeToPercent(34,0,100) will return 0.34 (34%)
to convert to percentage
min range
max range
the percentage
Loops the value, so that it is never larger than length and never smaller than 0.
This is similar to the modulo operator but it works with floating point numbers. For example, using 3.0 for t and 2.5 for length, the result would be 0.5. With t = 5 and length = 2.5, the result would be 0.0. Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
the value
the length
the looped value
Returns -1 if value is negative and +1 is value is positive.
the value
the value itself if it's equal to zero.
Interpolates between min and max with smoothing at the limits.
This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
from
to
value
the smooth stepped value
Returns a string : the upper case translation of the number i to hexadecimal.
number
the upper case translation of the number i to hexadecimal.
Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
number
number
(default = 1.401298E-45)
true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
Scalar computation library