Mathf
public static class MathfNamespace NodeWorld.Flux.
Math on floats, with the names of Unity's Mathf, computed inside the world's module.
Constants
PI
public const float PI = 3.14159274fPi as a float (3.14159274).
Infinity
public const float Infinity = float.PositiveInfinityPositive infinity.
NegativeInfinity
public const float NegativeInfinity = float.NegativeInfinityNegative infinity.
Deg2Rad
public const float Deg2Rad = PI / 180fMultiply degrees by it to get radians.
Rad2Deg
public const float Rad2Deg = 180f / PIMultiply radians by it to get degrees.
Epsilon
public const float Epsilon = float.EpsilonThe smallest positive float (denormal), as in Unity on platforms that keep denormals.
Methods
Sin
public static float Sin(float f)Sine of an angle in radians.
Cos
public static float Cos(float f)Cosine of an angle in radians.
Tan
public static float Tan(float f)Tangent of an angle in radians.
Asin
public static float Asin(float f)Arc sine, in radians.
Acos
public static float Acos(float f)Arc cosine, in radians.
Atan
public static float Atan(float f)Arc tangent, in radians.
Atan2
public static float Atan2(float y, float x)The angle in radians of the point (x, y) from the x axis, -PI to PI.
Sqrt
public static float Sqrt(float f)Square root.
Abs
public static float Abs(float f)Absolute value.
public static int Abs(int value)Absolute value.
Pow
public static float Pow(float f, float p)f to the power p.
Exp
public static float Exp(float power)e to the power power.
Log
public static float Log(float f, float p)Logarithm of f in base p.
public static float Log(float f)Natural logarithm (base e).
Log10
public static float Log10(float f)Logarithm in base 10.
Floor
public static float Floor(float f)The largest integer at or below f.
Ceil
public static float Ceil(float f)The smallest integer at or above f.
Round
public static float Round(float f)Nearest integer; halfway values go to the even one.
FloorToInt
public static int FloorToInt(float f)Floor, as an int.
CeilToInt
public static int CeilToInt(float f)Ceil, as an int.
RoundToInt
public static int RoundToInt(float f)Round, as an int: halfway values go to the even one.
Sign
public static float Sign(float f)1 for zero and positive values, -1 for negative ones.
Min
public static float Min(float a, float b)The smaller of two values.
public static int Min(int a, int b)The smaller of two values.
public static float Min(params float[] values)The smallest of the values (0 for none).
Max
public static float Max(float a, float b)The larger of two values.
public static int Max(int a, int b)The larger of two values.
public static float Max(params float[] values)The largest of the values (0 for none).
Clamp
public static float Clamp(float value, float min, float max)value kept between min and max.
public static int Clamp(int value, int min, int max)value kept between min and max.
Clamp01
public static float Clamp01(float value)value kept between 0 and 1.
Lerp
public static float Lerp(float a, float b, float t)From a (t = 0) to b (t = 1); t is kept between 0 and 1.
LerpUnclamped
public static float LerpUnclamped(float a, float b, float t)From a (t = 0) to b (t = 1); t is not limited.
InverseLerp
public static float InverseLerp(float a, float b, float value)Where value stands between a (0) and b (1), kept between 0 and 1; 0 when a equals b.
LerpAngle
public static float LerpAngle(float a, float b, float t)From angle a to angle b, in degrees, the short way round; t is kept between 0 and 1.
MoveTowards
public static float MoveTowards(float current, float target, float maxDelta)current moved towards target by maxDelta at most.
MoveTowardsAngle
public static float MoveTowardsAngle(float current, float target, float maxDelta)Angle current moved towards angle target by maxDelta degrees at most, the short way round.
SmoothStep
public static float SmoothStep(float from, float to, float t)From from (t = 0) to to (t = 1) with an ease in and out; t is kept between 0 and 1.
SmoothDamp
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime)Critically damped spring towards target (Game Programming Gems 4, 1.10).
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed)SmoothDamp over this frame (Time.deltaTime), at maxSpeed at most.
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime)SmoothDamp over this frame (Time.deltaTime), at any speed.
Repeat
public static float Repeat(float t, float length)t looped into [0, length).
PingPong
public static float PingPong(float t, float length)t going back and forth between 0 and length.
DeltaAngle
public static float DeltaAngle(float current, float target)Shortest difference between two angles in degrees, in [-180, 180].
Approximately
public static bool Approximately(float a, float b)Equal up to a relative tolerance (or a tiny absolute one near zero).
IsPowerOfTwo
public static bool IsPowerOfTwo(int value)value is a power of two.
NextPowerOfTwo
public static int NextPowerOfTwo(int value)The smallest power of two at or above value.
ClosestPowerOfTwo
public static int ClosestPowerOfTwo(int value)The power of two nearest to value (halfway: the larger).
